Setup
This section describes how to set up the toolchain for compiling Rust programsto WebAssembly and integrate them into JavaScript.
The Rust Toolchain
You will need the standard Rust toolchain, including rustup
, rustc
, andcargo
.
Follow these instructions to install the Rust toolchain.
The Rust and WebAssembly experience is riding the Rust release trains to stable!That means we don't require any experimental feature flags. However, we dorequire Rust 1.30 or newer.
wasm-pack
wasm-pack
is your one-stop shop for building, testing, and publishingRust-generated WebAssembly.
cargo-generate
Install cargo-generate
with this command:
cargo install cargo-generate
npm
npm
is a package manager for JavaScript. We will use it to install and run aJavaScript bundler and development server. At the end of the tutorial, we willpublish our compiled .wasm
to the npm
registry.
Follow these instructions to install npm
.
If you already have npm
installed, make sure it is up to date with thiscommand:
npm install npm@latest -g