fix: do not append browserHash
on optimized deps during build
#13906
+4
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
).