Get the system ready.
rustup target add wasm32-wasi
cargo install cargo-component
npm install
Run locally on NodeJS.
cargo component build
npx jco transpile target/wasm32-wasi/debug/jco_test.wasm -o nodejs/out_dir
node nodejs/main.js
Serve for browsers.
cargo component build
npx jco transpile target/wasm32-wasi/debug/jco_test.wasm -o browser/out_dir --no-nodejs-compat
node server.js
Run as a native executable. Uncomment the [[bin]]
section in Cargo.toml
file first.
cargo run
Other commands.
npx jco wit target/wasm32-wasi/debug/jco_test.wasm