feat: shared component utils + unified extension (Phase 1-2 of #250, #253)#416
Merged
feat: shared component utils + unified extension (Phase 1-2 of #250, #253)#416
Conversation
Create common/wasm_component_utils.bzl with: - WASI_VERSION_ATTR_KWARGS, VALIDATE_WIT_ATTR_KWARGS (shared attr definitions) - create_component_info() factory (replaces 7 identical WasmComponentInfo blocks) - normalize_wit_info() (unifies 3 incompatible WIT handling patterns) - validate_component_action() (shared validation, previously only Rust+Go) Refactor rust_wasm_component.bzl to use shared utils: - WasmComponentInfo creation: 15 lines → 5 lines - WIT validation: 78 lines → 6 lines - Attribute definitions: shared kwargs No behavioral changes — all existing builds and tests pass. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace WasmComponentInfo creation in python_wasm_component and python_wasm_binary with create_component_info() factory. Use shared WASI_VERSION_ATTR_KWARGS for consistent attribute definitions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Migrate WasmComponentInfo creation in Go, C++, and JS rules to use create_component_info() factory from shared wasm_component_utils.bzl. Add wasi_version attribute to Go, C++, and JS rules (previously only Rust and Python had it). All 7 language rules now consistently support wasi_version = "p2" | "p3" via shared WASI_VERSION_ATTR_KWARGS. Use shared VALIDATE_WIT_ATTR_KWARGS in Go (C++ already had custom). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New unified_extension.bzl provides a single entry point for all
toolchain setup with a languages parameter that controls what gets
downloaded:
wasm = use_extension("@rules_wasm_component//wasm:unified_extension.bzl", "wasm")
wasm.toolchains(
bundle = "stable-2026-03",
languages = ["rust", "go"],
)
Key features:
- languages parameter: only download toolchains you need
- bundle parameter: pre-validated version combinations
- include_p3: opt-in P3 WIT definitions
- Core tools (wasm-tools, wasmtime, wkg) always loaded
- Language-specific tools loaded conditionally:
- go: tinygo + binaryen
- cpp: wasi-sdk + cpp_component
- javascript: jco + binaryen
- python: componentize-py (lazy)
Existing individual extensions remain unchanged for backward compatibility.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Safe minor/patch dependency bumps. Major bumps deferred: - aspect_bazel_lib 2→3 (breaking), rules_go 0.59→0.60 (TinyGo risk), buildifier_prebuilt 6→8 (breaking) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This was referenced Mar 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary — Phase 1-2 of unified architecture (#250, #253, #257)
Phase 1: Shared Utilities
Create
common/wasm_component_utils.bzland migrate all 7 language rules:create_component_info()normalize_wit_info()validate_component_action()WASI_VERSION_ATTR_KWARGSAll 7 rules migrated: Rust, Python (component + binary), Go, C++, JS.
~170 LOC eliminated.
wasi_versionnow consistent across all languages.Phase 2: Unified Extension (#250)
New
wasm/unified_extension.bzlwith language selection:languagesparameter controls downloads (~50MB Rust-only vs ~950MB all)Test plan
//examples/basic:hello_componentbuilds//examples/go_component:calculator_componentbuilds//examples/js_component:simple_js_componentbuilds//test/p3:allpasses🤖 Generated with Claude Code