Skip to content

Commit c71dabc

Browse files
committed
allow to set runtime chunk in Entrypoint
split keeps runtime chunk in entrypoint default runtime chunk back to first chunk to keep CCP working
1 parent 85acfeb commit c71dabc

File tree

6 files changed

+31
-21
lines changed

6 files changed

+31
-21
lines changed

lib/Chunk.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,8 @@ class Chunk {
500500
newChunk._parents.add(parentChunk);
501501
}
502502
for(const entrypoint of this._entrypoints) {
503+
if(entrypoint.getRuntimeChunk() === this)
504+
entrypoint.setRuntimeChunk(this);
503505
entrypoint.insertChunk(newChunk, this);
504506
}
505507
}

lib/Entrypoint.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class Entrypoint {
88
constructor(name) {
99
this.name = name;
1010
this.chunks = [];
11+
this.runtimeChunk = undefined;
1112
}
1213

1314
unshiftChunk(chunk) {
@@ -54,8 +55,12 @@ class Entrypoint {
5455
return Array.from(files);
5556
}
5657

58+
setRuntimeChunk(chunk) {
59+
this.runtimeChunk = chunk;
60+
}
61+
5762
getRuntimeChunk() {
58-
return this.chunks[this.chunks.length - 1];
63+
return this.runtimeChunk || this.chunks[0];
5964
}
6065
}
6166

test/statsCases/commons-chunk-min-size-0/expected.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Hash: 8eb81b6ba5271547f2b2
1+
Hash: 96561e55e52ce5dd05d9
22
Time: Xms
33
Asset Size Chunks Chunk Names
4-
entry-1.js 4.02 KiB 0 [emitted] entry-1
4+
entry-1.js 81 bytes 0 [emitted] entry-1
55
vendor-1.js 5.62 KiB 1 [emitted] vendor-1
66
Entrypoint entry-1 = vendor-1.js entry-1.js
77
Entrypoint vendor-1 = vendor-1.js

test/statsCases/commons-plugin-issue-4980/expected.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
Hash: b692b715dca4d224ed46b48b74f73a93511804ad
1+
Hash: 0a7af1bf41c44dc4f3d62339087294aa36ac8856
22
Child
3-
Hash: b692b715dca4d224ed46
3+
Hash: 0a7af1bf41c44dc4f3d6
44
Time: Xms
55
Asset Size Chunks Chunk Names
6-
app.js 4.59 KiB 0 [emitted] app
6+
app.js 656 bytes 0 [emitted] app
77
vendor.1c0346d33a16fbee0579.js 619 bytes 1 [emitted] vendor
8-
Entrypoint app = vendor.1c0346d33a16fbee0579.js app.js
8+
runtime.js 4.65 KiB 2 [emitted] runtime
9+
Entrypoint app = runtime.js vendor.1c0346d33a16fbee0579.js app.js
910
[./constants.js] 87 bytes {1} [built]
1011
[./entry-1.js] ./entry-1.js + 2 modules 190 bytes {0} [built]
1112
| ./entry-1.js 67 bytes [built]
1213
| ./submodule-a.js 59 bytes [built]
1314
| ./submodule-b.js 59 bytes [built]
1415
Child
15-
Hash: b48b74f73a93511804ad
16+
Hash: 2339087294aa36ac8856
1617
Time: Xms
1718
Asset Size Chunks Chunk Names
18-
app.js 4.6 KiB 0 [emitted] app
19+
app.js 673 bytes 0 [emitted] app
1920
vendor.1c0346d33a16fbee0579.js 619 bytes 1 [emitted] vendor
20-
Entrypoint app = vendor.1c0346d33a16fbee0579.js app.js
21+
runtime.js 4.65 KiB 2 [emitted] runtime
22+
Entrypoint app = runtime.js vendor.1c0346d33a16fbee0579.js app.js
2123
[./constants.js] 87 bytes {1} [built]
2224
[./entry-2.js] ./entry-2.js + 2 modules 197 bytes {0} [built]
2325
| ./entry-2.js 67 bytes [built]
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
Hash: 1d3d6178be52f9ccfe79
1+
Hash: f4f2142b60f3f055cbd9
22
Time: Xms
3-
Asset Size Chunks Chunk Names
4-
entry.js 4.53 KiB entry [emitted] entry
5-
vendor.js 5.15 KiB vendor [emitted] vendor
6-
Entrypoint entry = vendor.js entry.js
7-
Entrypoint vendor = vendor.js
3+
Asset Size Chunks Chunk Names
4+
entry.js 425 bytes entry [emitted] entry
5+
manifest.js 4.66 KiB manifest [emitted] manifest
6+
vendor.js 469 bytes vendor [emitted] vendor
7+
Entrypoint entry = manifest.js vendor.js entry.js
8+
Entrypoint vendor = manifest.js vendor.js
89
[0] multi ./modules/a ./modules/b 40 bytes {vendor} [built]
910
[./entry.js] 72 bytes {entry} [built]
10-
[./modules/a.js] 22 bytes {vendor} {entry} [built]
11-
[./modules/b.js] 22 bytes {vendor} {entry} [built]
11+
[./modules/a.js] 22 bytes {vendor} [built]
12+
[./modules/b.js] 22 bytes {vendor} [built]
1213
[./modules/c.js] 22 bytes {entry} [built]

test/statsCases/scope-hoisting-multi/expected.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Hash: 87881f27c149dbb06ab313fe918f27661d9dca90
1+
Hash: 618d094d926d88426c4d89db4754cf89b4c9fcd6
22
Child
3-
Hash: 87881f27c149dbb06ab3
3+
Hash: 618d094d926d88426c4d
44
Time: Xms
55
Entrypoint vendor = vendor.js
66
Entrypoint first = vendor.js first.js
@@ -17,7 +17,7 @@ Child
1717
[9] ./module_first.js 31 bytes {3} [built]
1818
[10] ./second.js 177 bytes {4} [built]
1919
Child
20-
Hash: 13fe918f27661d9dca90
20+
Hash: 89db4754cf89b4c9fcd6
2121
Time: Xms
2222
Entrypoint vendor = vendor.js
2323
Entrypoint first = vendor.js first.js

0 commit comments

Comments
 (0)