Skip to content

Commit 85accfa

Browse files
samal-rasmussenjantimon
authored andcommitted
Add stacktrace to error message from childCompilation.errors
I was had an error that was thrown in my webpack.config.ts that was causing childCompilation to fail. But I didn't know it was an error thrown in my webpack.config.ts because child-compiler.js didn't include the stack trace in the error message. The stack trace I got ended at line 122 in node_modules\html-webpack-plugin\lib\child-compiler.js. So I fiddled with that to make it output the inner error stack trace and then I got the actual place of the error.
1 parent d051f5f commit 85accfa

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/child-compiler.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,16 @@ class HtmlWebpackChildCompiler {
118118
}
119119
// Reject the promise if the childCompilation contains error
120120
if (childCompilation && childCompilation.errors && childCompilation.errors.length) {
121-
const errorDetails = childCompilation.errors.map(error => error.message + (error.error ? ':\n' + error.error : '')).join('\n');
121+
const errorDetails = childCompilation.errors.map(error => {
122+
let message = error.message;
123+
if (error.error) {
124+
message += ':\n' + error.error;
125+
}
126+
if (error.stack) {
127+
message += '\n' + error.stack;
128+
}
129+
return message;
130+
}).join('\n');
122131
reject(new Error('Child compilation failed:\n' + errorDetails));
123132
return;
124133
}

0 commit comments

Comments
 (0)