Skip to content

Commit 604b49f

Browse files
onigoetzJohnNilsson
authored andcommitted
Make formatWebpackMessages return all messages (#2834)
* Move the reduction of the messages to a single place in the place it is used. * Fix variable name
1 parent a295a9e commit 604b49f

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

packages/react-dev-utils/WebpackDevServerUtils.js

+5
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ function createCompiler(webpack, config, appName, urls, useYarn) {
164164

165165
// If errors exist, only show errors.
166166
if (messages.errors.length) {
167+
// Only keep the first error. Others are often indicative
168+
// of the same problem, but confuse the reader with noise.
169+
if (messages.errors.length > 1) {
170+
messages.errors.length = 1;
171+
}
167172
console.log(chalk.red('Failed to compile.\n'));
168173
console.log(messages.errors.join('\n\n'));
169174
return;

packages/react-dev-utils/formatWebpackMessages.js

-5
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,6 @@ function formatWebpackMessages(json) {
121121
// preceding a much more useful Babel syntax error.
122122
result.errors = result.errors.filter(isLikelyASyntaxError);
123123
}
124-
// Only keep the first error. Others are often indicative
125-
// of the same problem, but confuse the reader with noise.
126-
if (result.errors.length > 1) {
127-
result.errors.length = 1;
128-
}
129124
return result;
130125
}
131126

packages/react-scripts/scripts/build.js

+5
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ function build(previousFileSizes) {
122122
}
123123
const messages = formatWebpackMessages(stats.toJson({}, true));
124124
if (messages.errors.length) {
125+
// Only keep the first error. Others are often indicative
126+
// of the same problem, but confuse the reader with noise.
127+
if (messages.errors.length > 1) {
128+
messages.errors.length = 1;
129+
}
125130
return reject(new Error(messages.errors.join('\n\n')));
126131
}
127132
if (

0 commit comments

Comments
 (0)