Skip to content

Commit 1133a56

Browse files
committed
better error reporting
1 parent 5514935 commit 1133a56

File tree

4 files changed

+43
-43
lines changed

4 files changed

+43
-43
lines changed

lib/Compilation.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ Compilation.prototype.buildModule = function(module, callback) {
9595
this.warnings.push(err);
9696
}, this);
9797
if(err) {
98+
module.error = err;
9899
this.applyPlugins("failed-module", module);
99100
return callback(err);
100101
}
@@ -144,12 +145,14 @@ Compilation.prototype.processModuleDependencies = function(module, callback) {
144145
var errorAndCallback = function errorAndCallback(err) {
145146
err.dependencies = dependencies;
146147
err.origin = module;
148+
module.dependenciesErrors.push(err);
147149
this.errors.push(err);
148150
callback();
149151
}.bind(this);
150152
var warningAndCallback = function warningAndCallback(err) {
151153
err.dependencies = dependencies;
152154
err.origin = module;
155+
module.dependenciesWarnings.push(err);
153156
this.warnings.push(err);
154157
callback();
155158
}.bind(this);
@@ -210,14 +213,14 @@ Compilation.prototype.processModuleDependencies = function(module, callback) {
210213
return this.processModuleDependencies(dependantModule, callback);
211214
}
212215

216+
dependencies.forEach(function(dep) {
217+
dep.module = dependantModule;
218+
dependantModule.addReason(module, dep);
219+
});
220+
213221
this.buildModule(dependantModule, function(err) {
214222
if(err) return errorOrWarningAndCallback(err);
215223

216-
dependencies.forEach(function(dep) {
217-
dep.module = dependantModule;
218-
dependantModule.addReason(module, dep);
219-
});
220-
221224
if(this.profile) {
222225
var afterBuilding = +new Date();
223226
dependantModule.profile.building = afterBuilding - afterFactory;

lib/Module.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ function Module() {
1515
this.id = null;
1616
this.chunks = [];
1717
this.warnings = [];
18+
this.dependenciesWarnings = [];
1819
this.errors = [];
20+
this.dependenciesErrors = [];
1921
}
2022
module.exports = Module;
2123

lib/Stats.js

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ Stats.prototype.toJson = function toJson(options, forToString) {
119119
return chunk.id;
120120
}),
121121
issuer: module.issuer,
122-
profile: module.profile
122+
profile: module.profile,
123+
failed: !!module.error,
124+
errors: module.errors && module.dependenciesErrors && (module.errors.length + module.dependenciesErrors.length),
125+
warnings: module.errors && module.dependenciesErrors && (module.warnings.length + module.dependenciesWarnings.length)
123126
};
124127
if(showReasons) {
125128
obj.reasons = module.reasons.filter(function(reason) {
@@ -363,6 +366,32 @@ Stats.jsonToString = function jsonToString(obj, useColors) {
363366
newline();
364367
}
365368
}
369+
function processModuleAttributes(module) {
370+
normal(" ");
371+
normal(module.size);
372+
if(module.chunks) {
373+
module.chunks.forEach(function(chunk) {
374+
normal(" {");
375+
yellow(chunk);
376+
normal("}");
377+
});
378+
}
379+
if(!module.cacheable) {
380+
red(" [not cacheable]");
381+
}
382+
if(module.built) {
383+
green(" [built]");
384+
}
385+
if(module.prefetched) {
386+
magenta(" [prefetched]");
387+
}
388+
if(module.failed)
389+
red(" [failed]");
390+
if(module.warnings)
391+
yellow(" [" + module.warnings + " warning"+(module.warnings == 1 ? "": "s")+"]");
392+
if(module.errors)
393+
red(" [" + module.errors + " error"+(module.errors == 1 ? "": "s")+"]");
394+
}
366395
if(obj.chunks) {
367396
obj.chunks.forEach(function(chunk) {
368397
normal("chunk ");
@@ -399,24 +428,7 @@ Stats.jsonToString = function jsonToString(obj, useColors) {
399428
normal(module.id);
400429
normal("] ");
401430
bold(module.name);
402-
normal(" ");
403-
normal(module.size);
404-
if(!module.cacheable) {
405-
red(" [not cacheable]");
406-
}
407-
if(module.built) {
408-
green(" [built]");
409-
}
410-
if(module.prefetched) {
411-
magenta(" [prefetched]");
412-
}
413-
if(module.chunks) {
414-
module.chunks.forEach(function(chunk) {
415-
normal(" {");
416-
yellow(chunk);
417-
normal("}");
418-
});
419-
}
431+
processModuleAttributes(module);
420432
newline();
421433
if(module.reasons) {
422434
module.reasons.forEach(function(reason) {
@@ -449,24 +461,7 @@ Stats.jsonToString = function jsonToString(obj, useColors) {
449461
normal(module.id);
450462
normal("] ");
451463
(module.size >= 0 ? bold : normal)(module.name);
452-
normal(" ");
453-
normal(module.size);
454-
if(!module.cacheable) {
455-
red(" [not cacheable]");
456-
}
457-
if(module.built) {
458-
green(" [built]");
459-
}
460-
if(module.prefetched) {
461-
magenta(" [prefetched]");
462-
}
463-
if(module.chunks) {
464-
module.chunks.forEach(function(chunk) {
465-
normal(" {");
466-
yellow(chunk);
467-
normal("}");
468-
});
469-
}
464+
processModuleAttributes(module);
470465
newline();
471466
if(module.reasons) {
472467
module.reasons.forEach(function(reason) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpack",
3-
"version": "0.10.0-beta14",
3+
"version": "0.10.0-beta15",
44
"author": "Tobias Koppers @sokra",
55
"description": "Packs CommonJs/AMD/Labeled Modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jade, coffee, css, less, ... and your custom stuff.",
66
"dependencies": {

0 commit comments

Comments
 (0)