-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: treeshake dynamic import chained member expression #5898
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: treeshake dynamic import chained member expression #5898
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
77b7368
to
b114268
Compare
b114268
to
062782a
Compare
9754604
to
75d2bc3
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.
While this is kind of a special case, it looks good to me. Technically at this point, we do have a logic that can track inclusions of object properties at this point. However, using for this purpose would require a bigger refactoring as getDeterministicImportedNames
is only run once, so it would instead need to be triggered somehow from the parameter variables. Maybe we will implement it at some point. Until then, good work!
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5898 +/- ##
==========================================
- Coverage 98.56% 98.55% -0.02%
==========================================
Files 270 270
Lines 8685 8692 +7
Branches 1487 1488 +1
==========================================
+ Hits 8560 8566 +6
- Misses 92 93 +1
Partials 33 33 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…-treeshake-member-expression
Head branch was pushed to by a user without write access
7dde172
to
00fe330
Compare
Pull Request is not mergeable
This PR has been released as part of rollup@4.40.0. You can test it via |
Amazing! It's an honor to be able to contribute to Rollup—thank you for all your work. |
This PR contains:
Are tests included?
Here's the test-only PR demonstrating that it fails without this change:
privatenumber#2
Breaking Changes?
List any relevant issue numbers:
Description
This PR adds support for tree-shaking dynamic imports when the following pattern is observed:
I didn't look into this deeply, but in a Vite library build, one of my libraries generates this syntax to import from a chunk. When a Vite app (which uses Rollup under the hood) consumes the library, the unused exports from the chunk isn’t tree-shaken.
I'm not sure if this is the root cause, but I thought this change would improve tree-shaking regardless at minimal cost and was worth adding.