-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
refactor: rewrite vendor chunk to handle redirect exports #6347
Conversation
@benmccann could you help me test this on that SvelteKit issue? |
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.
Code looks okay
Is it possible to add a test?
|
||
/** | ||
* Build only. Analyze which modules are used by entries and | ||
* generate manualChunks config to split those files to vendor. |
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.
this could use an explanation as to what the algorithm is and why this is being used instead of Rollup's default behavior
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.
added a simple explanation, Is it okay?
I didn't test it, but to be very blunt, my first reaction is that this is insanity. Rollup has built-in code splitting, so why build some very complicated thing to replace it? At the very least there needs to be some explanation of what this is doing and what its benefits are. My initial reaction is that I would be much happier to just rip it all out and not deal with the added complexity and issues caused by this feature, but maybe I would feel differently given some explanation |
added tests, but the tests are very barebone. I have no idea what edge cases to cover since I just ignored exports in |
Started a discussion about this, we should talk about it with more users to decide whether we implement it or just get rid of vendor chunk. |
Description
fix #3731
I decided to not open a discussion, but this implementation should be more tested. I have no idea if it actually solved that kind of issue, but tested it solved that particular issue.
Before:
After:
And yes, performance is not great on large size projects, but I only have a medium size project, and here is the result:
Additional context
The real problem is the current implementation of vendor doesn't handle redirect exports, dependencies like
framer-motion
provided a combined export kinds of like this:and the import looks like:
In the current implementation of vendor, the file
index.js
is considered to be a vendor file, so every import toindex.js
is put inside vendor chunk.But rollup handles this situation just fine, when vendor chunk is disabled, rollup splits dynamic import to
bar
seperately.This implementation scans all redirect exports. Instead of marking
index.js
as a vendor file, this pr detectsfoo
import frommain.js
and only marksfoo.js
as a vendor file, fixes the issue.#6318 probably should be based on this implementation.
Side note: this implementation still allows setting
manualChunks
toundefined
to disable vendor chunk.What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).