Skip to content

Commit 754f68b

Browse files
chore: Adding other asset sizes to report
1 parent 4a12f09 commit 754f68b

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

tools/scripts/diff-sizes.mjs

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,17 @@ function generateDiffRows (assetSizes, buildType) {
124124
}).join('\n')
125125
}
126126

127+
function generateOtherDiffRows (assetSizes, buildType, assetGroup) {
128+
const targetBuildTypeSizes = assetSizes[buildType]
129+
return Object.keys(targetBuildTypeSizes[assetGroup])
130+
.filter(assetName => assetName.indexOf('nr-loader') === -1)
131+
.map(assetName => {
132+
const buildSizes = targetBuildTypeSizes[assetGroup][assetName]
133+
const buildSizesResult = `${filesize(buildSizes.fileSize)} / ${filesize(buildSizes.gzipSize)} (gzip)`
134+
return `|${assetName}|${buildSizesResult}|`
135+
}).join('\n')
136+
}
137+
127138
async function writeDiff (assetSizes) {
128139
await fs.ensureDir(config.out)
129140
await fs.writeJson(path.join(config.out, 'size_report.json'), assetSizes, { spaces: 2 })
@@ -136,7 +147,39 @@ ${generateDiffRows(assetSizes, 'standard')}
136147
${generateDiffRows(assetSizes, 'polyfills')}
137148
${generateDiffRows(assetSizes, 'worker')}
138149
139-
<sub>This report only accounts for the minified loaders. Un-minified and async-loaded assets are not included.</sub>
150+
<details>
151+
<summary>Other Standard Assets</summary>
152+
153+
## Released Assets
154+
155+
| Asset Name | Asset Size |
156+
|------------|------------|
157+
${generateOtherDiffRows(assetSizes, 'standard', 'releaseStats')}
158+
159+
## Built Assets
160+
161+
| Asset Name | Asset Size |
162+
|------------|------------|
163+
${generateOtherDiffRows(assetSizes, 'standard', 'buildStats')}
164+
165+
</details>
166+
167+
<details>
168+
<summary>Other Polyfills Assets</summary>
169+
170+
## Released Assets
171+
172+
| Asset Name | Asset Size |
173+
|------------|------------|
174+
${generateOtherDiffRows(assetSizes, 'polyfills', 'releaseStats')}
175+
176+
## Built Assets
177+
178+
| Asset Name | Asset Size |
179+
|------------|------------|
180+
${generateOtherDiffRows(assetSizes, 'polyfills', 'buildStats')}
181+
182+
</details>
140183
`
141184
)
142185
}

0 commit comments

Comments
 (0)