Skip to content

Conversation

@RReverser
Copy link
Contributor

@RReverser RReverser commented Sep 11, 2025

This PR allows user to pass custom --target to Cargo which will take precedence over the wasm32-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! 📦✅

  • You have the latest version of rustfmt installed
$ rustup component add rustfmt
  • You ran cargo fmt on the code base before submitting
  • You reference which issue is being closed in the PR text

✨✨ 😄 Thanks so much for contributing to wasm-pack! 😄 ✨✨

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.
@drager drager requested a review from Copilot September 16, 2025 13:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@RReverser
Copy link
Contributor Author

RReverser commented Sep 16, 2025

@drager this from CI logs looks like upstream issue:

Caused by: failed to execute cargo-generate: exited with exit status: 1
full command: "/home/runner/work/wasm-pack/wasm-pack/target/test_cache/cargo-generate-f1e7334e4b3e9562/cargo-generate" "generate" "--git" "[https://github.com/drager/wasm-pack-template](https://github.com/drager/wasm-pack-template/)" "--name" "generated-project"

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.

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.

wasm32-unknown-emscripten support wasm-pack does not understand overriden target-dir Support for wasm32-wasi target?

1 participant