liveBook · Manning

Wac

As explained in Server-Side WebAssembly

wac is a WebAssembly composition tool that links component imports and exports and can produce a composed component.

wac is a WebAssembly composition tool that connects component exports to matching imports, producing a standalone composed component. Its plug-and-socket model treats exports as plugs and imports as sockets. section 4.5

Compose two Rust-produced components with this workflow:

  • Build the binary and library components with cargo component build --release. section 4.5
  • Install the CLI with cargo install --locked wac-cli@0.6.1. section 4.5
  • Run wac plug composability_bin.wasm --plug composability_lib.wasm -o composability.wasm to connect the binary's hello-world import to the library's export. section 4.5
  • Run the resulting artifact with wasmtime composability.wasm, without custom host functionality. section 4.5

Resolving hello-world

A binary component imports hello-world: func() -> string, while a library component exports the same function. wac embeds both components, wires the import to the export, and produces composability.wasm. Running it prints "Hello from Lib!". section 4.5

How Server-Side WebAssembly covers it

How deep it goes
Explains plug-based linkage and embedded components, while deferring complex composition-language scenarios.
Examples
Uses binary and library components linked through hello-world and executed as composability.wasm.
What it assumes
Requires compiled WebAssembly components with compatible WIT-defined imports and exports.
What you can do after
Build composed components with wac plug and run the resulting standalone artifact with wasmtime.
How it connects
Connects WebAssembly components with WIT, imports, exports, the component model, Canonical ABI, and wasmtime.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Server-Side WebAssembly. The section links point to the parts of the book it draws on.