Turbopack: Fix near-duplicate chunk creation in production builds
Add absorption pass to the production chunking merge algorithm. After the
main merge loop, small remaining candidates that couldn't find a merge
partner are now checked against existing heap chunks. If a small item's
bitmap overlaps sufficiently with a heap chunk's bitmap (duplication cost
exceeds extra download cost), the small item is absorbed into that chunk
rather than creating a near-duplicate.
This fixes cases where a tiny module (e.g. 360B) with bitmap {0,1,2}
would create a separate near-identical chunk instead of being absorbed
into a large chunk (e.g. 60KB) with bitmap {0,1}.
Also adds merge.rs with a pure Vc-free extraction of the merge algorithm
and 7 unit tests covering the near-duplicate scenarios.
Showing
This diff is collapsed.
Please
register
or
sign in
to comment