-
-
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: do not append browserHash
on optimized deps during build
#13906
Conversation
Run & review this pull request in StackBlitz Codeflow. |
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.
Thanks for the PR! This sounds good to me, but the issue that prompted you to create this fix does not. Even if you have multiple entries, there should be a single build process and all deps must be found before optimizing. There shouldn't be any new deps discovered during build. Would you create a minimal reproduction and a bug report?
You're right but I'm having some trouble with creating a minimal reproduction. I'll file an issue if I'd make it! |
browserHash
on optmized deps during buildbrowserHash
on optimized deps during build
I found that it cannot be reproduced on newer vite versions. The last version where I can reproduce the "chunks with different hash" behavior is 4.2.3 and the first version that cannot reproduce is 4.3.3. However I cannot find the specific version that fixes this because my project cannot build on vite >= 4.3.0 <= 4.3.2 (it throws error in |
Found out the cause: I was calling
|
Description
Do not append
browserHash
on optmized deps during build. It is unnecessary and on some occasions would cause duplicate files bundled. For example, if we have multiple entries, vite will "discover and optimize new deps" and re-compute thebrowserHash
, so it could end up with both.vite/deps_build-dist/chunk-ABCDEFGH.js?v=11111111
and.vite/deps_build-dist/chunk-ABCDEFGH.js?v=22222222
in the final bundles. They have the same content but different ids, so rollup treats them as different modules.In fact, "entry" optmized deps have no
browserHash
suffix currently. Only chunks imported by "entry" optimized deps have that. For example,.vite/deps_build-dist/vue-demi.js
importsvite/deps_build-dist/chunk-ABCDEFGH.js?v=11111111
and.vite/deps_build-dist/vue.js
imports.vite/deps_build-dist/chunk-ABCDEFGH.js?v=22222222
.I think this happens when the user cannot correctly configure the entries for deps optimization, which is possible for complicated and highly customized projects.
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).