- computation, rendering and iterations made in Rust/WebAssembly
- Unit tests
- Setup some performance infos to pull up / Benchmark ?
./crate/src: Rust implementation of Ball.js
Rust / Node / npm
Currently, only the nightly toolchain of Rust is supporting WebAssembly:
rustup default nightly rustup target add wasm32-unknown-unknown
Make sure you have
cargo install wasm-pack, then:
Launches a development server on http://localhost:8080.
npm run build
Will build a production version of the website in the
You can test your build by running
npm run serve
This project is sort of half polyfill for features like the host bindings proposal and half features for empowering high-level interactions between JS and wasm-compiled code (currently mostly from Rust). More specifically this project allows JS/wasm to communicate with strings, JS objects, classes, etc, as opposed to purely integers and floats. Using
wasm-bindgenfor example you can define a JS class in Rust or take a string from JS or return one. The functionality is growing as well!
If you want to generate the WebAssembly yourself (without Webpack):
wasm-pack build ./crate
This will create a
pkg folder containing:
package.json: like any npm package
ball_wasm.d.ts: TypeScript definitions of public functions of your rust crate that was turned to WebAssembly
ball_wasm_bg.wasm: Rust code turned into WebAssembly (will be required by
rustup default nightly will let you use rust nighly by default:
- That way, for each command, you won't have to specify the toolchain like:
cargo +nightly [cmd]
- To get back to stable channel (you may have other project relying on stable channel), run:
rustup default stable
- To check which default toolchain you're on, run the following:
rustup toolchain list
The Rust part is not automatically formatted at pre-commit hook (didn't want to force the user to install rustfmt-preview), please make sure you use a RLS (Rust Language Server) plugin for your editor that will format your code.
If you use vscode, you will have to open the
crate folder as project (the plugin doesn't support subfolders yet).