Docker Image for wasm-pack
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:
- a wasm-loader for webpack: https://github.com/ballercat/wasm-loader
- Using with parcel https://parceljs.org/webAssembly.html
Manually compiling .wasm
files can be tedious. There are ways to make this automated:
- Parcel supports importing rust files directly https://parceljs.org/rust.html
create-react-app
style webpack boilerplates exist to handle all of the compiling stages such as https://github.com/rustwasm/rust-webpack-template
Read other posts