Skip to content

Commit 153be56

Browse files
committed
keep commons chunk in mind when optimizing
1 parent 6c6e495 commit 153be56

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/Chunk.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Chunk.prototype.size = function(options) {
146146
}).reduce(function(a, b) {
147147
return a + b;
148148
}, 0);
149-
return modulesSize * (this.entry ? ENTRY_CHUNK_MULTIPLICATOR : 1) + CHUNK_OVERHEAD;
149+
return modulesSize * (this.id === 0 ? ENTRY_CHUNK_MULTIPLICATOR : 1) + CHUNK_OVERHEAD;
150150
};
151151

152152
Chunk.prototype.integratedSize = function(other, options) {
@@ -164,7 +164,7 @@ Chunk.prototype.integratedSize = function(other, options) {
164164
}).reduce(function(a, b) {
165165
return a + b;
166166
}, 0);
167-
return modulesSize * (this.entry || other.entry ? ENTRY_CHUNK_MULTIPLICATOR : 1) + CHUNK_OVERHEAD;
167+
return modulesSize * (this.id === 0 || other.id === 0 ? ENTRY_CHUNK_MULTIPLICATOR : 1) + CHUNK_OVERHEAD;
168168
};
169169

170170
Chunk.prototype.toString = function() {

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.entry;
15+
return c.id === 0;
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.entry;
49+
return p.id === 0;
5050
}).length;
5151
}
5252
function occurs(c) {

0 commit comments

Comments
 (0)