Skip to content

Conversation

@rafaelbeckel
Copy link
Contributor

@rafaelbeckel rafaelbeckel commented Nov 12, 2025

This PR implements support for passing arbitrary flags to wasm-bindgen via wasm-pack build.

Addresses #1092

CLI changes

  • New repeatable flag: --wbg-arg (alias: --wbg)
    • Example usage:
      • wasm-pack build --wbg-arg --experimental-reset-state-function
      • wasm-pack build --wbg-arg --weak-refs --wbg-arg --reference-types

Implementation

  • BuildOptions: add wbg_arg: Vec (Clap v4, allow_hyphen_values, visible_alias = "wbg").
  • Build: store bindgen_args and plumb through the build pipeline.
  • bindgen::wasm_bindgen_build: accept &[String] of args and append them to the wasm-bindgen Command (after defaults, so users can override if desired).
  • docs: Document the new flag with examples.
  • tests: Add an integration test asserting that a forwarded unknown flag is visible in the wasm-bindgen invocation (proves passthrough).

Closes #1092

- Add repeatable --wbg-arg (alias: --wbg) to forward args to wasm-bindgen
- Wire args through build pipeline and bindgen invocation
- Docs: usage examples and notes
- Tests: verify passthrough forwards unknown flag
- Quiet test: suppress unexpected_cfg warnings via RUSTFLAGS
- Generate/new tests: default template now rustwasm/wasm-pack-template to avoid auth issues
This reverts commit 83b056e.
#[clap(
long = "template",
default_value = "https://github.com/drager/wasm-pack-template"
default_value = "https://github.com/rustwasm/wasm-pack-template"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default_value = "https://github.com/rustwasm/wasm-pack-template"
default_value = "https://github.com/drager/wasm-pack-template"

@rafaelbeckel rafaelbeckel changed the title feat(build): add --wbg-arg passthrough to wasm-bindgen Pass arguments to wasm-bindgen Nov 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pass arguments to wasm-bindgen

1 participant