wa-lang.org/wazero@v1.0.2/imports/assemblyscript/example/README.md (about) 1 ## AssemblyScript example 2 3 This example runs a WebAssembly program compiled using AssemblyScript, built 4 with `npm install && npm run build`. 5 6 AssemblyScript program exports two functions, `hello_world` which executes 7 simple math, and `goodbye_world`, which throws an error that is logged using 8 AssemblyScript `abort` built-in function. 9 10 This demo configures AssemblyScript imports for errors and trace messages. 11 12 ```bash 13 $ go run assemblyscript.go 7 14 hello_world returned: 10 15 sad sad world at index.ts:7:3 16 ``` 17 18 Note: [index.ts](testdata/index.ts) avoids use of JavaScript functions that use 19 I/O, such as [console.log][1]. If your code uses these, compile your code with 20 the [wasi-shim][2] and configure in wazero using 21 `wasi_snapshot_preview1.Instantiate`. 22 23 [1]: https://github.com/AssemblyScript/assemblyscript/blob/v0.21.2/std/assembly/bindings/dom.ts#L143 24 [2]: https://github.com/AssemblyScript/wasi-shim#usage