Hello, very much a newbie with wasi32 and wasm in general - used to using wasm-pack. Struggling to export rust compiled to wasm32-wasi into javascript. Wondering if I am doing the right thing using wit-bindgen for this purpose?
wit-bindgen is part of the picture here, however there are now also higher-level tools that do more of the work for you. cargo-component can produce wasm components written in Rust, and jco can help them run in a JS environment so you can use them from JS.
This video includes a walkthrough of using these tools together.
awesome! digging in now, tysm
Hello @Jack Gilcrest, to run rust-compiled-to-wasm with wit bindgen, you can check out this example repo at the wit-bindgen
branch.
In folder plguin-rust
, you have the Rust code that will run in the browser, and in runtime-web-jco
you have the JS implementation. The code is very messy becauseI was testing something, but you should be able to read how to put it together. See also the build-and-run-web.sh
script.
One note is that this is using wasm32-unknown-unkown
target and not wasi, so this might not work for you if you need wasi capabilities.
Last updated: Nov 22 2024 at 17:03 UTC