refactor: use rollup hashing when emitting assets #10878
Merged
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.
Done: This PR depends on rollup/rollup#4712, Rollup 3.3 includes it and we updated it in a separate PR.
Description
Rollup 3 has a new hashing algorithm that fixes the issues we had when emitting assets before:
We currently do our own hashing and deduplication, see:
This is the first PR in a series to try to move back some of the responsibilities to Rollup. This should help to be compatible with external plugins using
emitFile
or config settings likeassetFileNames
. There was actually a faulty test in workers that was not letting us see a bug for workers andassetFileNames
.Ideally, we should try to move to also use
import.meta.ROLLUP_FILE_URL_referenceId
instead of our__VITE_ASSET__hash__
. I still don't know if it is feasible though because we still need our own scheme for references in CSS. This PR already moves from our own hash to usingreferenceId
though, and future PRs may move us closer to at least using rollup's scheme in JS files.What is the purpose of this pull request?