Skip to content

Commit ca1c91c

Browse files
committed
Merge branch 'master' into next
# Conflicts: # lib/Chunk.js # lib/MainTemplate.js # test/statsCases/commons-chunk-min-size-0/expected.txt # test/statsCases/commons-plugin-issue-4980/expected.txt # test/statsCases/named-chunks-plugin/expected.txt
2 parents b33bead + b545b51 commit ca1c91c

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

lib/Chunk.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ class Chunk {
535535
return this.addMultiplierAndOverhead(integratedModulesSize, options);
536536
}
537537

538-
getChunkMaps(includeEntries, realHash) {
538+
getChunkMaps(includeInitial, realHash) {
539539
const chunkHashMap = Object.create(null);
540540
const chunkNameMap = Object.create(null);
541541

@@ -544,7 +544,7 @@ class Chunk {
544544

545545
while(queue.length > 0) {
546546
const chunk = queue.pop();
547-
if(!chunk.hasRuntime() || includeEntries) {
547+
if(!chunk.isInitial() || includeInitial) {
548548
chunkHashMap[chunk.id] = realHash ? chunk.hash : chunk.renderedHash;
549549
if(chunk.name)
550550
chunkNameMap[chunk.id] = chunk.name;

lib/MainTemplate.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ module.exports = class MainTemplate extends Tapable {
130130
});
131131
this.hooks.requireExtensions.tap("MainTemplate", (source, chunk, hash) => {
132132
const buf = [];
133-
if(chunk.getNumberOfChunks() > 0) {
133+
const chunkMaps = chunk.getChunkMaps();
134+
// Check if there are non initial chunks which need to be imported using require-ensure
135+
if(Object.keys(chunkMaps.hash).length) {
134136
buf.push("// This file contains only the entry chunk.");
135137
buf.push("// The chunk loading function for additional chunks");
136138
buf.push(`${this.requireFn}.e = function requireEnsure(chunkId) {`);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Hash: 96561e55e52ce5dd05d9
22
Time: Xms
33
Asset Size Chunks Chunk Names
44
entry-1.js 81 bytes 0 [emitted] entry-1
5-
vendor-1.js 8.01 KiB 1 [emitted] vendor-1
5+
vendor-1.js 5.62 KiB 1 [emitted] vendor-1
66
[0] ./modules/a.js 22 bytes {1} [built]
77
[1] ./modules/b.js 22 bytes {1} [built]
88
[2] ./modules/c.js 22 bytes {1} [built]

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Child
55
Asset Size Chunks Chunk Names
66
app.js 656 bytes 0 [emitted] app
77
vendor.1c0346d33a16fbee0579.js 619 bytes 1 [emitted] vendor
8-
runtime.js 7.04 KiB 2 [emitted] runtime
8+
runtime.js 4.65 KiB 2 [emitted] runtime
99
[./constants.js] 87 bytes {1} [built]
1010
[./entry-1.js] ./entry-1.js + 2 modules 190 bytes {0} [built]
1111
| ./entry-1.js 67 bytes [built]
@@ -17,7 +17,7 @@ Child
1717
Asset Size Chunks Chunk Names
1818
app.js 673 bytes 0 [emitted] app
1919
vendor.1c0346d33a16fbee0579.js 619 bytes 1 [emitted] vendor
20-
runtime.js 7.04 KiB 2 [emitted] runtime
20+
runtime.js 4.65 KiB 2 [emitted] runtime
2121
[./constants.js] 87 bytes {1} [built]
2222
[./entry-2.js] ./entry-2.js + 2 modules 197 bytes {0} [built]
2323
| ./entry-2.js 67 bytes [built]

test/statsCases/named-chunks-plugin/expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Hash: f4f2142b60f3f055cbd9
22
Time: Xms
33
Asset Size Chunks Chunk Names
44
entry.js 425 bytes entry [emitted] entry
5-
manifest.js 7.05 KiB manifest [emitted] manifest
5+
manifest.js 4.66 KiB manifest [emitted] manifest
66
vendor.js 469 bytes vendor [emitted] vendor
77
[0] multi ./modules/a ./modules/b 40 bytes {vendor} [built]
88
[./entry.js] 72 bytes {entry} [built]

0 commit comments

Comments
 (0)