fix: do not append browserHash on optimized deps during build#13906
fix: do not append browserHash on optimized deps during build#13906patak-cat merged 2 commits intovitejs:mainfrom
browserHash on optimized deps during build#13906Conversation
|
|
patak-cat
left a comment
There was a problem hiding this comment.
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
browserHashon 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=11111111and.vite/deps_build-dist/chunk-ABCDEFGH.js?v=22222222in 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
browserHashsuffix currently. Only chunks imported by "entry" optimized deps have that. For example,.vite/deps_build-dist/vue-demi.jsimportsvite/deps_build-dist/chunk-ABCDEFGH.js?v=11111111and.vite/deps_build-dist/vue.jsimports.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).