Skip to content

Commit 2eea594

Browse files
committed
fix: update wkg_publish rule to use WasmComponentInfo provider for multi-file component support
Root cause: wkg_publish used allow_single_file=['.wasm'] constraint but rust_wasm_component_bindgen creates composite targets with both .wasm files and validation .log files, causing: '//examples/basic:hello_component_release' must produce a single file Solution: Updated wkg_publish to match wkg_push pattern: - Use WasmComponentInfo provider instead of allow_single_file constraint - Extract component.wasm_file from provider (ignores other files) - Add backward compatibility with wasm_file attribute for direct .wasm files This allows wkg_publish to work with complex component targets that produce multiple outputs while correctly isolating just the .wasm component file for publishing.
1 parent abe392c commit 2eea594

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

wkg/defs.bzl

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,14 @@ def _wkg_publish_impl(ctx):
221221
wkg_toolchain = ctx.toolchains["//toolchains:wkg_toolchain_type"]
222222
wkg = wkg_toolchain.wkg
223223

224-
# Component file to publish
225-
component = ctx.file.component
224+
# Get component file from WasmComponentInfo provider (like wkg_push does)
225+
if ctx.attr.component:
226+
component_info = ctx.attr.component[WasmComponentInfo]
227+
component = component_info.wasm_file
228+
elif ctx.file.wasm_file:
229+
component = ctx.file.wasm_file
230+
else:
231+
fail("Either component (with WasmComponentInfo) or wasm_file must be specified")
226232

227233
# Create wkg.toml metadata file
228234
metadata_content = """
@@ -314,9 +320,12 @@ wkg_publish = rule(
314320
implementation = _wkg_publish_impl,
315321
attrs = {
316322
"component": attr.label(
317-
doc = "WebAssembly component file to publish",
323+
providers = [WasmComponentInfo],
324+
doc = "WebAssembly component to publish",
325+
),
326+
"wasm_file": attr.label(
318327
allow_single_file = [".wasm"],
319-
mandatory = True,
328+
doc = "WebAssembly component file to publish (alternative to component)",
320329
),
321330
"package_name": attr.string(
322331
doc = "Package name for publishing",

0 commit comments

Comments
 (0)