Skip to content

bevy build web fails with an opaque wasm-bindgen error when the wasm exports are only in the library target #762

@mirsella

Description

@mirsella

Hello !

CLI or linter version

bevy 0.1.0-dev (4dd0654)

[Optional] Relevant system information

  • rustc 1.96.0-nightly (03749d625 2026-03-14)
  • Linux

What you did

I had a package with both:

  • a normal binary target
  • a library target with crate-type = [\"cdylib\", \"rlib\"]

The JS-facing #[wasm_bindgen] exports were only defined in the library target, while the wasm main() in the binary target was basically empty.

Then I ran:

bevy build -p game_client web

What went wrong

I expected either:

  • this layout to be supported, or
  • a clear error saying that bevy build web only supports JS-facing wasm exports from binary targets

Instead, the CLI built both wasm artifacts, but always ran wasm-bindgen on <bin>.wasm.
That ended up failing with this pretty opaque error:

error: failed to find intrinsics to enable `clone_ref` function

What made this confusing is that manually running wasm-bindgen on the generated lib*.wasm worked fine.

Additional information

This seems related to #230 because that issue already notes that the current web bundling logic is binary-oriented

Thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-WebBuilding or running Bevy apps targeting the browserC-BugA bug in the programD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesS-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions