Skip to content

Commit 17b6ac5

Browse files
authored
Merge pull request #160 from github/improve-markdown-comment
Improve Markdown comment
2 parents bfae2cc + cc6cf8d commit 17b6ac5

File tree

7 files changed

+213
-82
lines changed

7 files changed

+213
-82
lines changed

__tests__/__mocks__/new-stats-with-chunks.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,11 @@
255255
},
256256
{
257257
"size": 2790,
258-
"name": "./src/client/routes.tsx"
258+
"name": "./src/client/this/file/has/a/long/name/so-that-it-will-hopefully-wrap.tsx"
259259
},
260260
{
261261
"size": 1067,
262-
"name": "./src/client/render-memex.tsx"
262+
"name": "./src/client/this-is-another-file-with-a-long-name-to-test-the-table-sizing.tsx"
263263
},
264264
{
265265
"size": 878,
@@ -330,12 +330,12 @@
330330
"name": "./src/client/services/github-enabled-features-service.ts"
331331
},
332332
{
333-
"size": 11949,
334-
"name": "./src/client/app.tsx"
333+
"size": 10,
334+
"name": "./src/client/this-file-is-much-smaller.tsx"
335335
},
336336
{
337-
"size": 1379,
338-
"name": "./src/client/helpers/initial-state.ts"
337+
"size": 13318,
338+
"name": "./src/client/helpers/this-file-is-much-larger.ts"
339339
},
340340
{
341341
"size": 103,

__tests__/__mocks__/old-stats-with-chunks.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,11 @@
331331
},
332332
{
333333
"size": 11949,
334-
"name": "./src/client/app.tsx"
334+
"name": "./src/client/this-file-is-much-smaller.tsx"
335335
},
336336
{
337337
"size": 1379,
338-
"name": "./src/client/helpers/initial-state.ts"
338+
"name": "./src/client/helpers/this-file-is-much-larger.ts"
339339
},
340340
{
341341
"size": 103,

__tests__/main.test.ts

Lines changed: 74 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ No assets were added
2828
2929
Asset | Type | File Size | % Changed
3030
----- | ---- | --------- | ---------
31-
296.chunk.js | bundled<br />gzip | 124.57 KB -> 0 Bytes (-124.57 KB)<br />35.05 KB -> 0 Bytes | -100%
32-
288.chunk.js | bundled<br />gzip | 57.24 KB -> 0 Bytes (-57.24 KB)<br />16.33 KB -> 0 Bytes | -100%
33-
920.chunk.js | bundled<br />gzip | 54.98 KB -> 0 Bytes (-54.98 KB)<br />17.08 KB -> 0 Bytes | -100%
34-
912.chunk.js | bundled<br />gzip | 44.37 KB -> 0 Bytes (-44.37 KB)<br />14.31 KB -> 0 Bytes | -100%
35-
699.chunk.js | bundled<br />gzip | 26.39 KB -> 0 Bytes (-26.39 KB)<br />6.14 KB -> 0 Bytes | -100%
31+
296.chunk.js | bundled<br />gzip | 124.57 KB -> 0 B (-124.57 KB)<br />35.05 KB -> 0 B | -100%
32+
288.chunk.js | bundled<br />gzip | 57.24 KB -> 0 B (-57.24 KB)<br />16.33 KB -> 0 B | -100%
33+
920.chunk.js | bundled<br />gzip | 54.98 KB -> 0 B (-54.98 KB)<br />17.08 KB -> 0 B | -100%
34+
912.chunk.js | bundled<br />gzip | 44.37 KB -> 0 B (-44.37 KB)<br />14.31 KB -> 0 B | -100%
35+
699.chunk.js | bundled<br />gzip | 26.39 KB -> 0 B (-26.39 KB)<br />6.14 KB -> 0 B | -100%
3636
3737
**Bigger**
3838
@@ -44,7 +44,7 @@ app.bundle.js | bundled<br />gzip | 1.04 MB -> 1.29 MB (+254.35 KB)<br />297.38
4444
4545
Asset | Type | File Size | % Changed
4646
----- | ---- | --------- | ---------
47-
manifest.json | bundled<br />gzip | 551 Bytes -> 91 Bytes (-460 Bytes)<br />151 Bytes -> N/A | -83.48%
47+
manifest.json | bundled<br />gzip | 551 B -> 91 B (-460 B)<br />151 B -> N/A | -83.48%
4848
4949
**Unchanged**
5050
@@ -66,11 +66,11 @@ Files count | Type | Total bundle size | % Changed
6666
6767
Asset | Type | File Size | % Changed
6868
----- | ---- | --------- | ---------
69-
296.chunk.js | bundled<br />gzip | 0 Bytes -> 124.57 KB (+124.57 KB)<br />0 Bytes -> 35.05 KB | -
70-
288.chunk.js | bundled<br />gzip | 0 Bytes -> 57.24 KB (+57.24 KB)<br />0 Bytes -> 16.33 KB | -
71-
920.chunk.js | bundled<br />gzip | 0 Bytes -> 54.98 KB (+54.98 KB)<br />0 Bytes -> 17.08 KB | -
72-
912.chunk.js | bundled<br />gzip | 0 Bytes -> 44.37 KB (+44.37 KB)<br />0 Bytes -> 14.31 KB | -
73-
699.chunk.js | bundled<br />gzip | 0 Bytes -> 26.39 KB (+26.39 KB)<br />0 Bytes -> 6.14 KB | -
69+
296.chunk.js | bundled<br />gzip | 0 B -> 124.57 KB (+124.57 KB)<br />0 B -> 35.05 KB | -
70+
288.chunk.js | bundled<br />gzip | 0 B -> 57.24 KB (+57.24 KB)<br />0 B -> 16.33 KB | -
71+
920.chunk.js | bundled<br />gzip | 0 B -> 54.98 KB (+54.98 KB)<br />0 B -> 17.08 KB | -
72+
912.chunk.js | bundled<br />gzip | 0 B -> 44.37 KB (+44.37 KB)<br />0 B -> 14.31 KB | -
73+
699.chunk.js | bundled<br />gzip | 0 B -> 26.39 KB (+26.39 KB)<br />0 B -> 6.14 KB | -
7474
7575
**Removed**
7676
@@ -80,7 +80,7 @@ No assets were removed
8080
8181
Asset | Type | File Size | % Changed
8282
----- | ---- | --------- | ---------
83-
manifest.json | bundled<br />gzip | 91 Bytes -> 551 Bytes (+460 Bytes)<br />N/A -> 151 Bytes | +505.49%
83+
manifest.json | bundled<br />gzip | 91 B -> 551 B (+460 B)<br />N/A -> 151 B | +505.49%
8484
8585
**Smaller**
8686
@@ -130,7 +130,7 @@ app.bundle.js | bundled<br />gzip | 1.04 MB<br />297.38 KB | 0%
130130
920.chunk.js | bundled<br />gzip | 54.98 KB<br />17.08 KB | 0%
131131
912.chunk.js | bundled<br />gzip | 44.37 KB<br />14.31 KB | 0%
132132
699.chunk.js | bundled<br />gzip | 26.39 KB<br />6.14 KB | 0%
133-
manifest.json | bundled<br />gzip | 551 Bytes<br />151 Bytes | 0%`)
133+
manifest.json | bundled<br />gzip | 551 B<br />151 B | 0%`)
134134
})
135135

136136
test('computes the correct module diff information', () => {
@@ -139,42 +139,34 @@ test('computes the correct module diff information', () => {
139139
require('./__mocks__/new-stats-with-chunks.json')
140140
)
141141

142-
expect(statsDiff?.added).toEqual([
143-
{
144-
name: './src/client/this-file-was-added.ts',
145-
diff: 1496,
146-
diffPercentage: Infinity,
147-
new: {size: 1496, gzipSize: NaN},
148-
old: {size: 0, gzipSize: 0}
149-
}
150-
] as AssetDiff[])
151-
expect(statsDiff?.bigger).toEqual([
152-
{
153-
name: './src/client/this-file-grew-larger.tsx',
154-
diff: 200,
155-
diffPercentage: 35.58719,
156-
new: {size: 762, gzipSize: NaN},
157-
old: {size: 562, gzipSize: NaN}
158-
}
159-
] as AssetDiff[])
160-
expect(statsDiff?.smaller).toEqual([
161-
{
162-
name: './src/client/helpers/this-file-grew-smaller.ts',
163-
diff: -200,
164-
diffPercentage: -7.94281,
165-
new: {size: 2318, gzipSize: NaN},
166-
old: {size: 2518, gzipSize: NaN}
167-
}
168-
] as AssetDiff[])
169-
expect(statsDiff?.removed).toEqual([
170-
{
171-
name: './src/client/this-file-will-be-deleted.ts',
172-
diff: -1496,
173-
diffPercentage: -100,
174-
new: {size: 0, gzipSize: 0},
175-
old: {size: 1496, gzipSize: NaN}
176-
}
177-
] as AssetDiff[])
142+
expect(statsDiff?.added).toContainEqual({
143+
name: './src/client/this-file-was-added.ts',
144+
diff: 1496,
145+
diffPercentage: Infinity,
146+
new: {size: 1496, gzipSize: NaN},
147+
old: {size: 0, gzipSize: 0}
148+
} as AssetDiff)
149+
expect(statsDiff?.bigger).toContainEqual({
150+
name: './src/client/this-file-grew-larger.tsx',
151+
diff: 200,
152+
diffPercentage: 35.58719,
153+
new: {size: 762, gzipSize: NaN},
154+
old: {size: 562, gzipSize: NaN}
155+
} as AssetDiff)
156+
expect(statsDiff?.smaller).toContainEqual({
157+
name: './src/client/helpers/this-file-grew-smaller.ts',
158+
diff: -200,
159+
diffPercentage: -7.94281,
160+
new: {size: 2318, gzipSize: NaN},
161+
old: {size: 2518, gzipSize: NaN}
162+
} as AssetDiff)
163+
expect(statsDiff?.removed).toContainEqual({
164+
name: './src/client/this-file-will-be-deleted.ts',
165+
diff: -1496,
166+
diffPercentage: -100,
167+
new: {size: 0, gzipSize: 0},
168+
old: {size: 1496, gzipSize: NaN}
169+
} as AssetDiff)
178170
expect(statsDiff?.total.new).toEqual(statsDiff?.total.old)
179171
expect(statsDiff?.total.diff).toEqual(0)
180172
expect(statsDiff?.total.diffPercentage).toEqual(0)
@@ -186,15 +178,42 @@ test('displays module information when files are added/removed/changed', () => {
186178
require('./__mocks__/new-stats-with-chunks.json')
187179
)
188180

181+
console.log(printChunkModulesTable(statsDiff))
182+
189183
expect(printChunkModulesTable(statsDiff)).toEqual(`
190184
**Changeset**
191185
192-
File | Size | % Changed
193-
---- | ---- | ---------
194-
./src/client/this-file-was-added.ts | 0 Bytes -> 1.46 KB (+1.46 KB) | -
195-
./src/client/this-file-grew-larger.tsx | 562 Bytes -> 762 Bytes (+200 Bytes) | +35.59%
196-
./src/client/helpers/this-file-grew-smaller.ts | 2.46 KB -> 2.26 KB (-200 Bytes) | -7.94%
197-
./src/client/this-file-will-be-deleted.ts | 1.46 KB -> 0 Bytes (-1.46 KB) | -100%`)
186+
File | Δ
187+
---- | -
188+
\`src/client/this/file/has/a/long/name/so-that-it-will-hopefully-wrap.tsx\` | 🆕 +2.72 KB
189+
\`src/client/this-file-was-added.ts\` | 🆕 +1.46 KB
190+
\`src/client/this-is-another-file-with-a-long-name-to-test-the-table-sizing.tsx\` | 🆕 +1.04 KB
191+
\`src/client/helpers/this-file-is-much-larger.ts\` | 📈 +11.66 KB (+865.77%)
192+
\`src/client/this-file-grew-larger.tsx\` | 📈 +200 B (+35.59%)
193+
\`src/client/helpers/this-file-grew-smaller.ts\` | 📉 -200 B (-7.94%)
194+
\`src/client/this-file-is-much-smaller.tsx\` | 📉 -11.66 KB (-99.92%)
195+
\`src/client/routes.tsx\` | 🔥 -2.72 KB (-100%)
196+
\`src/client/this-file-will-be-deleted.ts\` | 🔥 -1.46 KB (-100%)
197+
\`src/client/render-memex.tsx\` | 🔥 -1.04 KB (-100%)
198+
199+
<details>
200+
<summary>View detailed changes</summary>
201+
202+
File | Old | New | Δ
203+
---- | --- | --- | -
204+
\`src/client/this/file/has/a/long/name/so-that-it-will-hopefully-wrap.tsx\` | 0 B | 2.72 KB | 🆕 +2.72 KB
205+
\`src/client/this-file-was-added.ts\` | 0 B | 1.46 KB | 🆕 +1.46 KB
206+
\`src/client/this-is-another-file-with-a-long-name-to-test-the-table-sizing.tsx\` | 0 B | 1.04 KB | 🆕 +1.04 KB
207+
\`src/client/helpers/this-file-is-much-larger.ts\` | 1.35 KB | 13.01 KB | 📈 +11.66 KB (+865.77%)
208+
\`src/client/this-file-grew-larger.tsx\` | 562 B | 762 B | 📈 +200 B (+35.59%)
209+
\`src/client/helpers/this-file-grew-smaller.ts\` | 2.46 KB | 2.26 KB | 📉 -200 B (-7.94%)
210+
\`src/client/this-file-is-much-smaller.tsx\` | 11.67 KB | 10 B | 📉 -11.66 KB (-99.92%)
211+
\`src/client/routes.tsx\` | 2.72 KB | 0 B | 🔥 -2.72 KB (-100%)
212+
\`src/client/this-file-will-be-deleted.ts\` | 1.46 KB | 0 B | 🔥 -1.46 KB (-100%)
213+
\`src/client/render-memex.tsx\` | 1.04 KB | 0 B | 🔥 -1.04 KB (-100%)
214+
215+
</details>
216+
`)
198217
})
199218

200219
test('displays no module information when unchanged', () => {

dist/index.js

Lines changed: 57 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/file-sizes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const BYTES_PER_KILOBYTE = 1024
22
const denominations = [
3-
'Bytes', // 1 Byte
3+
'B', // 1 Byte
44
'KB', // 1 Kilobyte
55
'MB', // 1 Megabyte
66
'GB', // 1 Gigabyte

0 commit comments

Comments
 (0)