From a82ca6082c44791e2ca95e9b7e78e039bfd16f8f Mon Sep 17 00:00:00 2001 From: Vincent Lemeunier <vincentlemeunier+git@gmail.com> Date: Mon, 29 May 2017 23:32:28 +0200 Subject: [PATCH 1/2] Order lint warnings by most recently edited file (#2378) --- .../react-dev-utils/WebpackDevServerUtils.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packages/react-dev-utils/WebpackDevServerUtils.js b/packages/react-dev-utils/WebpackDevServerUtils.js index 51a0feb56..59d688474 100644 --- a/packages/react-dev-utils/WebpackDevServerUtils.js +++ b/packages/react-dev-utils/WebpackDevServerUtils.js @@ -139,6 +139,29 @@ function createCompiler(webpack, config, appName, urls, useYarn) { let isFirstCompile = true; + compiler.plugin('after-compile', (compilation, callback) => { + // Order compilation warnings by most recently modified + compilation.warnings = [ + ...compilation.warnings, + ].sort((warning1, warning2) => { + if (!warning1._lastModifiedDate) { + warning1._lastModifiedDate = fs.statSync( + warning1.module.resource + ).mtime; + } + + if (!warning2._lastModifiedDate) { + warning2._lastModifiedDate = fs.statSync( + warning2.module.resource + ).mtime; + } + + return warning1._lastModifiedDate < warning2._lastModifiedDate ? 1 : -1; + }); + + callback(); + }); + // "done" event fires when Webpack has finished recompiling the bundle. // Whether or not you have warnings or errors, you will get this event. compiler.plugin('done', stats => { -- GitLab From 8c9939adf26a0f4764bdeeca7e1c9dffc336cbfd Mon Sep 17 00:00:00 2001 From: Vincent Lemeunier <vincentlemeunier+git@gmail.com> Date: Fri, 30 Jun 2017 11:45:52 +0200 Subject: [PATCH 2/2] Use webpack stats if possible when sorting warnings --- .../react-dev-utils/WebpackDevServerUtils.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/packages/react-dev-utils/WebpackDevServerUtils.js b/packages/react-dev-utils/WebpackDevServerUtils.js index 59d688474..c7e2561c3 100644 --- a/packages/react-dev-utils/WebpackDevServerUtils.js +++ b/packages/react-dev-utils/WebpackDevServerUtils.js @@ -144,19 +144,14 @@ function createCompiler(webpack, config, appName, urls, useYarn) { compilation.warnings = [ ...compilation.warnings, ].sort((warning1, warning2) => { - if (!warning1._lastModifiedDate) { - warning1._lastModifiedDate = fs.statSync( - warning1.module.resource - ).mtime; - } - - if (!warning2._lastModifiedDate) { - warning2._lastModifiedDate = fs.statSync( - warning2.module.resource - ).mtime; - } + const warning1Time = compilation.fileTimestamps[ + warning1.module.resource + ] || fs.statSync(warning1.module.resource).mtime.getTime(); + const warning2Time = compilation.fileTimestamps[ + warning2.module.resource + ] || fs.statSync(warning2.module.resource).mtime.getTime(); - return warning1._lastModifiedDate < warning2._lastModifiedDate ? 1 : -1; + return warning1Time < warning2Time ? 1 : -1; }); callback(); -- GitLab