add origin for used named chunks

This commit is contained in:
Tobias Koppers 2014-01-24 13:32:58 +01:00
parent 228486cfbe
commit 89fb178917
2 changed files with 9 additions and 2 deletions

View File

@ -68,6 +68,10 @@ Chunk.prototype.addBlock = function(block) {
return true;
};
Chunk.prototype.addOrigin = function(module, loc) {
this.origins.push({module: module, loc: loc, name: this.name});
};
Chunk.prototype.remove = function(reason) {
// console.log("remove " + this.toString());
this.modules.slice().forEach(function(m) {

View File

@ -410,8 +410,11 @@ Compilation.prototype.seal = function seal(callback) {
Compilation.prototype.addChunk = function addChunk(name, module, loc) {
if(name) {
if(Object.prototype.hasOwnProperty.call(this.namedChunks, name))
return this.namedChunks[name];
if(Object.prototype.hasOwnProperty.call(this.namedChunks, name)) {
var chunk = this.namedChunks[name];
if(module) chunk.addOrigin(module, loc);
return chunk;
}
}
var chunk = new Chunk(name, module, loc);
this.chunks.push(chunk);