This tool was created by the Rust / Wasm Working Group for building WebAssembly applications. It supports packaging code into
wasm-pack requires that you set the crate-type explicitly to include
[lib]crate-type = ["rlib", "cdylib"]
cargo install wasm-pack
This command will produce a bundle in the
./pkg directory with your app's compiled WebAssembly
wasm-pack build --target web
For more information on rollup.js visit this guide.
rollup ./main.js --format iife --file ./pkg/bundle.js
When using a bundler like rollup.js you can omit
Feel free to use your preferred server. Here we use a simple Python server to serve the built app.
python -m http.server 8000
If you don't have Python installed, you can install and use the
simple-http-server crate instead.