Skip to content

Commit 79eb404

Browse files
committed
1 parent bc29455 commit 79eb404

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

lib/Chunk.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,13 @@ Chunk.prototype.integrate = function(other, reason) {
209209
} else if(origin.reasons[0] !== reason) {
210210
origin.reasons.unshift(reason);
211211
}
212-
})
212+
});
213+
this.chunks = this.chunks.filter(function(c) {
214+
return c !== other && c !== this;
215+
});
216+
this.parents = this.parents.filter(function(c) {
217+
return c !== other && c !== this;
218+
});
213219
return true;
214220
};
215221

@@ -331,3 +337,19 @@ Chunk.prototype.sortItems = function() {
331337
Chunk.prototype.toString = function() {
332338
return "Chunk[" + this.modules.join() + "]";
333339
};
340+
341+
Chunk.prototype.checkConstraints = function() {
342+
var chunk = this;
343+
chunk.chunks.forEach(function(child, idx) {
344+
if(chunk.chunks.indexOf(child) !== idx)
345+
console.log("checkConstraints: duplicate child in chunk", chunk.debugId, child.debugId);
346+
if(child.parents.indexOf(chunk) < 0)
347+
console.log("checkConstraints: child missing parent", chunk.debugId, "->", child.debugId);
348+
});
349+
chunk.parents.forEach(function(parent, idx) {
350+
if(chunk.parents.indexOf(parent) !== idx)
351+
console.log("checkConstraints: duplicate parent in chunk", chunk.debugId, parent.debugId);
352+
if(parent.chunks.indexOf(chunk) < 0)
353+
console.log("checkConstraints: parent missing child", parent.debugId, "<-", chunk.debugId);
354+
});
355+
};

lib/Compilation.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,3 +948,11 @@ Compilation.prototype.getStats = function() {
948948
Compilation.prototype.createChildCompiler = function(name, outputOptions) {
949949
return this.compiler.createChildCompiler(this, name, outputOptions);
950950
};
951+
952+
Compilation.prototype.checkConstraints = function() {
953+
this.chunks.forEach(function(chunk, idx) {
954+
if(this.chunks.indexOf(chunk) !== idx)
955+
console.log("checkConstraints: duplicate chunk in compilation", chunk.debugId);
956+
chunk.checkConstraints();
957+
}.bind(this));
958+
};

lib/optimize/CommonsChunkPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ CommonsChunkPlugin.prototype.apply = function(compiler) {
168168
chunk.entrypoints.forEach(function(ep) {
169169
ep.insertChunk(commonChunk, chunk);
170170
});
171-
commonChunk.chunks.push(chunk);
171+
commonChunk.addChunk(chunk);
172172
});
173173
}
174174
if(filenameTemplate)

0 commit comments

Comments
 (0)