Skip to content

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

Closed
stephanemagnenat wants to merge 1 commit intodrager:masterfrom
enlightware:fix/sideEffectsMaster
Closed

Tell bundler that the generated package has side effects. Closes #972.#1208
stephanemagnenat wants to merge 1 commit intodrager:masterfrom
enlightware:fix/sideEffectsMaster

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 drager#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 drager#972.
@drager
Copy link
Owner

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