/unconf-092020-wasm

Some experiments and benchmarks on WASM for Mia-Platform unconference

Primary LanguageJavaScript

Surfacing WebAssembly

Mia-Platfom Unconference 09/2020

Useful bash commands

# link wasm support file in website
$ cd web; ln -s $(tinygo env TINYGOROOT)/targets/wasm_exec.js ./wasm_exec.js
$ cd primes; ln -s $(tinygo env TINYGOROOT)/targets/wasm_exec.js ./wasm_exec.js

# compile go package
$ cd go; tinygo build -o main.wasm  -heap-size 16076496 -target wasm .

# run minimal HTTP server, checkout localhost:8080/web
$ goexec 'http.ListenAndServe(`:8080`, http.FileServer(http.Dir(`.`)))'

Notes

Go support is still limited: to expose functions with a custom interface it's far better using tinygo compiler; otherwise functions must be defined with a specific interface defined in syscall/js package and must be injected into js window global variable.