/rust-wasm

A demo of WebAssembly via Rust and wasm-pack

Primary LanguageRustGNU General Public License v3.0GPL-3.0

rust-wasm

A demo of WebAssembly via Rust and wasm-pack.

Reference: https://rustwasm.github.io/docs/book/

Compile WASM

Use a multi-stage Docker build to compile Rust to WASM, and place the resulting code in build/.

DOCKER_BUILDKIT=1 podman build -t rust-wasm . --output build/ # or `make build`

Run Node.js server

There is a Node.js application in build/www which imports WASM from build/.

npm install --prefix build/www
npm start --prefix build/www # or `make start`

Then, visit http://localhost:8080 in a browser to execute WASM.