From 604b49fa1d7e155398c69c278b04549ed2e4e4af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Goetz?= Date: Wed, 9 Aug 2017 03:37:04 +0200 Subject: [PATCH] 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 --- packages/react-dev-utils/WebpackDevServerUtils.js | 5 +++++ packages/react-dev-utils/formatWebpackMessages.js | 5 ----- packages/react-scripts/scripts/build.js | 5 +++++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/react-dev-utils/WebpackDevServerUtils.js b/packages/react-dev-utils/WebpackDevServerUtils.js index f9957aaa3..bb4a8c790 100644 --- a/packages/react-dev-utils/WebpackDevServerUtils.js +++ b/packages/react-dev-utils/WebpackDevServerUtils.js @@ -164,6 +164,11 @@ function createCompiler(webpack, config, appName, urls, useYarn) { // If errors exist, only show errors. if (messages.errors.length) { + // Only keep the first error. Others are often indicative + // of the same problem, but confuse the reader with noise. + if (messages.errors.length > 1) { + messages.errors.length = 1; + } console.log(chalk.red('Failed to compile.\n')); console.log(messages.errors.join('\n\n')); return; diff --git a/packages/react-dev-utils/formatWebpackMessages.js b/packages/react-dev-utils/formatWebpackMessages.js index 5dfd099c6..a5176b920 100644 --- a/packages/react-dev-utils/formatWebpackMessages.js +++ b/packages/react-dev-utils/formatWebpackMessages.js @@ -121,11 +121,6 @@ function formatWebpackMessages(json) { // preceding a much more useful Babel syntax error. result.errors = result.errors.filter(isLikelyASyntaxError); } - // Only keep the first error. Others are often indicative - // of the same problem, but confuse the reader with noise. - if (result.errors.length > 1) { - result.errors.length = 1; - } return result; } diff --git a/packages/react-scripts/scripts/build.js b/packages/react-scripts/scripts/build.js index 5ad12ab12..7691bfd52 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -122,6 +122,11 @@ function build(previousFileSizes) { } const messages = formatWebpackMessages(stats.toJson({}, true)); if (messages.errors.length) { + // Only keep the first error. Others are often indicative + // of the same problem, but confuse the reader with noise. + if (messages.errors.length > 1) { + messages.errors.length = 1; + } return reject(new Error(messages.errors.join('\n\n'))); } if (