jco is a JavaScript toolchain for turning WIT definitions and JavaScript into WebAssembly components, then generating JavaScript glue for using those components. section 3.2.1 section 3.4.3
A practical jco workflow is:
- Install Node.js and npm, then install jco and componentize-js globally. section 3.2.1
- Run jco componentize with the JavaScript file, WIT file, world name, output path, and explicitly disabled capabilities. section 3.2.3
- Run jco transpile on the resulting .wasm file to inspect generated TypeScript declarations and JavaScript type mappings. section 3.4.3
SmartCMS key-value guest
A JavaScript guest imports get and set from component:smartcms/kvstore, stores guest-hello, and returns the retrieved value. jco componentizes it against the host WIT interface; transpilation maps Rust’s Option type to string | undefined. The component runs with stdio, random, clocks, and HTTP disabled, producing “Hello from the Guest!”. section 3.4.3
jco componentize greet.js --wit greet.wit --world-name
➥example --out greet.wasm --disable stdio random clocks http
Inspect the complete componentization command, including WIT input, world selection, output naming, and disabled capabilities. section 3.2.3
Listing 3.8 The TypeScript declaration file for our key-value store interface
/** @module Interface component:smartcms/kvstore **/ export function get(key: string): string | undefined; export function set(key: string, value: string): void;
Inspect the generated TypeScript declarations that expose the host key-value interface to JavaScript. section 3.4.3
