clawdio-bitcrusher
v0.1.0
Published
Write Rust code and compile to WASM for use on the web.
Readme
Rust WASM Library Template
Write Rust code and compile to WASM for use on the web.
Based on wasm-pack-template and this guide.
Requirements
- Rust
- wasm-pack
Development
- Install deps:
cargo - Write code (or import it into) in
lib.rs
Building
Build project using:
- General use:
wasm-pack build - AudioWorklet:
wasm-pack build --target web
This generates a WASM build, and nice JS + TS glue files, inside the /pkg folder.
For the general use version you'll likely need to use a build plugin to handle the WASM, like vite-plugin-wasm for a Vite build system.
If building for AudioWorklet, make sure to add the
--target webflag or you'll get errors about TextEncoder missing, or a globalURLvariable being undefined.
Using code
- Build project (see above)
- Go into build folder:
cd pkg - Create a link to the module:
yarn link - Go into another JS project and link the module:
yarn link rust-wasm-audio
