-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Used code incorrectly dropped with sideEffects: false & unrelated reexport #5375
Comments
Seems to be fixed in the current nightly ( |
Oh, you are right. I have focused on creating the minimal repro case and I haven't checked the very latest nightly build 🤦 This is already fixed in |
👍 Honestly at first I though this would be the first bug report for something introduced by #4861. I think this is similar to this one? https://github.com/parcel-bundler/parcel/blob/v2/packages/core/integration-tests/test/integration/scope-hoisting/es6/re-export-import/b.js The problem being that there there is first an import and then an unused reexport to the same file. Then the export would mark the dependency as "weak". |
This test looks quite similar (I'm talking purely about the structure of the linked file) but this is not a test added in #4861 so I assume that there is some difference between it and the case presented here. Otherwise, the test suite would be already failing for a long time. I'm not sure if I have understood your later comment - but if you are saying that the export+import order has been important for my case then it's not true. I've rechecked with both orders and the result is broken in the very same way (on the |
Yeah, the order doesn't really matter.
This test is very similar: https://github.com/parcel-bundler/parcel/blob/v2/packages/core/integration-tests/test/integration/scope-hoisting/es6/side-effects-re-exports-import/node_modules/bar/index.js. Import+reexport, the reexport is unused, sideEffects: false |
It indeed looks very similar (as the other one that you have pointed me to) - but this is also not a new test 🤔 |
-> #5376 |
🐛 bug report
🎛 Configuration (.babelrc, package.json, cli command)
🤔 Expected Behavior
Used import should stay in the bundle and be called correctly
😯 Current Behavior
Used import is being removed and replaced with
{}
💁 Possible Solution
This most likely happens during scope hoisting / module concatenation but I can't be totally sure because I don't know enough about Parcel's architecture and, unfortunately, I haven't more time digging into this right now.
What I have been able to establish is that the problem is somewhere before
treeShake
gets called.🔦 Context
We got a report about
@emotion/react
being broken with Parcel 2 here: emotion-js/emotion#2114 (comment)It results in a runtime error for production builds, therefore the impact on users is severe.
💻 Code Sample
I've prepared quite a detailed repro case here:
https://github.com/Andarist/parcel-sideeffects-flag-bug-repro
When bundling the entrypoint this line from a dependency is affected:
https://github.com/Andarist/parcel-sideeffects-flag-bug-repro/blob/fd386c2c9c2f01ff3ec6135e4e2f0672e05a61dc/src/node_modules/emotion-react/index.js#L5
and the
hasOwnProperty
gets replaced with{}
which leads to a runtime error in a production build. The final output can be checked here:https://github.com/Andarist/parcel-sideeffects-flag-bug-repro/blob/fd386c2c9c2f01ff3ec6135e4e2f0672e05a61dc/dist/parcel/index.f7c7b3c5.js#L1
I've also included webpack and Rollup demos for comparison (they both work correctly):
https://github.com/Andarist/parcel-sideeffects-flag-bug-repro/tree/fd386c2c9c2f01ff3ec6135e4e2f0672e05a61dc/dist
What I have also been able to establish is that this happens because:
sideEffects: false
is specified for this dependencyYou can check out 2 demos that remove each one of them (but not both at the same time!):
sideEffects: false
: https://github.com/Andarist/parcel-sideeffects-flag-bug-repro/compare/without-sideeffects-falseThey both lead to the same, correct, output - they result in the very same hash in the generated JS bundle.
🌍 Your Environment
2.0.0-nightly.447
The text was updated successfully, but these errors were encountered: