Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/react-dev-utils/WebpackDevServerUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,24 @@ 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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since it sorts in place, is it necessary to clone the array?

].sort((warning1, warning2) => {
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 warning1Time < warning2Time ? 1 : -1;
Comment on lines +146 to +154

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
].sort((warning1, warning2) => {
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 warning1Time < warning2Time ? 1 : -1;
].sort((...warnings) => {
const [a, b] = warnings.map(({ module: { resource } }) => (
compilation.fileTimestamps[resource] || fs.statSync(resource).mtime.getTime()
));
return a === b ? 0 : a < b ? 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 => {
Expand Down