Stream: jco

Topic: ✔ Stability of `jco` for non-wasi components


view this post on Zulip Patricio Palladino (Jun 18 2024 at 21:30):

Hi there!

We have a few rust libraries that target Node.js using N-API, and are currently exploring how to provide browser-compatible wasm builds, and components and jco look super promising.

I'm wondering how stable it is for projects that don't need wasi (they are isolated from the OS/runtime — e.g. one of them is a praser), but need to run both in the browser and Node.js.

The readme mentions * WASI Preview2 support in Node.js ([undergoing stabilization](https://github.com/bytecodealliance/jco/milestone/1)) & browsers (experimental)., but is that for WASI Preview 2? Or should I read it as "the entire jco should be considered experimental when targeting browsers"?

view this post on Zulip Ramon Klass (Jun 18 2024 at 21:47):

jco is only for wasi, if you want to compile your rust code that doesn't require wasi into something browsers can run, you want wasm-bindgen

view this post on Zulip Guy Bedford (Jun 18 2024 at 21:49):

Thanks for the question, Jco's transpilation layer is stable and this is reflected in the 1.x status and the project will be following semver for all features except for jco componentize which is still unstable. With regards to WASI support, that is also stable in Node.js, it is just the browser WASI support that is still experimental.

view this post on Zulip Ramon Klass (Jun 18 2024 at 21:49):

as an example, swc has https://swc.rs/docs/usage/core and https://swc.rs/docs/usage/wasm which are compiled from the same codebase, but one is napi and the other is wasm

view this post on Zulip Patricio Palladino (Jun 18 2024 at 21:51):

@Ramon Klass , is it limited to wasi? do you include "wasm components" in your definition of what wasi is? I'm still trying to make up my mind about how to distinguish the scope of each project. I understand the difference at the technical level, but the line is fuzzy at the product (and especially docs) level

view this post on Zulip Patricio Palladino (Jun 18 2024 at 21:52):

using components even without wasi (as in the set of standard interfaces), would allow us to run the components on other stacks, which is also a longer-term goal of ours

view this post on Zulip Patricio Palladino (Jun 18 2024 at 21:55):

Guy Bedford said:

hanks for the question, Jco's transpilation layer is stable and this is reflected in the 1.x status and the project will be following semver for all features except for jco componentize which is still unstable. With regards to WASI support, that is also stable in Node.js, it is just the browser WASI support that is still experimental.

Thanks for your answer! So if transpiled component doesn't need @bytecodealliance/preview2-shim it should be sable in the browser, right?

view this post on Zulip Patricio Palladino (Jun 18 2024 at 21:58):

Just as an interesting data point to the conversation, supporting multiple platforms using N-API can be pretty annoying, so wasm components+jco can be an amazing alternative to it.

So what started as a "let's make this run in the browser" effort, is now turning into "can we do everything with wasm components?"

view this post on Zulip Guy Bedford (Jun 19 2024 at 14:41):

Thanks for your answer! So if transpiled component doesn't need @bytecodealliance/preview2-shim it should be sable in the browser, right?

Yes exactly. Note that WASI Preview2 is stable itself, so some users just write their own preview2 implementations as necessary to support functionality in the browser - it's only the browser implementation of preview2 that is unstable currently.

view this post on Zulip Patricio Palladino (Jun 19 2024 at 15:18):

Thanks for your confirmation. And thanks a ton for your work on jco

view this post on Zulip Notification Bot (Jun 19 2024 at 15:23):

Patricio Palladino has marked this topic as resolved.


Last updated: Nov 26 2024 at 00:12 UTC