баги
This commit is contained in:
@@ -80,7 +80,7 @@ const ENTRY_OUTPUT_PATHS = Object.freeze({
|
||||
runtime: 'dist/react/shared/runtime.js'
|
||||
});
|
||||
|
||||
function chunkReachability() {
|
||||
function chunkReachability(includeDynamic = true) {
|
||||
const reach = new Map();
|
||||
for (const [entryName, entryPath] of Object.entries(ENTRY_OUTPUT_PATHS)) {
|
||||
const stack = [entryPath];
|
||||
@@ -90,6 +90,7 @@ function chunkReachability() {
|
||||
if (seen.has(path) || !outputs[path]) continue;
|
||||
seen.add(path);
|
||||
for (const imported of outputs[path].imports || []) {
|
||||
if (!includeDynamic && imported.kind === 'dynamic-import') continue;
|
||||
stack.push(imported.path);
|
||||
}
|
||||
}
|
||||
@@ -102,6 +103,7 @@ function chunkReachability() {
|
||||
}
|
||||
|
||||
const reach = chunkReachability();
|
||||
const coldReach = chunkReachability(false);
|
||||
const adminLazyChunkPaths = sharedChunkPaths.filter(path => {
|
||||
const entries = reach.get(path);
|
||||
return entries !== undefined && entries.size > 0 && [...entries].every(name => name === 'admin');
|
||||
@@ -128,7 +130,12 @@ for (const [name, path, limit, coldLimit] of [
|
||||
]) {
|
||||
const rawBytes = outputBytes(path);
|
||||
const gzipBytes = await gzipSize(path);
|
||||
const coldLoadGzipBytes = gzipBytes + sharedChunkGzipBytes;
|
||||
// Холодная загрузка включает только статические зависимости этой страницы.
|
||||
// Общий пул содержит также модули других кабинетов и не загружается целиком.
|
||||
const entryName = Object.keys(ENTRY_OUTPUT_PATHS).find(name => ENTRY_OUTPUT_PATHS[name] === path);
|
||||
const coldChunkPaths = sharedChunkPaths.filter(chunk => coldReach.get(chunk)?.has(entryName));
|
||||
const coldLoadGzipBytes = gzipBytes + (await Promise.all(coldChunkPaths.map(gzipSize)))
|
||||
.reduce((total, bytes) => total + bytes, 0);
|
||||
entryReports.push({ name, path, rawBytes, gzipBytes, coldLoadGzipBytes, limit, coldLimit });
|
||||
|
||||
if (gzipBytes > limit) {
|
||||
|
||||
Reference in New Issue
Block a user