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

Tell bundler that the generated package has side effects. Closes #972. #1208

Closed

Conversation

stephanemagnenat
Copy link

This is a brutal fix for #972, that sets sideEffects to true for ES modules so that the Rust main function (annotated #[wasm_bindgen(start)]) is not tree-shaked. A better solution would be to detect if the main function is present in the Rust code and emit the sideEffects flag accordingly.

Liamolucko added a commit to Liamolucko/wasm-pack that referenced this pull request Feb 5, 2023
This is a less extreme version of rustwasm#1208, which only marks snippets and the main file on the bundler target as having side effects instead of all files.

This means that the shim file which contains the vast majority of the JS code is still properly marked as having no side effects, allowing bundlers to get rid of things like unused `new TextEncoder` calls which could theoretically have side effects but don't.

Fixes rustwasm#972.
@drager
Copy link
Member

drager commented Jul 5, 2023

Fixed in #1224

@drager drager closed this Jul 5, 2023
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.

2 participants