Skip to content

Commit 6092362

Browse files
authored
fix: getMetadataForChunk infinitely loops when parsing build output (#67)
1 parent 232b90f commit 6092362

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/manifestParser/manifestParser.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default abstract class ManifestParser<
2626
protected inputManifest: Manifest;
2727
protected webAccessibleScriptsFilter: ReturnType<typeof createFilter>;
2828
protected viteDevServer: ViteDevServer | undefined;
29+
protected parsedMetaDataChunkIds = new Set<string>();
2930

3031
constructor(
3132
protected pluginOptions: ViteWebExtensionOptions,
@@ -260,14 +261,24 @@ export default abstract class ManifestParser<
260261
metadata: {
261262
css: Set<string>;
262263
assets: Set<string>;
263-
} = {
264-
css: new Set<string>(),
265-
assets: new Set<string>(),
266-
}
264+
} | null = null
267265
): {
268266
css: Set<string>;
269267
assets: Set<string>;
270268
} {
269+
if (metadata === null) {
270+
this.parsedMetaDataChunkIds.clear();
271+
272+
metadata = {
273+
css: new Set<string>(),
274+
assets: new Set<string>(),
275+
};
276+
}
277+
278+
if (this.parsedMetaDataChunkIds.has(chunkId)) {
279+
return metadata;
280+
}
281+
271282
const chunkInfo = getChunkInfoFromBundle(bundle, chunkId);
272283
if (!chunkInfo) {
273284
return metadata;
@@ -283,6 +294,8 @@ export default abstract class ManifestParser<
283294
metadata.assets
284295
);
285296

297+
this.parsedMetaDataChunkIds.add(chunkId);
298+
286299
chunkInfo.imports.forEach(
287300
(chunkId) =>
288301
(metadata = this.getMetadataforChunk(chunkId, bundle, true, metadata))

0 commit comments

Comments
 (0)