-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Summary
The export\! macro generated by rust_wasm_component_bindgen is not accessible from user code due to visibility restrictions.
Problem Details
- Generated wrapper creates
export\!macro aspub(crate):
// In generated wrapper at line 148:
pub(crate) use __export_camera_front_impl as export;- User code cannot access it:
// Error: macro `export` is private
camera_front_ecu_bindings::export\!(Component);- Compilation error:
error[E0603]: macro `export` is private
--> components/sensors/camera-front/src/lib.rs:17:28
Root Cause
The wrapper file at /rust/rust_wasm_component_bindgen.bzl generates the export macro with pub(crate) visibility, but the bindings are compiled as a separate crate, making the macro inaccessible from user code.
Suggested Fix
In the wrapper generation template, change:
pub(crate) use __export_camera_front_impl as export;to:
pub use __export_camera_front_impl as export;Steps to Reproduce
- Create a WIT file with a world definition:
package example:component;
world my-world {
export process: func() -> string;
}- Use
rust_wasm_component_bindgenin BUILD.bazel:
rust_wasm_component_bindgen(
name = "my_component",
srcs = ["src/lib.rs"],
wit = ":my_interfaces",
)- Try to use the export macro in src/lib.rs:
use my_component_bindings::{Guest, export};
struct Component;
impl Guest for Component {
fn process() -> String {
"Hello".to_string()
}
}
export\!(Component);- Build fails with
error[E0603]: macroexportis private
Impact
This blocks migration of projects using the new rust_wasm_component_bindgen API, as there's no way to export the component implementation.
Environment
- Bazel 8.3.1
- rules_wasm_component commit: 125a46f
- Platform: macOS ARM64
Metadata
Metadata
Assignees
Labels
No labels