Skip to content

Commit 769d40e

Browse files
committed
profile earlier and from cache
1 parent e9acc39 commit 769d40e

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

‎lib/Compilation.js‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ Compilation.prototype.processModuleDependencies = function(module, callback) {
162162
};
163163

164164
Compilation.prototype.addModuleDependencies = function(module, dependencies, bail, cacheGroup, recursive, callback) {
165+
var start = this.profile && +new Date();
166+
165167
var factories = [];
166168
for(var i = 0; i < dependencies.length; i++) {
167169
var factory = this.dependencyFactories.get(dependencies[i][0].Class);
@@ -199,7 +201,6 @@ Compilation.prototype.addModuleDependencies = function(module, dependencies, bai
199201
}.bind(this);
200202

201203
var factory = item[0];
202-
var start = this.profile && +new Date();
203204
factory.create(module.context, dependencies[0], function(err, dependantModule) {
204205
function isOptional() {
205206
return dependencies.filter(function(d) {
@@ -275,6 +276,11 @@ Compilation.prototype.addModuleDependencies = function(module, dependencies, bai
275276
dependantModule.addReason(module, dep);
276277
});
277278

279+
if(this.profile) {
280+
var afterBuilding = +new Date();
281+
module.profile.building = afterBuilding - afterFactory;
282+
}
283+
278284
if(recursive) {
279285
return this.processModuleDependencies(dependantModule, callback);
280286
} else {
@@ -317,6 +323,8 @@ Compilation.prototype.addModuleDependencies = function(module, dependencies, bai
317323
};
318324

319325
Compilation.prototype._addModuleChain = function process(context, dependency, onModule, callback) {
326+
var start = this.profile && +new Date();
327+
320328
var errorAndCallback = this.bail ? function errorAndCallback(err) {
321329
callback(err);
322330
} : function errorAndCallback(err) {
@@ -334,7 +342,6 @@ Compilation.prototype._addModuleChain = function process(context, dependency, on
334342
throw new Error("No dependency factory availible for this dependency type: " + dependency.Class.name);
335343
}
336344

337-
var start = this.profile && +new Date();
338345
moduleFactory.create(context, dependency, function(err, module) {
339346
if(err) {
340347
return errorAndCallback(new EntryModuleNotFoundError(err));
@@ -354,6 +361,11 @@ Compilation.prototype._addModuleChain = function process(context, dependency, on
354361

355362
onModule(module);
356363

364+
if(this.profile) {
365+
var afterBuilding = +new Date();
366+
module.profile.building = afterBuilding - afterFactory;
367+
}
368+
357369
return callback(null, module);
358370
}
359371

0 commit comments

Comments
 (0)