Update Cookbook.md

extensions
Volodymyr Shymanskyy 3 years ago committed by GitHub
parent ddf5afeee2
commit 29c81a5622
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -22,24 +22,23 @@ Hello, world!
Create `hello.ts`: Create `hello.ts`:
```ts ```ts
import "wasi" import "wasi"
import {Console} from "as-wasi" import {Console} from "as-wasi"
Console.log('Hello World!'); Console.log('Hello World!');
``` ```
Create `package.json`: Create `package.json`:
```json ```json
{ {
"name": "hello",
"version": "1.0.0",
"description": "Hello world with AssemblyScript and as-wasi",
"main": "hello.ts",
"scripts": { "scripts": {
"build": "asc hello.ts -b hello.wasm" "asbuild:debug": "asc hello.ts -b hello.wasm --debug",
"asbuild:optimized": "asc hello.ts -b hello.wasm -O3s --noAssert",
"asbuild:tiny": "asc hello.ts -b hello.wasm -O3z --noAssert --runtime stub --use abort=",
"build": "npm run asbuild:optimized"
}, },
"devDependencies": { "devDependencies": {
"assemblyscript": "^0.18.30", "assemblyscript": "*",
"as-wasi": "^0.4.4" "as-wasi": "*"
} }
} }
``` ```
@ -68,7 +67,7 @@ func main() {
Build and run: Build and run:
```sh ```sh
$ tinygo build -o hello.wasm -target wasi ./hello.go $ tinygo build -o hello.wasm -target wasi -no-debug hello.go
$ wasm3 hello.wasm $ wasm3 hello.wasm
Hello, world! Hello, world!
@ -119,6 +118,7 @@ The easiest way to start is to use [Wasienv](https://github.com/wasienv/wasienv)
Create `hello.cpp`: Create `hello.cpp`:
```cpp ```cpp
#include <iostream> #include <iostream>
int main() { int main() {
std::cout << "Hello, world!" << std::endl; std::cout << "Hello, world!" << std::endl;
return 0; return 0;
@ -128,6 +128,7 @@ int main() {
Or `hello.c`: Or `hello.c`:
```c ```c
#include <stdio.h> #include <stdio.h>
int main() { int main() {
printf("Hello, %s!\n", "world"); printf("Hello, %s!\n", "world");
return 0; return 0;

Loading…
Cancel
Save