Skip to content

Commit 044adc9

Browse files
authored
Merge pull request #24 from github/handle-gzip-display
handle gzipped displaying
2 parents c6574c2 + 467ab16 commit 044adc9

File tree

6 files changed

+299
-309
lines changed

6 files changed

+299
-309
lines changed

__tests__/main.test.ts

Lines changed: 44 additions & 240 deletions
Original file line numberDiff line numberDiff line change
@@ -11,103 +11,37 @@ test('Shows stats when files are removed', () => {
1111
require('./__mocks__/old-stats-assets.json'),
1212
require('./__mocks__/new-stats-assets.json')
1313
)
14-
expect(statsDiff).toEqual({
15-
added: [],
16-
bigger: [
17-
{
18-
diff: 260452,
19-
diffPercentage: 23.90567,
20-
name: 'app.bundle.js',
21-
newSize: 1349951,
22-
oldSize: 1089499
23-
}
24-
],
25-
removed: [
26-
{
27-
diff: -127558,
28-
diffPercentage: -100,
29-
name: '296.chunk.js',
30-
newSize: 0,
31-
oldSize: 127558
32-
},
33-
{
34-
diff: -58610,
35-
diffPercentage: -100,
36-
name: '288.chunk.js',
37-
newSize: 0,
38-
oldSize: 58610
39-
},
40-
{
41-
diff: -56302,
42-
diffPercentage: -100,
43-
name: '920.chunk.js',
44-
newSize: 0,
45-
oldSize: 56302
46-
},
47-
{
48-
diff: -45438,
49-
diffPercentage: -100,
50-
name: '912.chunk.js',
51-
newSize: 0,
52-
oldSize: 45438
53-
},
54-
{
55-
diff: -27026,
56-
diffPercentage: -100,
57-
name: '699.chunk.js',
58-
newSize: 0,
59-
oldSize: 27026
60-
}
61-
],
62-
smaller: [
63-
{
64-
diff: -460,
65-
diffPercentage: -83.48457,
66-
name: 'manifest.json',
67-
newSize: 91,
68-
oldSize: 551
69-
}
70-
],
71-
total: {
72-
diff: -54942,
73-
diffPercentage: -3.91051,
74-
name: '7 -> 2',
75-
newSize: 1350042,
76-
oldSize: 1404984
77-
},
78-
unchanged: []
79-
})
8014

8115
expect(printTotalAssetTable(statsDiff)).toEqual(`**Total**
8216
83-
Files count | Total bundle size | % Changed
84-
----------- | ----------------- | ---------
85-
7 -> 2 | 1.34 MB -> 1.29 MB (-53.65 KB) | -3.91%`)
17+
Files count | Type | Total bundle size | % Changed
18+
----------- | ---- | ----------------- | ---------
19+
7 -> 2 | bundled<br />gzip | 1.34 MB -> 1.29 MB (-53.65 KB)<br />386.44 KB -> N/A | -3.91%`)
8620
expect(printAssetTablesByGroup(statsDiff)).toEqual(`**Added**
8721
8822
No assets were added
8923
9024
**Removed**
9125
92-
Asset | File Size | % Changed
93-
----- | --------- | ---------
94-
296.chunk.js | 124.57 KB -> 0 Bytes (-124.57 KB) | -100%
95-
288.chunk.js | 57.24 KB -> 0 Bytes (-57.24 KB) | -100%
96-
920.chunk.js | 54.98 KB -> 0 Bytes (-54.98 KB) | -100%
97-
912.chunk.js | 44.37 KB -> 0 Bytes (-44.37 KB) | -100%
98-
699.chunk.js | 26.39 KB -> 0 Bytes (-26.39 KB) | -100%
26+
Asset | Type | File Size | % Changed
27+
----- | ---- | --------- | ---------
28+
296.chunk.js | bundled<br />gzip | 124.57 KB -> 0 Bytes (-124.57 KB)<br />35.05 KB -> 0 Bytes | -100%
29+
288.chunk.js | bundled<br />gzip | 57.24 KB -> 0 Bytes (-57.24 KB)<br />16.33 KB -> 0 Bytes | -100%
30+
920.chunk.js | bundled<br />gzip | 54.98 KB -> 0 Bytes (-54.98 KB)<br />17.08 KB -> 0 Bytes | -100%
31+
912.chunk.js | bundled<br />gzip | 44.37 KB -> 0 Bytes (-44.37 KB)<br />14.31 KB -> 0 Bytes | -100%
32+
699.chunk.js | bundled<br />gzip | 26.39 KB -> 0 Bytes (-26.39 KB)<br />6.14 KB -> 0 Bytes | -100%
9933
10034
**Bigger**
10135
102-
Asset | File Size | % Changed
103-
----- | --------- | ---------
104-
app.bundle.js | 1.04 MB -> 1.29 MB (+254.35 KB) | +23.91%
36+
Asset | Type | File Size | % Changed
37+
----- | ---- | --------- | ---------
38+
app.bundle.js | bundled<br />gzip | 1.04 MB -> 1.29 MB (+254.35 KB)<br />297.38 KB -> N/A | +23.91%
10539
10640
**Smaller**
10741
108-
Asset | File Size | % Changed
109-
----- | --------- | ---------
110-
manifest.json | 551 Bytes -> 91 Bytes (-460 Bytes) | -83.48%
42+
Asset | Type | File Size | % Changed
43+
----- | ---- | --------- | ---------
44+
manifest.json | bundled<br />gzip | 551 Bytes -> 91 Bytes (-460 Bytes)<br />151 Bytes -> N/A | -83.48%
11145
11246
**Unchanged**
11347
@@ -119,103 +53,37 @@ test('Shows stats when files are added', () => {
11953
require('./__mocks__/new-stats-assets.json'),
12054
require('./__mocks__/old-stats-assets.json')
12155
)
122-
expect(statsDiff).toEqual({
123-
added: [
124-
{
125-
diff: 127558,
126-
diffPercentage: Infinity,
127-
name: '296.chunk.js',
128-
newSize: 127558,
129-
oldSize: 0
130-
},
131-
{
132-
diff: 58610,
133-
diffPercentage: Infinity,
134-
name: '288.chunk.js',
135-
newSize: 58610,
136-
oldSize: 0
137-
},
138-
{
139-
diff: 56302,
140-
diffPercentage: Infinity,
141-
name: '920.chunk.js',
142-
newSize: 56302,
143-
oldSize: 0
144-
},
145-
{
146-
diff: 45438,
147-
diffPercentage: Infinity,
148-
name: '912.chunk.js',
149-
newSize: 45438,
150-
oldSize: 0
151-
},
152-
{
153-
diff: 27026,
154-
diffPercentage: Infinity,
155-
name: '699.chunk.js',
156-
newSize: 27026,
157-
oldSize: 0
158-
}
159-
],
160-
bigger: [
161-
{
162-
diff: 460,
163-
diffPercentage: 505.49451,
164-
name: 'manifest.json',
165-
newSize: 551,
166-
oldSize: 91
167-
}
168-
],
169-
removed: [],
170-
smaller: [
171-
{
172-
diff: -260452,
173-
diffPercentage: -19.29344,
174-
name: 'app.bundle.js',
175-
newSize: 1089499,
176-
oldSize: 1349951
177-
}
178-
],
179-
total: {
180-
diff: 54942,
181-
diffPercentage: 4.06965,
182-
name: '2 -> 7',
183-
newSize: 1404984,
184-
oldSize: 1350042
185-
},
186-
unchanged: []
187-
})
18856

18957
expect(printTotalAssetTable(statsDiff)).toEqual(`**Total**
19058
191-
Files count | Total bundle size | % Changed
192-
----------- | ----------------- | ---------
193-
2 -> 7 | 1.29 MB -> 1.34 MB (+53.65 KB) | +4.07%`)
59+
Files count | Type | Total bundle size | % Changed
60+
----------- | ---- | ----------------- | ---------
61+
2 -> 7 | bundled<br />gzip | 1.29 MB -> 1.34 MB (+53.65 KB)<br />N/A -> 386.44 KB | +4.07%`)
19462
expect(printAssetTablesByGroup(statsDiff)).toEqual(`**Added**
19563
196-
Asset | File Size | % Changed
197-
----- | --------- | ---------
198-
296.chunk.js | 0 Bytes -> 124.57 KB (+124.57 KB) | -
199-
288.chunk.js | 0 Bytes -> 57.24 KB (+57.24 KB) | -
200-
920.chunk.js | 0 Bytes -> 54.98 KB (+54.98 KB) | -
201-
912.chunk.js | 0 Bytes -> 44.37 KB (+44.37 KB) | -
202-
699.chunk.js | 0 Bytes -> 26.39 KB (+26.39 KB) | -
64+
Asset | Type | File Size | % Changed
65+
----- | ---- | --------- | ---------
66+
296.chunk.js | bundled<br />gzip | 0 Bytes -> 124.57 KB (+124.57 KB)<br />0 Bytes -> 35.05 KB | -
67+
288.chunk.js | bundled<br />gzip | 0 Bytes -> 57.24 KB (+57.24 KB)<br />0 Bytes -> 16.33 KB | -
68+
920.chunk.js | bundled<br />gzip | 0 Bytes -> 54.98 KB (+54.98 KB)<br />0 Bytes -> 17.08 KB | -
69+
912.chunk.js | bundled<br />gzip | 0 Bytes -> 44.37 KB (+44.37 KB)<br />0 Bytes -> 14.31 KB | -
70+
699.chunk.js | bundled<br />gzip | 0 Bytes -> 26.39 KB (+26.39 KB)<br />0 Bytes -> 6.14 KB | -
20371
20472
**Removed**
20573
20674
No assets were removed
20775
20876
**Bigger**
20977
210-
Asset | File Size | % Changed
211-
----- | --------- | ---------
212-
manifest.json | 91 Bytes -> 551 Bytes (+460 Bytes) | +505.49%
78+
Asset | Type | File Size | % Changed
79+
----- | ---- | --------- | ---------
80+
manifest.json | bundled<br />gzip | 91 Bytes -> 551 Bytes (+460 Bytes)<br />N/A -> 151 Bytes | +505.49%
21381
21482
**Smaller**
21583
216-
Asset | File Size | % Changed
217-
----- | --------- | ---------
218-
app.bundle.js | 1.29 MB -> 1.04 MB (-254.35 KB) | -19.29%
84+
Asset | Type | File Size | % Changed
85+
----- | ---- | --------- | ---------
86+
app.bundle.js | bundled<br />gzip | 1.29 MB -> 1.04 MB (-254.35 KB)<br />N/A -> 297.38 KB | -19.29%
21987
22088
**Unchanged**
22189
@@ -227,76 +95,12 @@ test('Shows stats when files are unchanged', () => {
22795
require('./__mocks__/old-stats-assets.json'),
22896
require('./__mocks__/old-stats-assets.json')
22997
)
230-
expect(statsDiff).toEqual({
231-
added: [],
232-
bigger: [],
233-
removed: [],
234-
smaller: [],
235-
total: {
236-
diff: 0,
237-
diffPercentage: 0,
238-
name: '7',
239-
newSize: 1404984,
240-
oldSize: 1404984
241-
},
242-
unchanged: [
243-
{
244-
diff: 0,
245-
diffPercentage: 0,
246-
name: 'app.bundle.js',
247-
newSize: 1089499,
248-
oldSize: 1089499
249-
},
250-
{
251-
diff: 0,
252-
diffPercentage: 0,
253-
name: '296.chunk.js',
254-
newSize: 127558,
255-
oldSize: 127558
256-
},
257-
{
258-
diff: 0,
259-
diffPercentage: 0,
260-
name: '288.chunk.js',
261-
newSize: 58610,
262-
oldSize: 58610
263-
},
264-
{
265-
diff: 0,
266-
diffPercentage: 0,
267-
name: '920.chunk.js',
268-
newSize: 56302,
269-
oldSize: 56302
270-
},
271-
{
272-
diff: 0,
273-
diffPercentage: 0,
274-
name: '912.chunk.js',
275-
newSize: 45438,
276-
oldSize: 45438
277-
},
278-
{
279-
diff: 0,
280-
diffPercentage: 0,
281-
name: '699.chunk.js',
282-
newSize: 27026,
283-
oldSize: 27026
284-
},
285-
{
286-
diff: 0,
287-
diffPercentage: 0,
288-
name: 'manifest.json',
289-
newSize: 551,
290-
oldSize: 551
291-
}
292-
]
293-
})
29498

29599
expect(printTotalAssetTable(statsDiff)).toEqual(`**Total**
296100
297-
Files count | Total bundle size | % Changed
298-
----------- | ----------------- | ---------
299-
7 | 1.34 MB | 0%`)
101+
Files count | Type | Total bundle size | % Changed
102+
----------- | ---- | ----------------- | ---------
103+
7 | bundled<br />gzip | 1.34 MB<br />386.44 KB | 0%`)
300104
expect(printAssetTablesByGroup(statsDiff)).toEqual(`**Added**
301105
302106
No assets were added
@@ -315,13 +119,13 @@ No assets were smaller
315119
316120
**Unchanged**
317121
318-
Asset | File Size | % Changed
319-
----- | --------- | ---------
320-
app.bundle.js | 1.04 MB | 0%
321-
296.chunk.js | 124.57 KB | 0%
322-
288.chunk.js | 57.24 KB | 0%
323-
920.chunk.js | 54.98 KB | 0%
324-
912.chunk.js | 44.37 KB | 0%
325-
699.chunk.js | 26.39 KB | 0%
326-
manifest.json | 551 Bytes | 0%`)
122+
Asset | Type | File Size | % Changed
123+
----- | ---- | --------- | ---------
124+
app.bundle.js | bundled<br />gzip | 1.04 MB<br />297.38 KB | 0%
125+
296.chunk.js | bundled<br />gzip | 124.57 KB<br />35.05 KB | 0%
126+
288.chunk.js | bundled<br />gzip | 57.24 KB<br />16.33 KB | 0%
127+
920.chunk.js | bundled<br />gzip | 54.98 KB<br />17.08 KB | 0%
128+
912.chunk.js | bundled<br />gzip | 44.37 KB<br />14.31 KB | 0%
129+
699.chunk.js | bundled<br />gzip | 26.39 KB<br />6.14 KB | 0%
130+
manifest.json | bundled<br />gzip | 551 Bytes<br />151 Bytes | 0%`)
327131
})

0 commit comments

Comments
 (0)