Skip to content

Commit

Permalink
fix(gatsby): handle cyclic chunkgroup children (#38052)
Browse files Browse the repository at this point in the history
(cherry picked from commit 272dacd)
  • Loading branch information
pieh committed May 5, 2023
1 parent 18a47da commit c4b4e0e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/gatsby/src/utils/webpack/get-ssr-chunk-hashes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ type ChunkGroup = webpack.Compilation["chunkGroups"][0]
function getHashes(
chunkGroup: ChunkGroup,
compilation: webpack.Compilation,
hashes: Array<string> = []
hashes: Array<string> = [],
visitedChunkGroups: Set<ChunkGroup> = new Set()
): Array<string> {
if (visitedChunkGroups.has(chunkGroup)) {
return hashes
}
visitedChunkGroups.add(chunkGroup)

for (const chunk of chunkGroup.chunks) {
if (!chunk.hash) {
throw new Error(
Expand All @@ -23,7 +29,7 @@ function getHashes(
)

if (isNotImportedByAsyncRequires) {
getHashes(childChunkGroup, compilation, hashes)
getHashes(childChunkGroup, compilation, hashes, visitedChunkGroups)
}
}

Expand Down

0 comments on commit c4b4e0e

Please sign in to comment.