Rust ➡ WebAssembly for Webpack, Node.js and Deno
See Getting started with Rust and WebAssembly
- Install Rust
- Install Node.js
- Install
wasm-pack
- Run
npm install
- Install Rust
- Install Node.js
- Install
wasm-pack
- Alternatively, install
cargo-make
- Alternatively, install
-
Add the following
.envrc
file:use flake # activates the flake dotenv_if_exists .env # optionally loads a .env file if it exists
-
Run
direnv allow .
inside the project directory to allow Direnv to execute the.envrc
-
For Webpack, also run
npm install
wasm-pack build --target nodejs
- Builds and generates bindings forsrc/lib.rs
node src/node.mjs
- Runssrc/node.mjs
cargo make run-node
- Runssrc/node.mjs
npm run serve
- Open http://localhost:8080
cargo make run-deno
- Runssrc/deno.ts