$ show bytecodealliance/jco
Jco is a JavaScript toolchain for WebAssembly components. It transpiles WASM components to JavaScript, generates TypeScript types from WIT, bundles components, and provides a standard library (`jco-std`) that ports Node.js built-in modules (fs, http, tls, net, crypto, zlib, etc.) to run inside WebAssembly components via WASI Preview 2/3. The monorepo contains a Rust workspace (bindgen crates, test components) and TypeScript packages (jco CLI, jco-transpile, preview2-shim, preview3-shim, jco-std). The codebase is notable for its differential testing approach: shims are tested against native Node.js behavior, with tests for HTTP/2, TLS, SQLite, streams, and worker threads. A dual-adapter pattern (deny-by-default vs. Node-native) ensures security by default. The project supports multiple WASI versions (0.2.x, 0.3.x) and Node.js versions (24.x, 26.x), with dedicated shims for browser and Node.js runtimes. Maintenance is active (recent commits, CI workflows), but there are drift risks: pinned Node.js versions, many TODO comments, incomplete browser shims (throwing Todo), and experimental features like JSPI and async support.
The LLM identified 8 files worth highlighting for reuse:
Portable Node.js `fs` implementation for WASM components, exposing a host-adapter interface that can be swapped between deny-by-default, Node-native, and custom implementations. Demonstrates the dual-adapter pattern used across all Node builtins.
TLS host adapter that offloads native crypto to a worker thread, providing a clean boundary between the WASM guest and Node.js TLS stack. Shows how to bridge synchronous WASI interfaces to asynchronous Node.js APIs.
Networking module factory that creates WASI-compatible socket implementations. Uses a factory pattern to inject host-specific behavior, enabling the same WIT interface to run on Node.js, browser, or custom hosts.
HTTP/2 module factory for WASI Preview 2, providing a typed host interface with multiple implementations. Demonstrates the host-adapter composition pattern for complex protocol modules.
Structured-value encoding for crossing the WASM/JS boundary, implementing a JSON-based graph serialization format. Reusable for any component that needs to pass complex values between guest and host.
Shared argument validation utilities adapted from Node.js, providing consistent type-checking and error messages across all builtin shims. Portable and dependency-free.
Worker threads implementation for WASM components, including a callback registry pattern for guest-exported resources and structured message passing. Demonstrates how to bridge Node.js worker_threads to WASI threads.
Rust implementation of JS identifier generation with reserved-keyword handling and collision avoidance. Used by the bindgen crate to produce valid JavaScript identifiers from WIT names, with regression tests for edge cases like `eval`.