The setup is based on this tutorial, but an excerpt follows below.
Install rust and then wasm-pack:
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
Install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Follow any extra instructions from the script and restart your terminal. Then run:
nvm install v16.13.2
nvm use
You don't need to specify the version since it is set by the .nvmrc
file.
Install npm and then run:
npm install
To start a web server that auto-reloads on changes, run:
npm start
Run:
npm run start:dist
Note that you need Python 3.8 (2019 release) or newer, else the mime type won't be correct for the wasm content.
We release by pushing to the github pages branch with the help of the gh-pages package.
To publish/deploy run:
npm run deploy
Run all tests:
npm run test:node
That command is an alias for WASM_BINDGEN_TEST_TIMEOUT=60 wasm-pack test --node
.
Or run a specific test file:
npm run test:node -- --test tier_0
Install:
cargo install wasm-bindgen-cli
Run with:
WASM_BINDGEN_TEST_TIMEOUT=60 cargo test --target wasm32-unknown-unknown
We use prettier for formatting. Please run the following before committing:
npx prettier --write .
Or a faster version:
npx prettier \
$(git diff --name-only --diff-filter=ACM) \
$(git diff --cached --name-only --diff-filter=ACM) \
--write --ignore-unknown