fix: invalidate chunk hashes on renderBuiltUrl change (fix #13996) - #21433
Closed
hartz89 wants to merge 1 commit into
Closed
fix: invalidate chunk hashes on renderBuiltUrl change (fix #13996) #21433hartz89 wants to merge 1 commit into
hartz89 wants to merge 1 commit into
Conversation
7 tasks
hartz89
force-pushed
the
render-built-url-fix-hashing
branch
from
March 19, 2026 21:15
9926d74 to
d7f5f21
Compare
hartz89
marked this pull request as ready for review
March 19, 2026 21:38
hartz89
force-pushed
the
render-built-url-fix-hashing
branch
from
March 19, 2026 21:42
d7f5f21 to
d04500f
Compare
hartz89
force-pushed
the
render-built-url-fix-hashing
branch
2 times, most recently
from
April 20, 2026 01:29
5a939b1 to
b4b9d25
Compare
JS chunks use the `augmentChunkHash` hook to mix the stringified `renderBuiltUrl` function into each chunk's hash. CSS assets inject a short hash of the function into CSS content during `finalizeCss` (stripped before emit) to influence the content-based filename hash. Note: hashing uses `Function.prototype.toString()`, so only the function source text is captured. Closed-over variables (e.g. `process.env`) are not visible — changing external state without changing the function body will not produce new filenames.
hartz89
force-pushed
the
render-built-url-fix-hashing
branch
from
April 20, 2026 01:38
b4b9d25 to
cec94cd
Compare
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #13996. When
experimental.renderBuiltUrlchanges, JS and CSS chunk hashes now invalidate properly.augmentChunkHashhook to include the stringifiedrenderBuiltUrlfunction in hash computationrenderBuiltUrlinto CSS content viafinalizeCss(before the asset filename hash is computed), then strips it ingenerateBundleso it doesn't appear in shipped CSSKnown limitation: Hash computation uses
Function.prototype.toString(), so only the function's source text is captured. IfrenderBuiltUrlcloses over external state (e.g.process.env.CDN_URL) without referencing it in the function body, changing that value won't produce new filenames — the function body itself must change. This is noted in a code comment and matches the general contract ofaugmentChunkHash.Testing
build.spec.tsverifying that differentrenderBuiltUrlfunctions produce different output hashes for both JS chunks and CSS assetsplayground/render-built-urlintegration test running two real builds with differentrenderBuiltUrlconfigs and asserting filenames differ for both JS chunks and CSS assetsrenderBuiltUrlfor CDN asset serving — confirmed all 19 JS chunks and 3 CSS assets received new hashes after modifying the function