From f7d9cd8166ea73512acb0b603a3e09c2dc8b7b8e Mon Sep 17 00:00:00 2001 From: James Newell Date: Tue, 6 Dec 2016 09:58:36 +1100 Subject: [PATCH] Don't strip stack traces of evaluated webpack bundles (#1050) * Don't strip stack traces of evaluated webpack code * Strip stack traces at the end of a string because the last line doesn't always have a `\n` and `create-react-app` is leaving the last line of the stack traces present in the error messages * code comment * code comment --- packages/react-dev-utils/formatWebpackMessages.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/react-dev-utils/formatWebpackMessages.js b/packages/react-dev-utils/formatWebpackMessages.js index d72d5f734ca..c40691b7c6b 100644 --- a/packages/react-dev-utils/formatWebpackMessages.js +++ b/packages/react-dev-utils/formatWebpackMessages.js @@ -101,9 +101,12 @@ function formatMessage(message) { // Reassemble the message. message = lines.join('\n'); - // Internal stacks are generally useless so we strip them + // Internal stacks are generally useless so we strip them... with the + // exception of stacks containing `webpack:` because they're normally + // from user code generated by WebPack. For more information see + // https://github.com/facebookincubator/create-react-app/pull/1050 message = message.replace( - /^\s*at\s.*:\d+:\d+[\s\)]*\n/gm, '' + /^\s*at\s((?!webpack:).)*:\d+:\d+[\s\)]*(\n|$)/gm, '' ); // at ... ...:x:y return message;