componentize-js: JS Module to Wasm Component
componentize-js embeds a JavaScript module into a wasm component that implements a given WIT world, using an embedded JS engine.
componentize-js is the engine behind jco componentize: it packages your JS (running on an embedded SpiderMonkey) into a real component that any component host can run.
What it does
componentize-js takes a JS entry module and a WIT world, and produces a component whose exports are backed by your JS running on an embedded engine. It is usually driven through jco but also exposes a Node API.
Common usage
# via jco (the common path)
jco componentize app.js --wit world.wit -o component.wasm
# then validate and run
wasm-tools validate component.wasmOptions
| Option | What it does |
|---|---|
| --wit <path> | WIT file or directory defining the world to implement |
| --world-name <name> | Select a specific world when the WIT has several |
| -o <file> | Output component path |
| --disable <feature> | Disable an optional capability (e.g. random, clocks) |
In CI
Your JS must export exactly the functions the WIT world declares; a name or signature mismatch fails componentization. Because it is Node-based, cache node_modules and pin the componentize-js/jco versions so the embedded engine and WIT handling stay consistent.
Common errors in CI
"Expected component to export ..." means your JS is missing an export the world requires. "No such world ..." means --world-name does not match the WIT. Unsupported JS syntax or a missing global surfaces as a build-time engine error. Validate the output with wasm-tools to confirm it is a well-formed component.