Examples demonstrating the WebAssembly Component Model using rules_wasm_component with Bazel.
Note
Part of the PulseEngine toolchain. Demonstrates patterns used across the PulseEngine toolchain.
| Example | Language | Type | Description |
|---|---|---|---|
//c:hello_c |
C | Library | Exports greeter interface |
//cpp:hello_cpp |
C++ | Library | Exports greeter interface |
//go:hello_go |
Go | CLI | Hello world with TinyGo |
//rust:hello_rust |
Rust | CLI | Hello world CLI component |
//rust:calculator |
Rust | CLI | Arithmetic calculator |
//rust:datetime |
Rust | CLI | Shows current date/time |
//rust:yolo_inference |
Rust | CLI + WASI-NN | YOLO object detection |
# Build all examples
bazel build //...
# Build specific example
bazel build //rust:hello_rust
bazel build //rust:yolo_inference_release# Hello world
wasmtime bazel-bin/rust/hello_rust.runfiles/_main/rust/hello_rust_host.wasm
# Calculator
wasmtime bazel-bin/rust/calculator.runfiles/_main/rust/calculator_host.wasm 8 + 8
# DateTime
wasmtime bazel-bin/rust/datetime.runfiles/_main/rust/datetime_host.wasmRequires ONNX model (see models/README.md):
# Download model
curl -L -o models/yolov8n.onnx \
https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8n.onnx
mkdir -p models/yolov8n && ln -sf ../yolov8n.onnx models/yolov8n/model.onnx
# Run detection
wasmtime run --dir . -S cli -S nn -S nn-graph=onnx::./models/yolov8n \
bazel-out/darwin_arm64-fastbuild-ST-*/bin/rust/yolo_inference_wasm_lib_release_wasm_base.wasm \
./bus.jpg.
├── c/ # C hello world component
├── cpp/ # C++ hello world component
├── rust/ # Rust components
│ ├── src/
│ │ ├── main.rs # hello_rust
│ │ ├── calculator.rs # calculator
│ │ ├── datetime.rs # datetime
│ │ └── yolo_inference.rs # YOLO detection logic
│ └── wit/yolo.wit
├── models/ # ONNX models (download separately)
├── MODULE.bazel
└── BUILD.bazel
Export custom interfaces that can be composed with other components:
interface greeter {
greet: func() -> string;
}
world hello-c {
export greeter;
}Export wasi:cli/run for direct execution with Wasmtime.
- CI (
ci.yml): Builds all components on Linux and macOS, runs Rust CLI tests - Release (
release.yml): Creates signed releases with provenance attestation
Apache-2.0
Part of PulseEngine — formally verified WebAssembly toolchain for safety-critical systems