Is it possible to use wit-bindgen to generate host and guest bindings for use with non-component WASM (i.e.: plain old modules)?
For the guest bindings, all tookchains presently emit core Wasm modules, plus a custom section that contains the component type information. Wit-component can translate those modules to a component
For host bindings, the answer is more complicated. Wasmtime has a component runtime, so the host bindings generated simply use that. But JavaScript does not have a component runtime, so wit-bindgen emits the JavaScript code that implements one for the given component type
If you want to target another host wasm runtime that doesn’t have a component runtime, you can follow the general way the js host binding generation works to generate host code that uses the Wasm runtime to implement a runtime for that particular component type.
Also just fyi the host generators are moving to new homes, for software engineering reasons. They will still work the same way, they just won’t be used through the wit-bindgen cli https://github.com/bytecodealliance/wit-bindgen/issues/395
Thanks @Pat Hickey. To clarify -- I want to use wit-bindgen with the non-component runtime in Wasmtime, so that I can use WASI (since component WASI is still very WIP). I suppose this isn't straightforward?
Nope this isn’t possible. Sit tight and we will land wasi support as soon as we can
Last updated: Dec 23 2024 at 13:07 UTC