From 25ceff5ec2ba708f3668bac7a4338549b09ad71c Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Wed, 13 Nov 2024 18:44:21 -0300 Subject: [PATCH] ChunkLoader: Avoid CSS debugging chunk --- src/debug/loadLazyChunks.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/debug/loadLazyChunks.ts b/src/debug/loadLazyChunks.ts index b7a8fbc6..6923d3a2 100644 --- a/src/debug/loadLazyChunks.ts +++ b/src/debug/loadLazyChunks.ts @@ -27,7 +27,12 @@ export async function loadLazyChunks() { const LazyChunkRegex = canonicalizeMatch(/(?:(?:Promise\.all\(\[)?(\i\.e\("?[^)]+?"?\)[^\]]*?)(?:\]\))?)\.then\(\i\.bind\(\i,"?([^)]+?)"?\)\)/g); + const foundCssDebuggingLoad = false; + async function searchAndLoadLazyChunks(factoryCode: string) { + // Workaround to avoid loading the CSS debugging chunk which turns the app pink + const hasCssDebuggingLoad = foundCssDebuggingLoad ? false : factoryCode.includes(".cssDebuggingEnabled&&"); + const lazyChunks = factoryCode.matchAll(LazyChunkRegex); const validChunkGroups = new Set<[chunkIds: number[], entryPoint: number]>(); @@ -43,6 +48,16 @@ export async function loadLazyChunks() { let invalidChunkGroup = false; for (const id of chunkIds) { + if (hasCssDebuggingLoad) { + if (chunkIds.length > 1) { + throw new Error("Found multiple chunks in factory that loads the CSS debugging chunk"); + } + + invalidChunks.add(id); + invalidChunkGroup = true; + break; + } + if (wreq.u(id) == null || wreq.u(id) === "undefined.js") continue; const isWorkerAsset = await fetch(wreq.p + wreq.u(id))