Skip to content

Commit

Permalink
Merge pull request #4791 from deificx/master
Browse files Browse the repository at this point in the history
add option to lib/Stats.js to disable stack trace on errors and warnings
  • Loading branch information
sokra committed Apr 30, 2017
2 parents 94ba75f + 84ea1ff commit c91ba49
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class Stats {
const showProvidedExports = optionOrFallback(options.providedExports, !forToString);
const showChildren = optionOrFallback(options.children, true);
const showSource = optionOrFallback(options.source, !forToString);
const showModuleTrace = optionOrFallback(options.moduleTrace, true);
const showErrors = optionOrFallback(options.errors, true);
const showErrorDetails = optionOrFallback(options.errorDetails, !forToString);
const showWarnings = optionOrFallback(options.warnings, true);
Expand Down Expand Up @@ -164,7 +165,7 @@ class Stats {
text += e.message;
if(showErrorDetails && e.details) text += `\n${e.details}`;
if(showErrorDetails && e.missing) text += e.missing.map(item => `\n[${item}]`).join("");
if(e.dependencies && e.origin) {
if(showModuleTrace && e.dependencies && e.origin) {
text += `\n @ ${e.origin.readableIdentifier(requestShortener)}`;
e.dependencies.forEach(dep => {
if(!dep.loc) return;
Expand Down
4 changes: 4 additions & 0 deletions schemas/webpackOptionsSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,10 @@
"type": "string",
"description": "sort the modules by that field"
},
"moduleTrace": {
"type": "boolean",
"description": "add dependencies and origin of warnings/errors"
},
"chunksSort": {
"type": "string",
"description": "sort the chunks by that field"
Expand Down
9 changes: 9 additions & 0 deletions test/statsCases/module-trace-disabled-in-error/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Hash: 6e950f2e83663cb6e9a6
Time: Xms
Asset Size Chunks Chunk Names
main.js 2.81 kB 0 [emitted] main
chunk {0} main.js (main) 25 bytes [entry] [rendered]
[0] (webpack)/test/statsCases/module-trace-disabled-in-error/index.js 25 bytes {0} [built]

ERROR in (webpack)/test/statsCases/module-trace-disabled-in-error/index.js
Module not found: Error: Can't resolve 'does-not-exist' in 'Xdir/module-trace-disabled-in-error'
1 change: 1 addition & 0 deletions test/statsCases/module-trace-disabled-in-error/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require('does-not-exist')
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
entry: "./index",
stats: {
moduleTrace: false
}
};
10 changes: 10 additions & 0 deletions test/statsCases/module-trace-enabled-in-error/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Hash: 6e950f2e83663cb6e9a6
Time: Xms
Asset Size Chunks Chunk Names
main.js 2.81 kB 0 [emitted] main
chunk {0} main.js (main) 25 bytes [entry] [rendered]
[0] (webpack)/test/statsCases/module-trace-enabled-in-error/index.js 25 bytes {0} [built]

ERROR in (webpack)/test/statsCases/module-trace-enabled-in-error/index.js
Module not found: Error: Can't resolve 'does-not-exist' in 'Xdir/module-trace-enabled-in-error'
@ (webpack)/test/statsCases/module-trace-enabled-in-error/index.js 1:0-25
1 change: 1 addition & 0 deletions test/statsCases/module-trace-enabled-in-error/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require('does-not-exist')
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
entry: "./index",
stats: {
moduleTrace: true
}
};

0 comments on commit c91ba49

Please sign in to comment.