From 29c81a5622c9cc09bd43e47a6e616a5708f976d0 Mon Sep 17 00:00:00 2001 From: Volodymyr Shymanskyy Date: Sat, 1 May 2021 02:49:21 +0300 Subject: [PATCH] Update Cookbook.md --- docs/Cookbook.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/Cookbook.md b/docs/Cookbook.md index 2d1a582..f89a3c8 100644 --- a/docs/Cookbook.md +++ b/docs/Cookbook.md @@ -22,24 +22,23 @@ Hello, world! Create `hello.ts`: ```ts import "wasi" - import {Console} from "as-wasi" + Console.log('Hello World!'); ``` Create `package.json`: ```json { - "name": "hello", - "version": "1.0.0", - "description": "Hello world with AssemblyScript and as-wasi", - "main": "hello.ts", "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": { - "assemblyscript": "^0.18.30", - "as-wasi": "^0.4.4" + "assemblyscript": "*", + "as-wasi": "*" } } ``` @@ -68,7 +67,7 @@ func main() { Build and run: ```sh -$ tinygo build -o hello.wasm -target wasi ./hello.go +$ tinygo build -o hello.wasm -target wasi -no-debug hello.go $ wasm3 hello.wasm Hello, world! @@ -119,6 +118,7 @@ The easiest way to start is to use [Wasienv](https://github.com/wasienv/wasienv) Create `hello.cpp`: ```cpp #include + int main() { std::cout << "Hello, world!" << std::endl; return 0; @@ -128,6 +128,7 @@ int main() { Or `hello.c`: ```c #include + int main() { printf("Hello, %s!\n", "world"); return 0;