One exported function, no imports:
| File | Role |
|---|---|
wit/world.wit |
greet: func(name: string) -> string |
guest/src/lib.rs |
Rust implementation using wit-bindgen |
host.ts |
Load the packaged translator, instantiate, call, and check the greeting |
From the repository root:
just shim
./examples/hello-world/run.shRequires Deno, Rust with wasm32-unknown-unknown, and wasm-tools. The script
builds the guest, componentizes and validates it, type-checks the host, and runs
it with read access to the example's build/ directory. Package resolution
comes from the repository workspace; see examples before
copying the directory out.
instantiate({ componentBytes, translator }, {}) supplies the empty import
record. await component.exports.greet(...) uses the default asynchronous host
calling convention even though the guest function is synchronous. The runtime
copies the returned string out of guest memory and handles canonical post-return
cleanup.
Continue with kitchen-sink for imports and other value shapes. The embedder contract is the API reference.