This directory contains examples demonstrating different approaches to building WebAssembly modules and components with full support for multiple languages.
Status: ✅ Working
A basic WebAssembly component using Rust with WIT interfaces and generated bindings.
bazel build //examples/basic:hello_component
bazel test //examples/basic:hello_component_test
Use this when:
- You need a simple component with WIT interfaces
- You want to learn the basic component model workflow
- You need rich interface types (strings, records, enums)
Status: ✅ Working
Advanced Go WebAssembly components using TinyGo v0.38.0 with WASI Preview 2 support.
bazel build //examples/go_component:calculator_component
bazel build //examples/go_component:http_service_component
Use this when:
- You want to write components in Go
- You need WASI Preview 2 functionality
- You want automatic WIT binding generation for Go
Status: ✅ Working
WebAssembly components written in C++ with WASI SDK toolchain.
bazel build //examples/cpp_component/calculator:calculator_component
bazel build //examples/cpp_component/http_service:http_service_component
Use this when:
- You have existing C++ code to port
- You need high performance components
- You want to leverage C++ ecosystem libraries
Status: ✅ Working
WebAssembly components using ComponentizeJS for JavaScript/TypeScript.
bazel build //examples/js_component:calculator_component
Use this when:
- You want to write components in JavaScript/TypeScript
- You need rapid prototyping capabilities
- You want to leverage npm ecosystem
- Full WebAssembly Component Model support
- Advanced WIT binding generation
- Production-ready toolchain
- Optimized for size and performance
- TinyGo v0.38.0 with WASI Preview 2
- Dual-step compilation (WASM module → Component)
- WASI Preview 1 adapter integration
- Full go.bytecodealliance.org support
- WASI SDK toolchain
- C-style WIT bindings
- High performance native code
- Extensive C/C++ ecosystem support
- ComponentizeJS integration
- Full npm ecosystem access
- TypeScript type safety
- Rapid development workflow
All major languages supported with first-class toolchain integration.
Automatic binding generation from WIT interface definitions for all languages.
Full support for composing components across languages using WAC.
Optimized toolchains with proper caching, parallel builds, and platform constraints.
# Build all working examples
bazel build //examples/basic:hello_component
bazel build //examples/go_component:calculator_component
bazel build //examples/cpp_component/calculator:calculator_cpp_component
bazel build //examples/js_component:hello_js_component
# Run tests
bazel test //examples/basic:hello_component_test
bazel test //examples/go_component:...
All examples are production ready and demonstrate best practices for WebAssembly Component Model development! 🎉