Conversation
This PR allows user to pass custom `--target` to Cargo which will take precedence over the `wasm32-unknown-unknown`. This allows us to experiments with targets like Emscripten and WASI in wasm-bindgen projects more easily.
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for custom target triples in wasm-pack, allowing users to specify arbitrary --target options to Cargo instead of being locked to wasm32-unknown-unknown. The implementation also switches from hardcoded directory structures to using Cargo metadata for artifact discovery.
- Updates target checking functions to accept custom target triples
- Replaces hardcoded path construction with Cargo metadata parsing for WASM artifact location
- Modifies the build process to respect user-specified targets while defaulting to
wasm32-unknown-unknown
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/command/test.rs | Updates test command to use new parameterized target checking function |
| src/command/build.rs | Adds target triple parsing from extra options and WASM path tracking |
| src/child.rs | Generalizes run_capture_stdout to accept any Display type instead of Tool enum |
| src/build/wasm_target.rs | Refactors target checking functions to accept arbitrary target triples |
| src/build/mod.rs | Implements Cargo metadata parsing to locate build artifacts dynamically |
| src/bindgen.rs | Removes hardcoded path construction in favor of direct WASM path parameter |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
@drager this from CI logs looks like upstream issue:
Looks like you might need to fork (transfer?) https://github.com/rustwasm/wasm-pack-template as well as https://github.com/drager/wasm-pack-template doesn't exist. |
|
Is this dead? |
Fixes build failure when Cargo.toml has both cdylib and rlib in crate-type by filtering artifacts to only .wasm files before the single-artifact check.
|
Thank you for this PR @RReverser! |
This PR allows user to pass custom
--targetto Cargo which will take precedence over thewasm32-unknown-unknown.The artifact lookup is also updated to use Cargo metadata instead of custom logic with hardcoded directory structure.
This allows us to experiments with targets like Emscripten and WASI in wasm-bindgen projects more easily.
Fixes #654.
Fixes #906.
Fixes #1349.
Fixes #1468.
Fixes #1469.
Make sure these boxes are checked! 📦✅
rustfmtinstalledcargo fmton the code base before submitting✨✨ 😄 Thanks so much for contributing to wasm-pack! 😄 ✨✨