Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasm-pack runs wasm-bindgen on wrong binary for certain cargo flags #1410

Open
zebp opened this issue Jul 10, 2024 · 0 comments · May be fixed by #1421
Open

wasm-pack runs wasm-bindgen on wrong binary for certain cargo flags #1410

zebp opened this issue Jul 10, 2024 · 0 comments · May be fixed by #1421

Comments

@zebp
Copy link

zebp commented Jul 10, 2024

🐛 Bug description

wasm-pack makes the assumption that the final binary for the build command will always be target/wasm32-unknown-unknown/{debug|release}/whatever.wasm regardless of the build options passed to Cargo, some of them change the result of the final path but still emit a binary since the invalid path also gets a different binary. The case I've been running into is when passing --tests to Cargo a file with tests compiled into the binary will be emitted to target/wasm32-unknown-unknown/debug/deps/$NAME-$HASH.wasm and a binary without tests compiled in will be emitted to target/wasm32-unknown-unknown/debug/$name.wasm.

🤔 Expected Behavior

wasm-pack should run wasm-bindgen on the final binary specified by Cargo by parsing Cargo's message format. I'm willing to author a PR fixing this since this issue is blocking for me.

👟 Steps to reproduce

These following command will build give you the path Cargo emitted the correct binary to, but wasm-pack won't operate on:

$ git clone git@github.com:zebp/wasm-pack-test-repro.git
$ cd wasm-pack-test-repro
# Sometimes this flakes and returns "null", not sure why.
$ wasm-pack build --dev -- --tests --message-format=json-diagnostic-rendered-ansi | tail -2 | head -1 | jq --raw-output .executable
# Has the expected function names conditionally compiled with #[cfg(test)]
$ strings $THE_PATH_FROM_LAST_STEP | grep a_very_unique_name_to_grep
# Doesn't have the expected functions since cargo didn't emit a binary with tests enabled to location wasm-pack used
$ strings ./pkg/wasm_pack_test_repro_bg.wasm | grep a_very_unique_name_to_grep 

Note, this is flaky for some reason specifically when using wasm-pack. If you use the same arguments to Cargo directly it always acts as expected.

🌍 Your environment

Include the relevant details of your environment.
wasm-pack version: 0.13.0
rustc version: 1.79.0 (129f3b996 2024-06-10)

@zebp zebp linked a pull request Aug 18, 2024 that will close this issue
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 a pull request may close this issue.

1 participant