Skip to content

Commit c91ba49

Browse files
authored
Merge pull request webpack#4791 from deificx/master
add option to lib/Stats.js to disable stack trace on errors and warnings
2 parents 94ba75f + 84ea1ff commit c91ba49

File tree

8 files changed

+39
-1
lines changed

8 files changed

+39
-1
lines changed

lib/Stats.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class Stats {
9595
const showProvidedExports = optionOrFallback(options.providedExports, !forToString);
9696
const showChildren = optionOrFallback(options.children, true);
9797
const showSource = optionOrFallback(options.source, !forToString);
98+
const showModuleTrace = optionOrFallback(options.moduleTrace, true);
9899
const showErrors = optionOrFallback(options.errors, true);
99100
const showErrorDetails = optionOrFallback(options.errorDetails, !forToString);
100101
const showWarnings = optionOrFallback(options.warnings, true);
@@ -164,7 +165,7 @@ class Stats {
164165
text += e.message;
165166
if(showErrorDetails && e.details) text += `\n${e.details}`;
166167
if(showErrorDetails && e.missing) text += e.missing.map(item => `\n[${item}]`).join("");
167-
if(e.dependencies && e.origin) {
168+
if(showModuleTrace && e.dependencies && e.origin) {
168169
text += `\n @ ${e.origin.readableIdentifier(requestShortener)}`;
169170
e.dependencies.forEach(dep => {
170171
if(!dep.loc) return;

schemas/webpackOptionsSchema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,10 @@
993993
"type": "string",
994994
"description": "sort the modules by that field"
995995
},
996+
"moduleTrace": {
997+
"type": "boolean",
998+
"description": "add dependencies and origin of warnings/errors"
999+
},
9961000
"chunksSort": {
9971001
"type": "string",
9981002
"description": "sort the chunks by that field"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Hash: 6e950f2e83663cb6e9a6
2+
Time: Xms
3+
Asset Size Chunks Chunk Names
4+
main.js 2.81 kB 0 [emitted] main
5+
chunk {0} main.js (main) 25 bytes [entry] [rendered]
6+
[0] (webpack)/test/statsCases/module-trace-disabled-in-error/index.js 25 bytes {0} [built]
7+
8+
ERROR in (webpack)/test/statsCases/module-trace-disabled-in-error/index.js
9+
Module not found: Error: Can't resolve 'does-not-exist' in 'Xdir/module-trace-disabled-in-error'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('does-not-exist')
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
entry: "./index",
3+
stats: {
4+
moduleTrace: false
5+
}
6+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Hash: 6e950f2e83663cb6e9a6
2+
Time: Xms
3+
Asset Size Chunks Chunk Names
4+
main.js 2.81 kB 0 [emitted] main
5+
chunk {0} main.js (main) 25 bytes [entry] [rendered]
6+
[0] (webpack)/test/statsCases/module-trace-enabled-in-error/index.js 25 bytes {0} [built]
7+
8+
ERROR in (webpack)/test/statsCases/module-trace-enabled-in-error/index.js
9+
Module not found: Error: Can't resolve 'does-not-exist' in 'Xdir/module-trace-enabled-in-error'
10+
@ (webpack)/test/statsCases/module-trace-enabled-in-error/index.js 1:0-25
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('does-not-exist')
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
entry: "./index",
3+
stats: {
4+
moduleTrace: true
5+
}
6+
};

0 commit comments

Comments
 (0)