Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

WASI support

Components that import WASI interfaces need a host implementation of those interfaces at runtime. Jco ships two such implementations as npm packages, and jco transpile maps WASI imports to them automatically:

WASI versionPackageMapped imports
0.2.x@bytecodealliance/preview2-shimwasi:cli, clocks, filesystem, http, io, random, sockets
0.3.x@bytecodealliance/preview3-shimwasi:cli, clocks, filesystem, http, random, sockets

Both packages provide a Node.js build and a browser build, selected through the package’s node export condition, so the same transpiled component runs in either environment.

  • Preview 2 shim describes the WASI 0.2 implementation, its browser capability model, sandboxing with WASIShim, and the host-side helper functions.
  • Preview 3 shim describes the WASI 0.3 implementation and how it maps versions.

The mapping is expressed through the same --map mechanism available to any import; see WASI Shims in the Transpiling chapter. Pass --no-wasi-shim to treat WASI like any other import, and see Manual Wasm instantiation with WASI overrides to supply your own implementations at instantiation time.