I'm likely missing something obvious, but I'm trying to switch from wasm-bindgen to using cargo-component to build from my WIT definitions. I'm targeting the browser (via jco), so I don't need any of the default WASI stuff (clocks, cli, random, i/o, etc.), but I can't figure out how to configure cargo-component to omit those unused WASI bits. None of my WIT interfaces import any wasi stuff, so I just assume it's included in every component, but is there a way to avoid this and just use the component model minus WASI via cargo-component?
https://github.com/bytecodealliance/WASI-Virt will help you with that.
Additionally, you can pass --target wasm32-unknown-unknown
to cargo component build
to omit WASI imports from the generated component
Thanks Joel and Peter! I tried playing around with wasm32-unknown-unknown, but I'll give that another try. I'll also look into the Virtual Implementations.
Joel Dice said:
https://github.com/bytecodealliance/WASI-Virt will help you with that.
Can these virtual interfaces be used as an adapter?
No, it can't be used as a replacement for the wasi_snapshot_preview1.wasm adapter, if that's what you mean. It works at the component level to virtualize Preview 2 interfaces, so the adapter it uses doesn't have the shape that wit-component
(on which cargo-component
is based) expects adapters to have.
Last updated: Nov 25 2024 at 19:03 UTC