Skip to content

Commit 89fb178

Browse files
committed
add origin for used named chunks
1 parent 228486c commit 89fb178

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/Chunk.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ Chunk.prototype.addBlock = function(block) {
6868
return true;
6969
};
7070

71+
Chunk.prototype.addOrigin = function(module, loc) {
72+
this.origins.push({module: module, loc: loc, name: this.name});
73+
};
74+
7175
Chunk.prototype.remove = function(reason) {
7276
// console.log("remove " + this.toString());
7377
this.modules.slice().forEach(function(m) {

lib/Compilation.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,11 @@ Compilation.prototype.seal = function seal(callback) {
410410

411411
Compilation.prototype.addChunk = function addChunk(name, module, loc) {
412412
if(name) {
413-
if(Object.prototype.hasOwnProperty.call(this.namedChunks, name))
414-
return this.namedChunks[name];
413+
if(Object.prototype.hasOwnProperty.call(this.namedChunks, name)) {
414+
var chunk = this.namedChunks[name];
415+
if(module) chunk.addOrigin(module, loc);
416+
return chunk;
417+
}
415418
}
416419
var chunk = new Chunk(name, module, loc);
417420
this.chunks.push(chunk);

0 commit comments

Comments
 (0)