No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-09-28 22:08:56 +02:00
.cargo initial commit 2026-09-28 22:08:56 +02:00
crates initial commit 2026-09-28 22:08:56 +02:00
.gitignore initial commit 2026-09-28 22:08:56 +02:00
Cargo.lock initial commit 2026-09-28 22:08:56 +02:00
Cargo.toml initial commit 2026-09-28 22:08:56 +02:00
README.md initial commit 2026-09-28 22:08:56 +02:00
wkg.lock initial commit 2026-09-28 22:08:56 +02:00
wkg.toml initial commit 2026-09-28 22:08:56 +02:00

WebAssembly Components Example

Prerequisites

cargo install wasmtime-cli --locked # runtime
cargo install wkg --locked # component dependency resolution
cargo install wac-cli --locked # component linking

Resolve component dependencies

cd crates/format-gcd
wkg fetch # creates wit/deps/...

Build components

cargo build --release

Invoke math-gcd

wasmtime run --invoke "gcd(39, 26)" target/wasm32-wasip2/release/math_gcd.wasm

Invoke format-gcd

First, we need to link the components together to resolve all dependencies. Here, format_gcd imports interfaces from math_gcd.

wac plug target/wasm32-wasip2/release/format_gcd.wasm \
 --plug target/wasm32-wasip2/release/math_gcd.wasm \
 -o combined.wasm

Then, we can invoke the combined component.

wasmtime run --invoke "format-gcd(39, 26)" combined.wasm