-
Notifications
You must be signed in to change notification settings - Fork 416
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
There should be a way to disable sideEffects: false
#972
Comments
The problem is indeed significant. Because of side effects are ignored by default, the "main" Rust function annotated with |
Liamolucko
added a commit
to Liamolucko/wasm-pack
that referenced
this issue
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🐛 Bug description
Custom JS snippets can contain top-level side-effects. Right now, wasm-pack generated package.json includes
sideEffects: false
which marks every file as side-effect free, leading to potential bugs after bundling.🤔 Expected Behavior
When JS snippet files are generated, they should be put into the
sideEffects
array, and only the JS file generated by wasm-bindgen should be assumed to be side-effect free since it's the only one wasm-bindgen has control over.package.json
allows to list potentially side-effect-y files asThis will avoid bugs for snippets with top-level side-effects, while it won't decrease optimization level for common scenarios where the module is used via its main entry point.
The text was updated successfully, but these errors were encountered: