Stream: jco

Topic: Integration of jco and JSPI


view this post on Zulip Catherine (whitequark) (Oct 29 2025 at 16:25):

I would like to use jco together with JSPI. To be specific, I have many WASIp2 (which are currently wrapped WASIp1) applications, which are in turn wrapped with jco and ran from the web as well as other platforms. Since wasi-virt is incapable of providing a filesystem overlay, I have to implement the entire filesystem in JavaScript.

Right now, I have to download the entire filesystem upfront. I would like to download files on-demand whenever they're opened (or at least to provide the option to do so), to avoid massive waste of bandwidth when packages like Clang are involved (where sizes of 100..400 MB are not uncommon). To do this, I need jco to wrap the wasi:cli/run export in WebAssembly.promising (easy enough), and the path_open import (or its WASIp2 equivalent) in WebAssembly.Suspending (which --async-import seems to silently fail to do).

How do I do this with jco?

view this post on Zulip Victor Adossi (Oct 29 2025 at 16:29):

Have you tried with the asyncMode: 'jspi' option just yet? Also, I'm assuming you already know about --instantiation=async?

view this post on Zulip Victor Adossi (Oct 29 2025 at 16:31):

Here's an example from a test:

https://github.com/bytecodealliance/jco/blob/fd13566145b81611c7ad400cb115ae195f2c30f6/packages/jco/test/jspi.js#L72

Unfortunately we don't have a good example in the Jco book, but we do have the option documented:

https://bytecodealliance.github.io/jco/transpiling.html?highlight=jspi#options

JavaScript toolchain for working with WebAssembly Components - bytecodealliance/jco

view this post on Zulip Victor Adossi (Oct 29 2025 at 16:31):

As you can see from the test you'll need to specify your async imports as well

JavaScript toolchain for working with WebAssembly Components - bytecodealliance/jco

view this post on Zulip Victor Adossi (Oct 29 2025 at 16:32):

I'd love to know which documentation you took a quick glance at to see where we should include better docs on this, but the book is probably a good start (contributions welcome of course!).

If you'd like to create a ticket against jco that would help with tracking the improvement to the documentation

view this post on Zulip Catherine (whitequark) (Oct 29 2025 at 17:48):

Turns out I had a small and difficult to notice typo in my jco invocation. The following seems to do what I want:

jco [...] --async-mode jspi --async-exports 'wasi:cli/run#run' --async-imports 'wasi:filesystem/types#[method]descriptor.open-at'

Thanks!


Last updated: Dec 06 2025 at 07:03 UTC