Stream: wit-bindgen

Topic: Extending wit-bindgen to generate JS bindings


view this post on Zulip foobat (Jul 22 2023 at 15:01):

I'm working in a project to run WASM and JS on IOT devices. We want to use WASM components in our project, but our WASM runtime has no component model support. We tried JCO but it doesn't work on our project, because our WASM API dose not support cross module imports, but JCO often generates multiple modules even if there's only one input component.

Since the only way to create a compnent now is creating a core module with wit-bindgen and clang, and convert this core module to a component. There's nothing special with this core module except it uses components' ABI. As a workaround in a transition stage, we want to run this core module directly on our runtime, instead of converting it to a component and transpiring it back to core module with JCO.

So I want to extend wit-bindgen to generate JS bindings for this core module from a WIT file. This may sound weird, but the same mechanism that wit-bindgen use to generate ABI bridge is suitable for generating JS bindings to a core module. The README of wit-bindegn suggests me to reach out the authors here. So I'm here to get some further information.

THANKS.

view this post on Zulip Mossaka (Joe) (Jul 24 2023 at 23:49):

@Guy Bedford could give you some insights as he's the author of jco.

view this post on Zulip Guy Bedford (Jul 25 2023 at 18:44):

@foobat it may be possible for JCO to convert the internal adapter Wasm modules into JS, and this is something we may need to explore for other reasons

view this post on Zulip Guy Bedford (Jul 25 2023 at 18:45):

if so, it sounds like that might enable your use case, provided the component does not use component composition internally

view this post on Zulip Guy Bedford (Jul 25 2023 at 18:45):

that said, a lot of interesting components just do use composition anyway, so there would still be quite a strong restriction on the environment

view this post on Zulip Guy Bedford (Jul 25 2023 at 18:46):

if you are interested in that overall direction, we definitely need help updating JCO to convert the internal "core adapters" into JS

view this post on Zulip Guy Bedford (Jul 25 2023 at 18:49):

that sounds very similar to the work you're interested in, so we could pick it up on github if you're keen - https://github.com/bytecodealliance/jco/issues/116.

If we had the capability to convert adapter core modules that only do transcoding (eg in #79) and other simple binding attachment operations into the associated JS code, this would unblock some com...

Last updated: Dec 23 2024 at 12:05 UTC