-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathto-comment-body.ts
More file actions
38 lines (29 loc) · 1.09 KB
/
to-comment-body.ts
File metadata and controls
38 lines (29 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import {
printAssetTablesByGroup,
printChunkModulesTable,
printTotalAssetTable
} from './print-markdown'
import type {WebpackStatsDiff, Sizes, ChunkSizes} from './types'
export function getIdentifierComment(key: string): string {
return `<!--- bundlestats-action-comment${key ? ` key:${key}` : ''} --->`
}
export function getCommentBody(
statsDiff: WebpackStatsDiff<Sizes>,
chunkModuleDiff: WebpackStatsDiff<ChunkSizes> | undefined,
title: string
): string {
return `
### Bundle Stats${title ? ` - ${title}` : ''}
Hey there, this message comes from a [GitHub action](https://github.com/github/webpack-bundlesize-compare-action) that helps you and reviewers to understand how these changes affect the size of this project's bundle.
As this PR is updated, I'll keep you updated on how the bundle size is impacted.
${printTotalAssetTable(statsDiff, chunkModuleDiff)}
${chunkModuleDiff ? `${printChunkModulesTable(chunkModuleDiff)}\n` : ''}
<details>
<summary>View detailed bundle breakdown</summary>
<div>
${printAssetTablesByGroup(statsDiff)}
</div>
</details>
${getIdentifierComment(title)}
`
}