Repository navigation
Conversation
… 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]>
|
I ran into #23225 with 1. A shared chunk that becomes CSS-only still keeps its importers' names The fixture:
Removing the
Both edits happen after hashing. With this PR's logic, A browser holding the old What closed it for me: also put into the hash each statically or dynamically imported chunk's "is pure CSS" fact. That fact is its rendered code being empty with only styles imported, which is the condition css-post uses. With that addition, all four graph changes I tried showed 0 collisions:
A content-only change still renamed only the changed chunk. 2. Duplicate chunk names (from reading the source, not reproduced) rolldown's chunk-import-map plugin keys the first same-named non-facade chunk, in render order, by its name, and later duplicates by their smallest module id ( Results per graph change (same-name/different-bytes files, base vs variant in the same folder): |
Description
With
build.chunkImportMap, Rolldown finalizes chunk hashes beforevite:build-import-analysisreplaces dynamic import preload markers ingenerateBundle. A change to a dynamic import static dependency closure can therefore change the emitted__vite__mapDepsarrays without changing the content-hashed filename.Record the rendered chunk graph and add each dynamic import exact preload dependency signature to
augmentChunkHash. The signature uses the same facade, unique chunk name, and first module identities as the Rolldown chunk import map. It also accounts for extracted CSS membership and avoids pulling nested dynamic imports into the parent hash.This is a rebased continuation of #23278. The original implementation commit retains @pooridev authorship. The failing playground test from that PR used an export that the bundler removed as unused, so this branch replaces it with a unit regression matching the graph from the issue reproduction.
Fixes #23225
Tests
pnpm buildpnpm test-unit(977 passed, 3 skipped)pnpm test-build chunk-importmap(13 passed)antur84/vite-chunkimportmap-stale-hash-reproagainst the locally built package (0 same-name/different-bytes collisions)