Skip to content

Commit c784a96

Browse files
committed
expand test case to cover more cases
1 parent acdabb1 commit c784a96

File tree

3 files changed

+236
-77
lines changed

3 files changed

+236
-77
lines changed
Lines changed: 160 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,160 @@
1-
Entrypoint main = main.js
2-
Entrypoint a = libs.js vendors.js a.js
3-
Entrypoint b = libs.js vendors.js b.js
4-
Entrypoint c = libs.js vendors.js c.js
5-
chunk {0} 0.chunk.js 40 bytes {7} [rendered] commons chunk
6-
[0] ./d.js 20 bytes {0} {8} {9} {10} [built]
7-
[1] ./node_modules/x.js 20 bytes {0} {11} [built]
8-
chunk {1} 1.chunk.js 20 bytes {0+2+3} {7} {8+11+12} [rendered] commons chunk
9-
[2] ./f.js 20 bytes {1} {9} {10} [built]
10-
chunk {2} 2.chunk.js 20 bytes {7} [rendered] commons chunk
11-
[3] ./node_modules/y.js 20 bytes {2} {12} [built]
12-
chunk {3} 3.chunk.js 122 bytes {7} [rendered]
13-
> [8] ./index.js 1:0-13
14-
[7] ./a.js + 1 modules 122 bytes {3} {8} [built]
15-
| ./a.js 87 bytes [built]
16-
| ./e.js 20 bytes [built]
17-
chunk {4} 4.chunk.js 72 bytes {7} [rendered]
18-
> [8] ./index.js 2:0-13
19-
[5] ./b.js 72 bytes {4} {9} [built]
20-
chunk {5} 5.chunk.js 92 bytes {7} [rendered]
21-
> [8] ./index.js 3:0-13
22-
[4] ./node_modules/z.js 20 bytes {5} {12} [built]
23-
[6] ./c.js 72 bytes {5} {10} [built]
24-
chunk {6} 6.chunk.js 34 bytes {0+2+3} {8+11+12} [rendered]
25-
> [] 6:0-13
26-
[9] ./g.js 34 bytes {6} [built]
27-
chunk {7} main.js (main) 45 bytes [entry] [rendered]
28-
> main [8] ./index.js
29-
[8] ./index.js 45 bytes {7} [built]
30-
chunk {8} a.js (a) 142 bytes [entry] [rendered]
31-
> a []
32-
[0] ./d.js 20 bytes {0} {8} {9} {10} [built]
33-
[7] ./a.js + 1 modules 122 bytes {3} {8} [built]
34-
| ./a.js 87 bytes [built]
35-
| ./e.js 20 bytes [built]
36-
chunk {9} b.js (b) 112 bytes [entry] [rendered]
37-
> b [5] ./b.js
38-
[0] ./d.js 20 bytes {0} {8} {9} {10} [built]
39-
[2] ./f.js 20 bytes {1} {9} {10} [built]
40-
[5] ./b.js 72 bytes {4} {9} [built]
41-
chunk {10} c.js (c) 112 bytes [entry] [rendered]
42-
> c [6] ./c.js
43-
[0] ./d.js 20 bytes {0} {8} {9} {10} [built]
44-
[2] ./f.js 20 bytes {1} {9} {10} [built]
45-
[6] ./c.js 72 bytes {5} {10} [built]
46-
chunk {11} libs.js (libs) 20 bytes [initial] [rendered] vendors chunk
47-
[1] ./node_modules/x.js 20 bytes {0} {11} [built]
48-
chunk {12} vendors.js (vendors) 40 bytes [initial] [rendered] vendors chunk
49-
[3] ./node_modules/y.js 20 bytes {2} {12} [built]
50-
[4] ./node_modules/z.js 20 bytes {5} {12} [built]
1+
Child async-only:
2+
Entrypoint main = async-only/main.js
3+
Entrypoint a = async-only/a.js
4+
Entrypoint b = async-only/b.js
5+
Entrypoint c = async-only/c.js
6+
chunk {0} async-only/0.js 20 bytes {8} {1+2+4} {7} [rendered] commons chunk
7+
[2] ./f.js 20 bytes {0} {9} {10} [built]
8+
chunk {1} async-only/1.js 40 bytes {7} [rendered] commons chunk
9+
[0] ./d.js 20 bytes {1} {8} {9} {10} [built]
10+
[1] ./node_modules/x.js 20 bytes {1} {8} {9} {10} [built]
11+
chunk {2} async-only/2.js 20 bytes {7} [rendered] commons chunk
12+
[3] ./node_modules/y.js 20 bytes {2} {8} {9} [built]
13+
chunk {3} async-only/3.js 34 bytes {8} {1+2+4} [rendered]
14+
> [] 6:0-13
15+
[8] ./g.js 34 bytes {3} [built]
16+
chunk {4} async-only/4.js 122 bytes {7} [rendered]
17+
> [7] ./index.js 1:0-13
18+
[5] ./a.js + 1 modules 122 bytes {4} {8} [built]
19+
| ./a.js 87 bytes [built]
20+
| ./e.js 20 bytes [built]
21+
chunk {5} async-only/5.js 72 bytes {7} [rendered]
22+
> [7] ./index.js 2:0-13
23+
[4] ./b.js 72 bytes {5} {9} [built]
24+
chunk {6} async-only/6.js 107 bytes {7} [rendered]
25+
> [7] ./index.js 3:0-13
26+
[6] ./c.js + 1 modules 107 bytes {6} {10} [built]
27+
| ./c.js 72 bytes [built]
28+
| ./node_modules/z.js 20 bytes [built]
29+
chunk {7} async-only/main.js (main) 45 bytes [entry] [rendered]
30+
> main [7] ./index.js
31+
[7] ./index.js 45 bytes {7} [built]
32+
chunk {8} async-only/a.js (a) 182 bytes [entry] [rendered]
33+
> a []
34+
[0] ./d.js 20 bytes {1} {8} {9} {10} [built]
35+
[1] ./node_modules/x.js 20 bytes {1} {8} {9} {10} [built]
36+
[3] ./node_modules/y.js 20 bytes {2} {8} {9} [built]
37+
[5] ./a.js + 1 modules 122 bytes {4} {8} [built]
38+
| ./a.js 87 bytes [built]
39+
| ./e.js 20 bytes [built]
40+
chunk {9} async-only/b.js (b) 152 bytes [entry] [rendered]
41+
> b [4] ./b.js
42+
[0] ./d.js 20 bytes {1} {8} {9} {10} [built]
43+
[1] ./node_modules/x.js 20 bytes {1} {8} {9} {10} [built]
44+
[2] ./f.js 20 bytes {0} {9} {10} [built]
45+
[3] ./node_modules/y.js 20 bytes {2} {8} {9} [built]
46+
[4] ./b.js 72 bytes {5} {9} [built]
47+
chunk {10} async-only/c.js (c) 167 bytes [entry] [rendered]
48+
> c []
49+
[0] ./d.js 20 bytes {1} {8} {9} {10} [built]
50+
[1] ./node_modules/x.js 20 bytes {1} {8} {9} {10} [built]
51+
[2] ./f.js 20 bytes {0} {9} {10} [built]
52+
[6] ./c.js + 1 modules 107 bytes {6} {10} [built]
53+
| ./c.js 72 bytes [built]
54+
| ./node_modules/z.js 20 bytes [built]
55+
Child vendors1:
56+
Entrypoint main = vendors1/main.js
57+
Entrypoint a = vendors1/vendors.js vendors1/10.js vendors1/a.js
58+
Entrypoint b = vendors1/vendors.js vendors1/9.js vendors1/10.js vendors1/b.js
59+
Entrypoint c = vendors1/vendors.js vendors1/9.js vendors1/10.js vendors1/c.js
60+
chunk {0} vendors1/0.js 182 bytes {4} [rendered]
61+
> [8] ./index.js 1:0-13
62+
[0] ./d.js 20 bytes {0} {1} {2} {10} [built]
63+
[1] ./node_modules/x.js 20 bytes {0} {1} {2} {8} [built]
64+
[3] ./node_modules/y.js 20 bytes {0} {1} {8} [built]
65+
[7] ./a.js + 1 modules 122 bytes {0} {5} [built]
66+
| ./a.js 87 bytes [built]
67+
| ./e.js 20 bytes [built]
68+
chunk {1} vendors1/1.js 152 bytes {4} [rendered]
69+
> [8] ./index.js 2:0-13
70+
[0] ./d.js 20 bytes {0} {1} {2} {10} [built]
71+
[1] ./node_modules/x.js 20 bytes {0} {1} {2} {8} [built]
72+
[2] ./f.js 20 bytes {1} {2} {3} {9} [built]
73+
[3] ./node_modules/y.js 20 bytes {0} {1} {8} [built]
74+
[5] ./b.js 72 bytes {1} {6} [built]
75+
chunk {2} vendors1/2.js 152 bytes {4} [rendered]
76+
> [8] ./index.js 3:0-13
77+
[0] ./d.js 20 bytes {0} {1} {2} {10} [built]
78+
[1] ./node_modules/x.js 20 bytes {0} {1} {2} {8} [built]
79+
[2] ./f.js 20 bytes {1} {2} {3} {9} [built]
80+
[4] ./node_modules/z.js 20 bytes {2} {8} [built]
81+
[6] ./c.js 72 bytes {2} {7} [built]
82+
chunk {3} vendors1/3.js 54 bytes {0} {5+8+10} [rendered]
83+
> [] 6:0-13
84+
[2] ./f.js 20 bytes {1} {2} {3} {9} [built]
85+
[9] ./g.js 34 bytes {3} [built]
86+
chunk {4} vendors1/main.js (main) 45 bytes [entry] [rendered]
87+
> main [8] ./index.js
88+
[8] ./index.js 45 bytes {4} [built]
89+
chunk {5} vendors1/a.js (a) 122 bytes [entry] [rendered]
90+
> a []
91+
[7] ./a.js + 1 modules 122 bytes {0} {5} [built]
92+
| ./a.js 87 bytes [built]
93+
| ./e.js 20 bytes [built]
94+
chunk {6} vendors1/b.js (b) 72 bytes [entry] [rendered]
95+
> b [5] ./b.js
96+
[5] ./b.js 72 bytes {1} {6} [built]
97+
chunk {7} vendors1/c.js (c) 72 bytes [entry] [rendered]
98+
> c [6] ./c.js
99+
[6] ./c.js 72 bytes {2} {7} [built]
100+
chunk {8} vendors1/vendors.js (vendors) 60 bytes [initial] [rendered] vendors chunk
101+
[1] ./node_modules/x.js 20 bytes {0} {1} {2} {8} [built]
102+
[3] ./node_modules/y.js 20 bytes {0} {1} {8} [built]
103+
[4] ./node_modules/z.js 20 bytes {2} {8} [built]
104+
chunk {9} vendors1/9.js 20 bytes [initial] [rendered] commons chunk
105+
[2] ./f.js 20 bytes {1} {2} {3} {9} [built]
106+
chunk {10} vendors1/10.js 20 bytes [initial] [rendered] commons chunk
107+
[0] ./d.js 20 bytes {0} {1} {2} {10} [built]
108+
Child async-and-vendor:
109+
Entrypoint main = async-and-vendor/main.js
110+
Entrypoint a = async-and-vendor/libs-x.js async-and-vendor/vendors.js async-and-vendor/a.js
111+
Entrypoint b = async-and-vendor/libs-x.js async-and-vendor/vendors.js async-and-vendor/b.js
112+
Entrypoint c = async-and-vendor/libs-x.js async-and-vendor/vendors.js async-and-vendor/c.js
113+
chunk {0} async-and-vendor/0.js 40 bytes {7} [rendered] commons chunk
114+
[0] ./d.js 20 bytes {0} {8} {9} {10} [built]
115+
[1] ./node_modules/x.js 20 bytes {0} {12} [built]
116+
chunk {1} async-and-vendor/1.js 20 bytes {0+2+3} {7} {8+11+12} [rendered] commons chunk
117+
[2] ./f.js 20 bytes {1} {9} {10} [built]
118+
chunk {2} async-and-vendor/2.js 20 bytes {7} [rendered] commons chunk
119+
[3] ./node_modules/y.js 20 bytes {2} {11} [built]
120+
chunk {3} async-and-vendor/3.js 122 bytes {7} [rendered]
121+
> [8] ./index.js 1:0-13
122+
[7] ./a.js + 1 modules 122 bytes {3} {8} [built]
123+
| ./a.js 87 bytes [built]
124+
| ./e.js 20 bytes [built]
125+
chunk {4} async-and-vendor/4.js 72 bytes {7} [rendered]
126+
> [8] ./index.js 2:0-13
127+
[5] ./b.js 72 bytes {4} {9} [built]
128+
chunk {5} async-and-vendor/5.js 92 bytes {7} [rendered]
129+
> [8] ./index.js 3:0-13
130+
[4] ./node_modules/z.js 20 bytes {5} {11} [built]
131+
[6] ./c.js 72 bytes {5} {10} [built]
132+
chunk {6} async-and-vendor/6.js 34 bytes {0+2+3} {8+11+12} [rendered]
133+
> [] 6:0-13
134+
[10] ./g.js 34 bytes {6} [built]
135+
chunk {7} async-and-vendor/main.js (main) 45 bytes [entry] [rendered]
136+
> main [8] ./index.js
137+
[8] ./index.js 45 bytes {7} [built]
138+
chunk {8} async-and-vendor/a.js (a) 142 bytes [entry] [rendered]
139+
> a []
140+
[0] ./d.js 20 bytes {0} {8} {9} {10} [built]
141+
[7] ./a.js + 1 modules 122 bytes {3} {8} [built]
142+
| ./a.js 87 bytes [built]
143+
| ./e.js 20 bytes [built]
144+
chunk {9} async-and-vendor/b.js (b) 112 bytes [entry] [rendered]
145+
> b [5] ./b.js
146+
[0] ./d.js 20 bytes {0} {8} {9} {10} [built]
147+
[2] ./f.js 20 bytes {1} {9} {10} [built]
148+
[5] ./b.js 72 bytes {4} {9} [built]
149+
chunk {10} async-and-vendor/c.js (c) 112 bytes [entry] [rendered]
150+
> c [6] ./c.js
151+
[0] ./d.js 20 bytes {0} {8} {9} {10} [built]
152+
[2] ./f.js 20 bytes {1} {9} {10} [built]
153+
[6] ./c.js 72 bytes {5} {10} [built]
154+
chunk {11} async-and-vendor/vendors.js (vendors) 61 bytes [initial] [rendered] vendors chunk
155+
> vendors [9] ./node_modules/xy.js
156+
[3] ./node_modules/y.js 20 bytes {2} {11} [built]
157+
[4] ./node_modules/z.js 20 bytes {5} {11} [built]
158+
[9] ./node_modules/xy.js 21 bytes {11} [built]
159+
chunk {12} async-and-vendor/libs-x.js (libs-x) 20 bytes [initial] [rendered] vendors chunk
160+
[1] ./node_modules/x.js 20 bytes {0} {12} [built]

test/statsCases/async-commons-chunk-auto/node_modules/xy.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 75 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,79 @@
11
const path = require("path");
2-
module.exports = {
3-
mode: "production",
4-
entry: {
5-
main: "./",
6-
a: "./a",
7-
b: "./b",
8-
c: "./c"
9-
},
10-
output: {
11-
chunkFilename: "[name].chunk.js"
2+
const stats = {
3+
hash: false,
4+
timings: false,
5+
assets: false,
6+
chunks: true,
7+
chunkOrigins: true,
8+
entrypoints: true,
9+
modules: false
10+
};
11+
module.exports = [
12+
{
13+
name: "async-only",
14+
mode: "production",
15+
entry: {
16+
main: "./",
17+
a: "./a",
18+
b: "./b",
19+
c: "./c"
20+
},
21+
output: {
22+
filename: "async-only/[name].js"
23+
},
24+
optimization: {
25+
asyncCommonsChunks: {
26+
minSize: 1 // enforce all
27+
}
28+
},
29+
stats
1230
},
13-
optimization: {
14-
asyncCommonsChunks: {
15-
minSize: 1 // enforce all
16-
},
17-
initialVendorsChunk: {
18-
"libs": /[\\/](xyz|x)/,
19-
vendors: path.resolve(__dirname, "node_modules")
20-
}
31+
{
32+
name: "vendors1",
33+
mode: "production",
34+
entry: {
35+
main: "./",
36+
a: "./a",
37+
b: "./b",
38+
c: "./c"
39+
},
40+
output: {
41+
filename: "vendors1/[name].js"
42+
},
43+
optimization: {
44+
asyncCommonsChunks: false,
45+
initialCommonsChunks: {
46+
minSize: 1 // enforce all
47+
},
48+
initialVendorsChunk: true
49+
},
50+
stats
2151
},
22-
stats: {
23-
hash: false,
24-
timings: false,
25-
assets: false,
26-
chunks: true,
27-
chunkOrigins: true,
28-
entrypoints: true,
29-
modules: false
52+
{
53+
name: "async-and-vendor",
54+
mode: "production",
55+
entry: {
56+
main: "./",
57+
a: "./a",
58+
b: "./b",
59+
c: "./c",
60+
vendors: "xy"
61+
},
62+
output: {
63+
filename: "async-and-vendor/[name].js"
64+
},
65+
optimization: {
66+
asyncCommonsChunks: {
67+
minSize: 1 // enforce all
68+
},
69+
initialVendorsChunk: {
70+
"libs": name => {
71+
const match = /[\\/](xyz|x)\.js/.exec(name);
72+
if(match) return "libs-" + match[1];
73+
},
74+
vendors: path.resolve(__dirname, "node_modules")
75+
}
76+
},
77+
stats
3078
}
31-
};
79+
];

0 commit comments

Comments
 (0)