From 93691f7f97619627ec32510acb60a1fb9b6c3f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Goetz?= Date: Fri, 21 Jul 2017 21:30:49 +0200 Subject: [PATCH 1/2] Move the reduction of the messages to a single place in the place it is used. --- 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 8a66b15ec0c..83087191d30 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 (result.errors.length > 1) { + result.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 5dfd099c65c..a5176b92049 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 b9b65f5313d..c2aa78dcd50 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -121,6 +121,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 ( From 361029088e34e1c4006914e65ad5ebe1b200f736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Goetz?= Date: Fri, 21 Jul 2017 22:05:49 +0200 Subject: [PATCH 2/2] Fix variable name --- packages/react-dev-utils/WebpackDevServerUtils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-dev-utils/WebpackDevServerUtils.js b/packages/react-dev-utils/WebpackDevServerUtils.js index 83087191d30..1cd060592f9 100644 --- a/packages/react-dev-utils/WebpackDevServerUtils.js +++ b/packages/react-dev-utils/WebpackDevServerUtils.js @@ -166,8 +166,8 @@ function createCompiler(webpack, config, appName, urls, useYarn) { if (messages.errors.length) { // 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; + if (messages.errors.length > 1) { + messages.errors.length = 1; } console.log(chalk.red('Failed to compile.\n')); console.log(messages.errors.join('\n\n'));