Skip to content

Commit

Permalink
Add support for Webpack 5 message objects (#10121)
Browse files Browse the repository at this point in the history
Co-authored-by: Brody McKee <mrmckeb@gmail.com>
  • Loading branch information
jasonwilliams and mrmckeb authored May 30, 2021
1 parent 7bdeced commit b172b5e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/react-dev-utils/formatWebpackMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,19 @@ function isLikelyASyntaxError(message) {

// Cleans up webpack error messages.
function formatMessage(message) {
let lines = message.split('\n');
let lines = [];

if (typeof message === 'string') {
lines = message.split('\n');
} else if ('message' in message) {
lines = message['message'].split('\n');
} else if (Array.isArray(message)) {
message.forEach(message => {
if ('message' in message) {
lines = message['message'].split('\n');
}
});
}

// Strip webpack-added headers off errors/warnings
// https://github.com/webpack/webpack/blob/master/lib/ModuleError.js
Expand Down

2 comments on commit b172b5e

@robaweb
Copy link

@robaweb robaweb commented on b172b5e Jul 5, 2021

Choose a reason for hiding this comment

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

Could someone please create a beta tag for the package react-dev-utils (npm, yarn) for this commit? There is only the tag 11.0.4 without these changes

@aeoncleanse
Copy link

Choose a reason for hiding this comment

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

Seconded. I could really use a beta release of react-dev-utils on npm with this fix enabled.

Please sign in to comment.