- install the rust toolchain
- install npm
- install wasm-pack
- install some more deps
apt-get install gcc libssl-dev pkg-config lld
- clone this repo
- cd rust-us
- ./start.sh
- Once you see
ℹ 「wdm」: Compiled successfully.
, open your browser to http://localhost:8080/
This will also automatically watch the rust code in ./src/
and incrementally rebuild on changes. If you're lucky, your web browser will also automatically reload after a successful build.
This guide has a few pointers. I got ~20% faster compiles by following it: https://bevyengine.org/learn/book/getting-started/setup/#enable-fast-compiles-optional
A template for kick starting a Rust and WebAssembly project using wasm-pack.
Tutorial – wasm-pack-template discord
📚 Read this template tutorial! 📚
This template is designed for compiling Rust libraries into WebAssembly and publishing the resulting package to NPM.
Be sure to check out other wasm-pack
tutorials online for other
templates and usages of wasm-pack
.
wasm-pack build
wasm-pack test --headless --firefox
wasm-pack publish
wasm-bindgen
for communicating between WebAssembly and JavaScript.console_error_panic_hook
for logging panic messages to the developer console.wee_alloc
, an allocator optimized for small code size.