This example demonstrates the simplest possible WebAssembly component using Rust.
src/lib.rs- Rust component implementationwit/hello.wit- WIT interface definitionBUILD.bazel- Bazel build configuration
# Build the component
bazel build //examples/basic:hello_component
# Test the component
bazel test //examples/basic:hello_component_testThe component exports a simple hello function:
package hello:world;
world hello {
export hello: func(name: string) -> string;
}# Test with wasmtime
wasmtime run --wasi preview2 bazel-bin/examples/basic/hello_component.wasm
# Or use the built-in test
bazel test //examples/basic:hello_component_testThis demonstrates the minimal setup required for a WebAssembly component with rules_wasm_component.