-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
fix: chunk split for dynamic import dep #6318
Conversation
9386059
to
0431163
Compare
will this fix #6250? |
Yes,it is a general solution for the scene with dynamic import. |
@QiroNT could you test this PR for us? |
I don't particularly like this implementation since it still kinds of combining modules imported from the same package, not ideal for stuffs like localization files. Maybe should have an option to either combine modules by dynamic entry, or combine by package name. Could be configured by matching entries like how the BTW I think that localization files being split into two files is not beneficial, maybe also a option to disable this optimization (include packages in source chunk) for an entry? or just disable for very small files (also could be the default to the config above), but idk if it could fit inside vite's build cycle. |
Why do we need to do any special vendor chunking? The feature was originally added in f6b58a0#diff-aa53520bfd53e6c24220c44494457cc66370fd2bee513c15f9be7eb537a363e7. I can only guess at why it was added as there was no explanation provided at the time. I guess the idea is that the vendor chunk changes less frequently and will be better cached? But it ends up loading lots of code that's unnecessary for a page, adds complication, creates more chunks, and causes issues if libraries are used from multiple places so I find it quite hard to believe it's an overall win. Personally, I'd really love to just remove it, or at least make it optional and off by default. |
I understand.This solution separates application code and dependent code, improves the cache hit rate, and increases the number of chunks. Maybe you don’t like this way too much, but prefer to split the package size by package name.Such as: {
'markdown-it': ['markdown-it'],
'echarts': ['echarts'],
'react': ['react', 'react-dom']
} Then the packages in the value will be packaged together.right? |
@QiroNT @benmccann However, currently vite's chunk split is implemented through rollup's manualChunks. If vite is not handled by default but a new chunk split configuration is created, it will conflict with |
Actually it's the opposite, look closely at locales from |
Thought for the past few hours, the whole vendor thing should be rewritten with this issue in mind. Probably doing an analyze to choose whether multiple entries from a dependency should be packaged together or not, I'll hopefully open a discussion about this proposal later, but god that's a lot more to consider than I've ever thought it would be. |
Description
For a dynamic import module,the application code and the third-party dep code will be seperated.In the meanwhile, each async-vendor will be divided in terms of dynamic import entry, instead of all being packaged into a single file, so huge async vendor can be avoided.
See details in #6289.
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).