-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Import expression effect check considers moduleSideEffects #6120
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
base: master
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Thank you for your contribution! ❤️You can try out this pull request locally by installing Rollup via npm install rollup/rollup#feat/enhance-tree-shaking-for-dynamic-importsNotice: Ensure you have installed the latest nightly Rust toolchain. If you haven't installed it yet, please see https://www.rust-lang.org/tools/install to learn how to download Rustup and install Rust. or load it into the REPL: |
Performance report
|
Codecov Report✅ All modified and coverable lines are covered by tests. Please upload reports for the commit 70baa48 to get more accurate results. Additional details and impacted files@@ Coverage Diff @@
## master #6120 +/- ##
=======================================
Coverage 98.73% 98.74%
=======================================
Files 271 271
Lines 10630 10652 +22
Branches 2846 2853 +7
=======================================
+ Hits 10496 10518 +22
Misses 89 89
Partials 45 45 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
You are mostly right, but it will never be synchronous, and some logic may rely on the fact that it is async. As this is hard to detect, I would suggest instead to replace it with something compact like an |
|
Oh, I misunderstood before. I get it now—if an async function doesn’t have an |
ddbdfef to
70baa48
Compare
|
After thinking it through, it seems difficult to replace an awaiting import expression with I originally thought Maybe we have to narrow the scope of this PR and only take import expressions into account. |
That is not true. For instance, a BlockStatement also does not propagate the inclusion to its children, and I would have hoped this can work similarly. It is wrong, though, to have conditional logic in |
5369863 to
96b5453
Compare
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
relevant: #6073
Description
Technically, an
awaitexpression should always have side effects, since it delays the execution of the following code. For example:Here,
'b'is logged before'a'.But if the argument to
awaitis animport()expression, I think theawaitexpression could be safely removed. In that case, the execution timing of the following code is not deterministic anyway, since it is affected by file I/O or network requests.