#wasm-component #component-model

wac-graph

A library for defining, encoding, and decoding WebAssembly composition graphs

14 releases (breaking)

0.10.0 Apr 17, 2026
0.9.0 Feb 2, 2026
0.9.0-dev Nov 10, 2025
0.7.0 Jun 17, 2025
0.5.0 Jul 22, 2024

#2579 in WebAssembly

Download history 3106/week @ 2026-01-19 2488/week @ 2026-01-26 3980/week @ 2026-02-02 7209/week @ 2026-02-09 4013/week @ 2026-02-16 4432/week @ 2026-02-23 5535/week @ 2026-03-02 5553/week @ 2026-03-09 5713/week @ 2026-03-16 6295/week @ 2026-03-23 7546/week @ 2026-03-30 9067/week @ 2026-04-06 8966/week @ 2026-04-13 14734/week @ 2026-04-20 9792/week @ 2026-04-27 11184/week @ 2026-05-04

45,639 downloads per month
Used in 19 crates (14 directly)

Apache-2.0 WITH LLVM-exception

295KB
6.5K SLoC

A library for defining, encoding, and decoding WebAssembly composition graphs.

An example of composing two components together using a CompositionGraph:

use wac_graph::{CompositionGraph, EncodeOptions, types::Package};

let mut graph = CompositionGraph::new();

// Register the packages with the graph
// It is assumed that `my:package1` exports a function named `a`,
// while `my:package2` imports a function named `b`.
let pkg = Package::from_file("my:package1", None, "package1.wasm", graph.types_mut())?;
let package1 = graph.register_package(pkg)?;
let pkg = Package::from_file("my:package2", None, "package2.wasm", graph.types_mut())?;
let package2 = graph.register_package(pkg)?;

// Instantiate package `my:package1`
let instantiation1 = graph.instantiate(package1);

// Alias the `a` export of the `my:package1` instance
let a = graph.alias_instance_export(instantiation1, "a")?;

// Instantiate package `my:package2`
let instantiation2 = graph.instantiate(package2);

// Set argument `b` of the instantiation of `my:package2` to `a`
graph.set_instantiation_argument(instantiation2, "b", a)?;

// Finally, encode the graph into a new component
let bytes = graph.encode(EncodeOptions::default())?;

Dependencies

~6MB
~107K SLoC