Skip to content

Commit 27d7668

Browse files
committed
align stats string output to max length
1 parent 0e404b8 commit 27d7668

File tree

58 files changed

+854
-834
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+854
-834
lines changed

lib/Stats.js

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -998,19 +998,39 @@ class Stats {
998998

999999
const processModulesList = (obj, prefix) => {
10001000
if (obj.modules) {
1001+
let maxModuleId = 0;
1002+
for (const module of obj.modules) {
1003+
if (typeof module.id === "number") {
1004+
if (maxModuleId < module.id) maxModuleId = module.id;
1005+
}
1006+
}
1007+
let contentPrefix = prefix + " ";
1008+
if (maxModuleId >= 10) contentPrefix += " ";
1009+
if (maxModuleId >= 100) contentPrefix += " ";
1010+
if (maxModuleId >= 1000) contentPrefix += " ";
10011011
for (const module of obj.modules) {
10021012
colors.normal(prefix);
10031013
const name = module.name || module.identifier;
1004-
let contentPrefix = prefix + " ";
10051014
if (typeof module.id === "string" || typeof module.id === "number") {
1006-
contentPrefix += " ";
1007-
if (module.id < 1000) colors.normal(" ");
1008-
if (module.id < 100) colors.normal(" ");
1009-
if (module.id < 10) colors.normal(" ");
1010-
colors.normal("[");
1011-
colors.normal(module.id);
1012-
colors.normal("]");
1013-
if (name !== module.id) colors.normal(" ");
1015+
if (typeof module.id === "number") {
1016+
if (module.id < 1000 && maxModuleId >= 1000) colors.normal(" ");
1017+
if (module.id < 100 && maxModuleId >= 100) colors.normal(" ");
1018+
if (module.id < 10 && maxModuleId >= 10) colors.normal(" ");
1019+
} else {
1020+
if (maxModuleId >= 1000) colors.normal(" ");
1021+
if (maxModuleId >= 100) colors.normal(" ");
1022+
if (maxModuleId >= 10) colors.normal(" ");
1023+
}
1024+
if (name !== module.id) {
1025+
colors.normal("[");
1026+
colors.normal(module.id);
1027+
colors.normal("]");
1028+
colors.normal(" ");
1029+
} else {
1030+
colors.normal("[");
1031+
colors.bold(module.id);
1032+
colors.normal("]");
1033+
}
10141034
}
10151035
if (name !== module.id) {
10161036
colors.bold(name);

test/statsCases/aggressive-splitting-entry/expected.txt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ Child fitting:
1111
Entrypoint main = d43339a3d0f86c6b8d90.js 6c7fb52c5514dbfbf094.js a1e683753eca705a0882.js
1212
chunk {0} fb95acf7c457672e70d0.js 916 bytes <{1}> <{2}> <{3}>
1313
> ./g [4] ./index.js 7:0-13
14-
[7] ./g.js 916 bytes {0} [built]
14+
[7] ./g.js 916 bytes {0} [built]
1515
chunk {1} a1e683753eca705a0882.js 1.87 KiB ={2}= ={3}= >{0}< [entry] [rendered]
1616
> ./index main
17-
[3] ./e.js 899 bytes {1} [built]
18-
[4] ./index.js 111 bytes {1} [built]
19-
[6] ./f.js 900 bytes {1} [built]
17+
[3] ./e.js 899 bytes {1} [built]
18+
[4] ./index.js 111 bytes {1} [built]
19+
[6] ./f.js 900 bytes {1} [built]
2020
chunk {2} d43339a3d0f86c6b8d90.js 1.76 KiB ={1}= ={3}= >{0}< [initial] [rendered] [recorded] aggressive splitted
2121
> ./index main
22-
[0] ./b.js 899 bytes {2} [built]
23-
[5] ./a.js 899 bytes {2} [built]
22+
[0] ./b.js 899 bytes {2} [built]
23+
[5] ./a.js 899 bytes {2} [built]
2424
chunk {3} 6c7fb52c5514dbfbf094.js 1.76 KiB ={1}= ={2}= >{0}< [initial] [rendered] [recorded] aggressive splitted
2525
> ./index main
26-
[1] ./c.js 899 bytes {3} [built]
27-
[2] ./d.js 899 bytes {3} [built]
26+
[1] ./c.js 899 bytes {3} [built]
27+
[2] ./d.js 899 bytes {3} [built]
2828
Child content-change:
2929
Hash: a82dbd8d6c7a22df1caf
3030
Time: Xms
@@ -37,17 +37,17 @@ Child content-change:
3737
Entrypoint main = d43339a3d0f86c6b8d90.js 6c7fb52c5514dbfbf094.js a1e683753eca705a0882.js
3838
chunk {0} fb95acf7c457672e70d0.js 916 bytes <{1}> <{2}> <{3}>
3939
> ./g [4] ./index.js 7:0-13
40-
[7] ./g.js 916 bytes {0} [built]
40+
[7] ./g.js 916 bytes {0} [built]
4141
chunk {1} a1e683753eca705a0882.js 1.87 KiB ={2}= ={3}= >{0}< [entry] [rendered]
4242
> ./index main
43-
[3] ./e.js 899 bytes {1} [built]
44-
[4] ./index.js 111 bytes {1} [built]
45-
[6] ./f.js 900 bytes {1} [built]
43+
[3] ./e.js 899 bytes {1} [built]
44+
[4] ./index.js 111 bytes {1} [built]
45+
[6] ./f.js 900 bytes {1} [built]
4646
chunk {2} d43339a3d0f86c6b8d90.js 1.76 KiB ={1}= ={3}= >{0}< [initial] [rendered] [recorded] aggressive splitted
4747
> ./index main
48-
[0] ./b.js 899 bytes {2} [built]
49-
[5] ./a.js 899 bytes {2} [built]
48+
[0] ./b.js 899 bytes {2} [built]
49+
[5] ./a.js 899 bytes {2} [built]
5050
chunk {3} 6c7fb52c5514dbfbf094.js 1.76 KiB ={1}= ={2}= >{0}< [initial] [rendered] [recorded] aggressive splitted
5151
> ./index main
52-
[1] ./c.js 899 bytes {3} [built]
53-
[2] ./d.js 899 bytes {3} [built]
52+
[1] ./c.js 899 bytes {3} [built]
53+
[2] ./d.js 899 bytes {3} [built]

test/statsCases/aggressive-splitting-on-demand/expected.txt

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,48 +18,48 @@ Entrypoint main = d20b83dfd7d0fd0c8793.js
1818
chunk {0} 4467a9f70ef8365bcb32.js 1.76 KiB <{10}> ={1}= ={2}= ={3}= ={7}= ={9}= [recorded] aggressive splitted
1919
> ./b ./d ./e ./f ./g [11] ./index.js 5:0-44
2020
> ./b ./d ./e ./f ./g ./h ./i ./j ./k [11] ./index.js 6:0-72
21-
[0] ./b.js 899 bytes {0} {5} [built]
22-
[1] ./d.js 899 bytes {0} {8} [built]
21+
[0] ./b.js 899 bytes {0} {5} [built]
22+
[1] ./d.js 899 bytes {0} {8} [built]
2323
chunk {1} aafb9d82e452def4c3bb.js 899 bytes <{10}> ={0}= ={2}= ={8}=
2424
> ./c ./d ./e [11] ./index.js 3:0-30
2525
> ./b ./d ./e ./f ./g [11] ./index.js 5:0-44
26-
[2] ./e.js 899 bytes {1} {3} [built]
26+
[2] ./e.js 899 bytes {1} {3} [built]
2727
chunk {2} 8debdc7e72b763a13e35.js 1.76 KiB <{10}> ={0}= ={1}= ={11}= ={3}= ={6}= ={7}= ={9}= [recorded] aggressive splitted
2828
> ./f ./g ./h ./i ./j ./k [11] ./index.js 4:0-51
2929
> ./b ./d ./e ./f ./g [11] ./index.js 5:0-44
3030
> ./b ./d ./e ./f ./g ./h ./i ./j ./k [11] ./index.js 6:0-72
31-
[3] ./f.js 899 bytes {2} [built]
32-
[4] ./g.js 901 bytes {2} [built]
31+
[3] ./f.js 899 bytes {2} [built]
32+
[4] ./g.js 901 bytes {2} [built]
3333
chunk {3} 6a2c2702ac98f9f90db9.js 1.76 KiB <{10}> ={0}= ={2}= ={7}= ={9}= [rendered] [recorded] aggressive splitted
3434
> ./b ./d ./e ./f ./g ./h ./i ./j ./k [11] ./index.js 6:0-72
35-
[2] ./e.js 899 bytes {1} {3} [built]
36-
[6] ./h.js 899 bytes {3} {11} [built]
35+
[2] ./e.js 899 bytes {1} {3} [built]
36+
[6] ./h.js 899 bytes {3} {11} [built]
3737
chunk {4} 258ba4b441feff644266.js 899 bytes <{10}>
3838
> ./a [11] ./index.js 1:0-16
39-
[10] ./a.js 899 bytes {4} [built]
39+
[10] ./a.js 899 bytes {4} [built]
4040
chunk {5} 8ae4998ca98adb2a08ea.js 1.76 KiB <{10}>
4141
> ./b ./c [11] ./index.js 2:0-23
42-
[0] ./b.js 899 bytes {0} {5} [built]
43-
[5] ./c.js 899 bytes {5} {8} [built]
42+
[0] ./b.js 899 bytes {0} {5} [built]
43+
[5] ./c.js 899 bytes {5} {8} [built]
4444
chunk {6} 620d3f8d9bdb989cde07.js 1.76 KiB <{10}> ={11}= ={2}=
4545
> ./f ./g ./h ./i ./j ./k [11] ./index.js 4:0-51
46-
[8] ./j.js 901 bytes {6} {9} [built]
47-
[9] ./k.js 899 bytes {6} {7} [built]
46+
[8] ./j.js 901 bytes {6} {9} [built]
47+
[9] ./k.js 899 bytes {6} {7} [built]
4848
chunk {7} 344e13508b62e833aacf.js 899 bytes <{10}> ={0}= ={2}= ={3}= ={9}=
4949
> ./b ./d ./e ./f ./g ./h ./i ./j ./k [11] ./index.js 6:0-72
50-
[9] ./k.js 899 bytes {6} {7} [built]
50+
[9] ./k.js 899 bytes {6} {7} [built]
5151
chunk {8} 2aaed192bbfbc2302c53.js 1.76 KiB <{10}> ={1}= [recorded] aggressive splitted
5252
> ./c ./d ./e [11] ./index.js 3:0-30
53-
[1] ./d.js 899 bytes {0} {8} [built]
54-
[5] ./c.js 899 bytes {5} {8} [built]
53+
[1] ./d.js 899 bytes {0} {8} [built]
54+
[5] ./c.js 899 bytes {5} {8} [built]
5555
chunk {9} 72e04d4eaed46d9aac4c.js 1.76 KiB <{10}> ={0}= ={2}= ={3}= ={7}= [rendered] [recorded] aggressive splitted
5656
> ./b ./d ./e ./f ./g ./h ./i ./j ./k [11] ./index.js 6:0-72
57-
[7] ./i.js 899 bytes {9} {11} [built]
58-
[8] ./j.js 901 bytes {6} {9} [built]
57+
[7] ./i.js 899 bytes {9} {11} [built]
58+
[8] ./j.js 901 bytes {6} {9} [built]
5959
chunk {10} d20b83dfd7d0fd0c8793.js (main) 248 bytes >{0}< >{1}< >{11}< >{2}< >{3}< >{4}< >{5}< >{6}< >{7}< >{8}< >{9}< [entry] [rendered]
6060
> ./index main
61-
[11] ./index.js 248 bytes {10} [built]
61+
[11] ./index.js 248 bytes {10} [built]
6262
chunk {11} 1165c0cca1ba14a506ff.js 1.76 KiB <{10}> ={2}= ={6}= [rendered] [recorded] aggressive splitted
6363
> ./f ./g ./h ./i ./j ./k [11] ./index.js 4:0-51
64-
[6] ./h.js 899 bytes {3} {11} [built]
65-
[7] ./i.js 899 bytes {9} {11} [built]
64+
[6] ./h.js 899 bytes {3} {11} [built]
65+
[7] ./i.js 899 bytes {9} {11} [built]

0 commit comments

Comments
 (0)