diff --git a/webpack-subresource-integrity/src/manifest.ts b/webpack-subresource-integrity/src/manifest.ts index 5bc5cea..9a0c60d 100644 --- a/webpack-subresource-integrity/src/manifest.ts +++ b/webpack-subresource-integrity/src/manifest.ts @@ -17,7 +17,7 @@ import { allChunksInChunkIterable, allChunksInPrimaryChunkIterable, sriHashVariableReference, - wmfSharedChunk, + checkForFiles, } from "./util"; import { createDAGfromGraph } from "./scc"; import { RuntimeModule, Template, Chunk } from "webpack"; @@ -53,13 +53,13 @@ function buildTopologicallySortedChunkGraph( // Chunks should have *all* chunks, not simply entry chunks for (const vertex of chunks) { - if (wmfSharedChunk(vertex) || addIfNotExist(vertices, vertex)) { + if (checkForFiles(vertex) || addIfNotExist(vertices, vertex)) { continue; } edges.set(vertex, new Set()); for (const childChunk of allChunksInChunkIterable(vertex)) { - if (!wmfSharedChunk(childChunk)) { + if (!checkForFiles(childChunk)) { edges.get(vertex)?.add(childChunk); } } diff --git a/webpack-subresource-integrity/src/util.ts b/webpack-subresource-integrity/src/util.ts index 3f3ff22..943271c 100644 --- a/webpack-subresource-integrity/src/util.ts +++ b/webpack-subresource-integrity/src/util.ts @@ -87,10 +87,8 @@ export function addIfNotExist(set: Set, item: T): boolean { set.add(item); return false; } -export function wmfSharedChunk(chunk: Chunk): boolean { - return Boolean( - chunk.chunkReason?.includes("split chunk (cache group: default)") - ); +export function checkForFiles(chunk: Chunk): boolean { + return chunk.files?.size === 0; } export function findChunks(chunk: Chunk): Set { @@ -104,7 +102,7 @@ export function findChunks(chunk: Chunk): Set { group.childrenIterable.forEach(recurseGroup); } - if (wmfSharedChunk(childChunk) || addIfNotExist(allChunks, childChunk)) { + if (checkForFiles(childChunk) || addIfNotExist(allChunks, childChunk)) { return; } Array.from(childChunk.groupsIterable).forEach(recurseGroup);