Revert Prism LazyChunks
This commit is contained in:
parent
b140471e20
commit
bf7303208c
1 changed files with 4 additions and 16 deletions
|
|
@ -30,18 +30,6 @@ function getWebpackChunkMap() {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function promiseAllSettledBatched<T>(tasks: (() => Promise<T>)[], batchSize = 8): Promise<T[]> {
|
|
||||||
const results: T[] = [];
|
|
||||||
for (let i = 0; i < tasks.length; i += batchSize) {
|
|
||||||
const batch = tasks.slice(i, i + batchSize);
|
|
||||||
const settled = await Promise.allSettled(batch.map(t => t()));
|
|
||||||
for (const r of settled) {
|
|
||||||
if (r.status === "fulfilled") results.push(r.value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function loadLazyChunks() {
|
export async function loadLazyChunks() {
|
||||||
const LazyChunkLoaderLogger = new Logger("LazyChunkLoader");
|
const LazyChunkLoaderLogger = new Logger("LazyChunkLoader");
|
||||||
const queue = pLimit(50);
|
const queue = pLimit(50);
|
||||||
|
|
@ -73,7 +61,7 @@ export async function loadLazyChunks() {
|
||||||
|
|
||||||
const shouldForceDefer = false;
|
const shouldForceDefer = false;
|
||||||
|
|
||||||
await promiseAllSettledBatched(Array.from(lazyChunks).map(([, rawChunkIds, entryPoint]) => async () => {
|
await Promise.all(Array.from(lazyChunks).map(async ([, rawChunkIds, entryPoint]) => {
|
||||||
const chunkIds = rawChunkIds
|
const chunkIds = rawChunkIds
|
||||||
?.matchAll(Webpack.ChunkIdsRegex)
|
?.matchAll(Webpack.ChunkIdsRegex)
|
||||||
.map(m => {
|
.map(m => {
|
||||||
|
|
@ -124,9 +112,9 @@ export async function loadLazyChunks() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Loads all found valid chunk groups
|
// Loads all found valid chunk groups
|
||||||
await promiseAllSettledBatched(
|
await Promise.all(
|
||||||
Array.from(validChunkGroups)
|
Array.from(validChunkGroups)
|
||||||
.map(([chunkIds]) => () =>
|
.map(([chunkIds]) =>
|
||||||
Promise.all(chunkIds.map(id => wreq.e(id)))
|
Promise.all(chunkIds.map(id => wreq.e(id)))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
@ -202,7 +190,7 @@ export async function loadLazyChunks() {
|
||||||
return !(validChunks.has(id) || invalidChunks.has(id));
|
return !(validChunks.has(id) || invalidChunks.has(id));
|
||||||
});
|
});
|
||||||
|
|
||||||
await promiseAllSettledBatched(chunksLeft.map(id => async () => queue(async () => {
|
await Promise.all(chunksLeft.map(async id => queue(async () => {
|
||||||
const isWorkerAsset = await fetch(wreq.p + wreq.u(id))
|
const isWorkerAsset = await fetch(wreq.p + wreq.u(id))
|
||||||
.then(r => r.text())
|
.then(r => r.text())
|
||||||
.then(t => /importScripts\(|self\.postMessage/.test(t));
|
.then(t => /importScripts\(|self\.postMessage/.test(t));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue