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
feat: tree-shake deterministic dynamic imports #4952
feat: tree-shake deterministic dynamic imports #4952
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov Report
@@ Coverage Diff @@
## master #4952 +/- ##
=======================================
Coverage 98.98% 98.98%
=======================================
Files 222 222
Lines 8050 8112 +62
Branches 2210 2236 +26
=======================================
+ Hits 7968 8030 +62
Misses 28 28
Partials 54 54
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
04cd599
to
913bb4c
Compare
056a017
to
9ac9832
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some final comments and a possible optimization I stumbled upon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thanks a lot!
This PR has been released as part of rollup@3.21.0. You can test it via |
* - `const { foo } = await import('bar')`. | ||
* - `(await import('bar')).foo` | ||
* - `import('bar').then(({ foo }) => {})` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be doc'ed here too? https://rollupjs.org/introduction/#tree-shaking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any PR for the docs is welcome! I guess something similar to what Parcel has does not hurt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this what you're referring to? https://parceljs.org/features/scope-hoisting/#dynamic-imports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
And we might even include a REPL link to see it in action and play around
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
resolves #4951
fix #3417
fix #3447
Description
Full proposal in #4951
This PR enables tree-shaking for deterministic dynamic imports. The following are valid cases:
Idea credits to: