wasm-tools component: Build and Wrap Components
wasm-tools component wraps a core wasm module into a WebAssembly component, applying WASI adapters as needed.
The component model needs core modules wrapped with the right adapter. wasm-tools component new is the CLI that does it, a common CI step between a Rust/C build and a component host.
What it does
wasm-tools component new takes a core module and produces a component, using an --adapt adapter (for example the WASI preview1-to-preview2 shim). wasm-tools component wit prints the WIT world of a component.
Common usage
wasm-tools component new core.wasm -o component.wasm
wasm-tools component new core.wasm \
--adapt wasi_snapshot_preview1.reactor.wasm -o component.wasm
wasm-tools component wit component.wasmOptions
| Subcommand / flag | What it does |
|---|---|
| component new | Turn a core module into a component |
| --adapt <name=file> | Supply a WASI adapter module to satisfy imports |
| -o <file> | Output component path |
| component wit | Print the WIT world/interfaces of a component |
| component embed | Embed a WIT world into a core module for later new |
In CI
A Rust module built for wasm32-wasip1 usually needs the preview1 reactor adapter passed via --adapt; ship the adapter with your build cache. Validate the result with wasm-tools validate before handing it to jco or a host.
Common errors in CI
"missing adapter for import wasi_snapshot_preview1" means you must pass --adapt with the reactor/command adapter. "component ... requires ... but adapter provides ..." is an adapter version mismatch; use the adapter matching your wasi crate. "expected a core module" means you already passed a component.