jco transpile: Run Wasm Components in JavaScript
jco transpile turns a WebAssembly component into JavaScript ES modules plus a core wasm, so components run in Node and browsers.
jco (JavaScript Component Tools) is the bridge between the component model and JS runtimes. In CI it transpiles a built component into importable JS for tests or bundling.
What it does
jco transpile reads a component and emits ES module glue that instantiates the underlying core module and exposes its WIT interfaces as JS. jco componentize does the reverse for JS: it wraps a JS module into a component from a WIT world.
Common usage
jco transpile component.wasm -o out
jco transpile component.wasm -o out --map 'wasi:*=./wasi-shim.js'
jco componentize app.js --wit world.wit -o component.wasm
jco --versionOptions
| Flag / subcommand | What it does |
|---|---|
| transpile | Component to JS ES modules + core wasm |
| -o <dir> | Output directory for the generated files |
| --map <spec> | Map an imported interface to a JS implementation |
| --instantiation | Emit a manual instantiation function instead of top-level await |
| componentize | Wrap a JS module into a component from a WIT world |
In CI
jco runs on Node; install it with npm i -g @bytecodealliance/jco or as a dev dependency and cache node_modules. Validate the component first with wasm-tools validate; jco surfaces clearer errors on a valid component. Provide --map shims for any host imports the component expects.
Common errors in CI
"jco: command not found" means the package is not installed. "Error: no export named ..." means the WIT world does not match what you import. "missing import wasi:..." means an unmapped host interface; supply it with --map. Passing a core module instead of a component gives "expected a component".