To use rust and webassembly requires installing a fair amount of tooling. I decided to create a docker image with everything required:

  • rust 1.30
  • wasm-pack
  • cargo-generate
  • nodejs
  • yarn
  • exposes port 8080 and port 5000

It is available on docker hub: https://hub.docker.com/r/rnsloan/wasm-pack/

To pull the image: docker pull rnsloan/wasm-pack:1.0.0.

wasm-pack

To use wasm-pack follow the guide here: https://rustwasm.github.io/wasm-pack/book/project-setup/using-a-template.html

JavaScript

For instructions on how to use .wasm files with JavaScript look at guides with JS bundling tools such as:

Manually compiling .wasm files can be tedious. There are ways to make this automated: