Skip to content

fix: include preload dep membership in chunk hash when chunkImportMap is on - #23278

Closed
pooridev wants to merge 2 commits into
vitejs:mainfrom
pooridev:fix/chunk-importmap-preload-hash
Closed

pooridev wants to merge 2 commits into
vitejs:mainfrom
pooridev:fix/chunk-importmap-preload-hash

Conversation

@pooridev

@pooridev pooridev commented Aug 16, 2026 •

Copy link
Copy Markdown

Summary

  • With build.chunkImportMap, vite:build-import-analysis substitutes __VITE_PRELOAD__ in generateBundle, after Rollup/Rolldown has already hashed the chunk.
  • A graph change that only alters the injected __vite__mapDeps membership therefore reused a content-hashed filename for different bytes, which breaks Cache-Control: immutable.
  • Record each chunk's import graph during renderChunk and feed the transitive membership into augmentChunkHash, using stable chunk names so CSS-content-only changes still keep the importer filename (see fix(build): map CSS chunks in chunk import maps (fix #22946) #22947).

Fixes #23225

Test plan

  • Added a chunk-importmap playground build test that adds a shared extra dep to one dynamic importer and asserts the entry filename moves
  • pnpm test-unit
  • pnpm test-serve chunk-importmap / pnpm test-build chunk-importmap if browsers are available

pooridev and others added 2 commits August 17, 2026 02:21
… is on

generateBundle substitutes `__VITE_PRELOAD__` after hashing, so a graph change that only alters `__vite__mapDeps` reused a content-hashed filename for different bytes.

Co-authored-by: Cursor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

build.chunkImportMap reuses a content-hashed file name for different bytes

1 participant