Skip to content

Commit

Permalink
fix graph update
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Mar 6, 2024
1 parent 415cd74 commit 0e1ef37
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions packages/next/src/build/webpack/plugins/merge-css-chunks-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,29 @@ export class MergeCssChunksPlugin {
*/
function updateInfoForMerging(removedChunk: Chunk, newChunk: Chunk) {
const info = cssChunkInfo.get(removedChunk)!
const newInfo = cssChunkInfo.get(newChunk)!
for (const [entrypoint, entryInfo] of info.entrypoints) {
if (entryInfo.prev === newChunk) {
const prevInfo = cssChunkInfo.get(entryInfo.prev)!
prevInfo.entrypoints.get(entrypoint)!.next = entryInfo.next
} else if (entryInfo.prev) {
const prevInfo = cssChunkInfo.get(entryInfo.prev)!
const prev = entryInfo.prev !== newChunk ? entryInfo.prev : null
const next = entryInfo.next !== newChunk ? entryInfo.next : null
if (prev) {
const prevInfo = cssChunkInfo.get(prev)!
prevInfo.entrypoints.get(entrypoint)!.next = newChunk
}
if (entryInfo.next) {
const nextInfo = cssChunkInfo.get(entryInfo.next)!
if (next) {
const nextInfo = cssChunkInfo.get(next)!
nextInfo.entrypoints.get(entrypoint)!.prev = newChunk
}
cssChunksForChunkGroup.get(entrypoint)!.delete(removedChunk)
let newEntryInfo = newInfo.entrypoints.get(entrypoint)
if (newEntryInfo !== undefined) {
newEntryInfo.prev =
newEntryInfo.prev === removedChunk ? prev : newEntryInfo.prev
newEntryInfo.next =
newEntryInfo.next === removedChunk ? next : newEntryInfo.next
} else {
newEntryInfo = { prev, next }
newInfo.entrypoints.set(entrypoint, newEntryInfo)
}
}
cssChunkInfo.delete(removedChunk)
return info
Expand Down

0 comments on commit 0e1ef37

Please sign in to comment.