1. 17

Hi everyone!

This new tutorial goes a bit more in depth than the extant tutorials we’ve had for Rust and WebAssembly. The goal is to introduce all the topics you need when doing real Rust+Wasm development, all with a single running example to give continuity.

Topics covered include:

  • Setting up the toolchain and making a hello world
  • Designing Rust programs for WebAssembly
  • Debugging
  • Time profiling
  • Code size profiling

Every chapter also has exercises, if you want to challenge yourself.

If you follow along with the tutorial, please take notes along the way!! Your feedback would be incredibly valuable!



  2. 1

    Is there any way to specify the current project is using the wasm target so one could just use cargo build instead of relying on npm? I tried rustup override but I keep having an error about the wasm target not found, even though I just installed it on nightly.

    1. 1

      If you look at what npm run build-debug and npm run build-release are doing, you’ll see that it isn’t very magic:

      cargo +nightly build --target wasm32-unknown-unknown && \
          wasm-bindgen target/wasm32-unknown-unknown/debug/wasm_game_of_life.wasm --out-dir .

      So, yes, you can use cargo build to create the .wasm binary, you just have to supply the --target wasm32-unknown-unknown. However, to get the generated JavaScript API glue, you need to also run wasm-bindgen.

      The npm run build-* commands just package them both up in one step for convenience.