Skip to content

Commit

Permalink
compute webpackTemplateSize
Browse files Browse the repository at this point in the history
  • Loading branch information
hiyuki committed Sep 20, 2023
1 parent 9069d7f commit 001c936
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/size-report/src/SizeReportPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -369,6 +373,7 @@ class SizeReportPlugin {
}
}
}

divideEquallySize(sharedModulesGroupsSet, fillInfo.size)
divideEquallySize(customGroupSharedModulesGroupsSet, fillInfo.size)
}
Expand Down Expand Up @@ -490,7 +495,8 @@ class SizeReportPlugin {
totalSize: 0,
staticSize: 0,
chunkSize: 0,
copySize: 0
copySize: 0,
webpackTemplateSize: 0
}

function fillPackagesSizeInfo (packageName, size) {
Expand Down Expand Up @@ -588,7 +594,6 @@ class SizeReportPlugin {
packageName,
size,
modules: []
// webpackTemplateSize: 0
}
assetsSizeInfo.assets.push(chunkAssetInfo)
fillPackagesSizeInfo(packageName, size)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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])
})

Expand Down

0 comments on commit 001c936

Please sign in to comment.