Skip to content

Commit 1fa9169

Browse files
committed
use initial flag for initial loaded chunks
1 parent cc8bfaa commit 1fa9169

File tree

5 files changed

+10
-8
lines changed

5 files changed

+10
-8
lines changed

lib/BannerPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ BannerPlugin.prototype.apply = function(compiler) {
2121
compiler.plugin("compilation", function(compilation) {
2222
compilation.plugin("optimize-chunk-assets", function(chunks, callback) {
2323
chunks.forEach(function(chunk) {
24-
if(entryOnly && !chunk.entry) return;
24+
if(entryOnly && !chunk.initial) return;
2525
chunk.files.forEach(function(file) {
2626
compilation.assets[file] = new ConcatSource(banner, "\n", compilation.assets[file]);
2727
});

lib/Chunk.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ function Chunk(name) {
1111
this.parents = [];
1212
this.blocks = [];
1313
this.rendered = false;
14+
this.entry = false;
15+
this.initial = false;
1416
}
1517
module.exports = Chunk;
1618

@@ -146,7 +148,7 @@ Chunk.prototype.size = function(options) {
146148
}).reduce(function(a, b) {
147149
return a + b;
148150
}, 0);
149-
return modulesSize * (this.id === 0 ? ENTRY_CHUNK_MULTIPLICATOR : 1) + CHUNK_OVERHEAD;
151+
return modulesSize * (this.initial ? ENTRY_CHUNK_MULTIPLICATOR : 1) + CHUNK_OVERHEAD;
150152
};
151153

152154
Chunk.prototype.integratedSize = function(other, options) {
@@ -164,7 +166,7 @@ Chunk.prototype.integratedSize = function(other, options) {
164166
}).reduce(function(a, b) {
165167
return a + b;
166168
}, 0);
167-
return modulesSize * (this.id === 0 || other.id === 0 ? ENTRY_CHUNK_MULTIPLICATOR : 1) + CHUNK_OVERHEAD;
169+
return modulesSize * (this.initial || other.initial ? ENTRY_CHUNK_MULTIPLICATOR : 1) + CHUNK_OVERHEAD;
168170
};
169171

170172
Chunk.prototype.toString = function() {

lib/Compilation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ Compilation.prototype.seal = function seal(callback) {
360360
var module = preparedChunk.module;
361361
var chunk = this.addChunk(preparedChunk.name);
362362
chunk.id = 0;
363-
chunk.entry = true;
363+
chunk.initial = chunk.entry = true;
364364
chunk.addModule(module);
365365
module.addChunk(chunk);
366366
this.processDependenciesBlockForChunk(module, chunk);
@@ -575,7 +575,7 @@ Compilation.prototype.createChunkAssets = function createChunkAssets() {
575575
var source;
576576
var file;
577577
var filenameTemplate = chunk.filenameTemplate ? chunk.filenameTemplate :
578-
chunk.id === 0 ? filename :
578+
chunk.initial ? filename :
579579
chunkFilename;
580580
if(chunk.entry) {
581581
if(this.cache && this.cache["c" + chunk.id + chunk.name] && this.cache["c" + chunk.id + chunk.name].hash == this.fullHash) {

lib/optimize/CommonsChunkPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ CommonsChunkPlugin.prototype.apply = function(compiler) {
5252
commonChunk.chunks.push(chunk);
5353
chunk.entry = false;
5454
});
55-
commonChunk.entry = true;
55+
commonChunk.initial = commonChunk.entry = true;
5656
commonChunk.filenameTemplate = filenameTemplate;
5757
});
5858
});

lib/optimize/OccurenceOrderPlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ OccurenceOrderPlugin.prototype.apply = function(compiler) {
1212
compilation.plugin("optimize-module-order", function(modules) {
1313
function entryChunks(m) {
1414
return m.chunks.filter(function(c) {
15-
return c.id === 0;
15+
return c.initial;
1616
}).length;
1717
}
1818
function occursInEntry(m) {
@@ -46,7 +46,7 @@ OccurenceOrderPlugin.prototype.apply = function(compiler) {
4646
compilation.plugin("optimize-chunk-order", function(chunks) {
4747
function occursInEntry(c) {
4848
return c.parents.filter(function(p) {
49-
return p.id === 0;
49+
return p.initial;
5050
}).length;
5151
}
5252
function occurs(c) {

0 commit comments

Comments
 (0)