rules_wasm 2.3.0Latest published 6.5mo ago
MODULE.bazel
bazel_dep(name = "rules_wasm", version = "2.3.0")
README

WebAssembly Component Bazel Tools

A Bazel module with tools for working with WebAssembly components.

This module primarily hosts language-agnostic rules for working with WebAssembly components, but also welcomes language-specific rules to compile source code files into components (including generating WIT bindings).

Rules

  • //wasm:defs.bzl:
    • wasm_component - Turn a core Wasm module into a component.
    • wasm_plug - Link the exports of a 'plug' component into the imports of a 'wrapper' component to create a new component. This is the simplest way to compose components together without a WAC file.
    • wit_package - Bundle a group of WIT files into a unified package.
  • //rust:defs.bzl:
    • rust_component - Compile a WIT interface and matching Rust implementation into a Wasm component. Use the default Rust toolchain.
    • rust_wit_bindgen - Generate Rust sources for a Wasm interface. This is a lower-level rule that you normally wouldn't need to use directly. Use rust_component for a single macro to compile a component from Rust.
  • C support is hacky and needs to be adapted to a proper CC toolchain (blocked on bazelbuild/rules_cc#277), but there's //c:defs.bzl, which makes use of the WASI SDK:
    • c_component - Compile a WIT interface and matching C implementation into a Wasm component.
    • c_wit_bindgen - Generate C sources for a Wasm interface. This is a lower-level rule that you normally wouldn't need to use directly. Use c_component for a single macro to compile a component from C.
  • Go support is hacky and needs to be adapted to a proper Go toolchain. This is fundamentally difficult because Bazel's Go rules require knowing about module metadata and dependencies during the analysis phase, but the output of wit-bindgen-go is only known for sure during the execution phase. Meanwhile, there's a temporary crutch: //go:defs.bzl, which makes use of TinyGo and is somewhat limited.
    • go_component - Compile a WIT interface and matching Go implementation into a Wasm component.
    • go_wit_bindgen - Generate Go sources for a Wasm interface, including a minimal go.mod file to emulate a Go module. This is a lower-level rule that you normally wouldn't need to use directly. Use go_component for a single macro to compile a component from Go.

Examples

See example/.

Caveats

  • Currently works only for the following execution platforms (due to the use of Bash scripts and downloading pre-built tool binaries):
    • aarch64-linux
    • aarch64-macos
    • x86_64-linux
    • x86_64-macos

About

Bazel tools for working with WebAssembly components

@vimana-cloud/rules_wasm@vimana-cloud
Homepage
3stars
Monday, March 16, 2026
@ouillie#7992 rules_wasm@2.3.0 (#7992)

Languages

Shell16.9%
Rust1.4%
Go1.1%
C0.4%

Maintainers

@ouillie

Compatibility

Versions

2.3.0 +5d2026-03-16
2.2.1 +1.5mo2026-03-11
2.1.1 +3d2026-01-25
2.1.0 +1.5mo2026-01-21
2.0.3 +5d2025-12-06
2.0.2 +9.4mo2025-12-01
1.1.1 +2.8mo2025-02-20
1.0.17 +1.2mo2024-11-26
1.0.162024-10-21