From 001c93672dc1630e4c0fad6a85ebe7d6ef2e3ed3 Mon Sep 17 00:00:00 2001 From: hiyuki <674883329@qq.com> Date: Wed, 20 Sep 2023 16:04:24 +0800 Subject: [PATCH] compute webpackTemplateSize --- packages/size-report/src/SizeReportPlugin.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/size-report/src/SizeReportPlugin.js b/packages/size-report/src/SizeReportPlugin.js index f388f4d215..4bb7ab735e 100644 --- a/packages/size-report/src/SizeReportPlugin.js +++ b/packages/size-report/src/SizeReportPlugin.js @@ -132,7 +132,11 @@ class SizeReportPlugin { function addModuleEntryGraph (moduleId, relation) { if (typeof moduleId !== 'number') return - if (!moduleEntryGraphMap.has(moduleId)) moduleEntryGraphMap.set(moduleId, { target: !!(relation && relation.target), children: new Set(), parents: new Set() }) + if (!moduleEntryGraphMap.has(moduleId)) moduleEntryGraphMap.set(moduleId, { + target: !!(relation && relation.target), + children: new Set(), + parents: new Set() + }) const value = moduleEntryGraphMap.get(moduleId) if (Array.isArray(relation.children)) { @@ -369,6 +373,7 @@ class SizeReportPlugin { } } } + divideEquallySize(sharedModulesGroupsSet, fillInfo.size) divideEquallySize(customGroupSharedModulesGroupsSet, fillInfo.size) } @@ -490,7 +495,8 @@ class SizeReportPlugin { totalSize: 0, staticSize: 0, chunkSize: 0, - copySize: 0 + copySize: 0, + webpackTemplateSize: 0 } function fillPackagesSizeInfo (packageName, size) { @@ -588,7 +594,6 @@ class SizeReportPlugin { packageName, size, modules: [] - // webpackTemplateSize: 0 } assetsSizeInfo.assets.push(chunkAssetInfo) fillPackagesSizeInfo(packageName, size) @@ -626,8 +631,7 @@ class SizeReportPlugin { chunkAssetInfo.modules.push(moduleData) size -= moduleSize } - - // chunkAssetInfo.webpackTemplateSize = size + sizeSummary.webpackTemplateSize += size // filter sourcemap } else if (!/\.m?js\.map$/i.test(name)) { // static copy assets such as project.config.json @@ -765,7 +769,7 @@ class SizeReportPlugin { assetsSizeInfo.assets.forEach((asset) => { if (asset.modules) sortAndFormat(asset.modules) }) - 'totalSize|staticSize|chunkSize|copySize'.split('|').forEach((key) => { + 'totalSize|staticSize|chunkSize|copySize|webpackTemplateSize'.split('|').forEach((key) => { sizeSummary[key] = formatSize(sizeSummary[key]) })