build chunks on seal (fixes prefetching bug)

This commit is contained in:
Tobias Koppers 2013-05-22 10:12:53 +02:00
parent 44f8709fbd
commit 0870e00113
1 changed files with 14 additions and 7 deletions

View File

@ -29,6 +29,7 @@ function Compilation(compiler) {
this.bail = options && options.bail;
this.profile = options && options.profile;
this.entries = [];
this.preparedChunks = [];
this.chunks = [];
this.namedChunks = {};
this.modules = [];
@ -317,18 +318,15 @@ Compilation.prototype.addEntry = function process(context, entry, name, callback
if(err) return callback(err);
if(module) {
var chunk = this.addChunk(name);
chunk.id = 0;
chunk.entry = true;
chunk.addModule(module);
module.addChunk(chunk);
this.processDependenciesBlockForChunk(module, chunk);
this.preparedChunks.push({
name: name,
module: module
});
}
return callback();
}.bind(this));
};
Compilation.prototype.prefetch = function process(context, dependency, callback) {
this._addModuleChain(context, dependency, function(module) {
@ -339,6 +337,15 @@ Compilation.prototype.prefetch = function process(context, dependency, callback)
Compilation.prototype.seal = function seal(callback) {
this.applyPlugins("seal");
this.preparedChunks.forEach(function(preparedChunk) {
var module = preparedChunk.module;
var chunk = this.addChunk(preparedChunk.name);
chunk.id = 0;
chunk.entry = true;
chunk.addModule(module);
module.addChunk(chunk);
this.processDependenciesBlockForChunk(module, chunk);
}, this);
this.applyPlugins("optimize");
this.applyPlugins("optimize-modules", this.modules);
this.applyPlugins("after-optimize-modules", this.modules);