facebook / create-react-app

Set up a modern web app by running one command.
https://create-react-app.dev
MIT License
102.73k stars 26.85k forks source link

Failed to compile message without any detail. #5008

Closed RIP21 closed 6 years ago

RIP21 commented 6 years ago

This is issue created for discussing fix of the weird common Alphas 2.0.0 error that looks like that: https://user-images.githubusercontent.com/616428/41606667-3591d1de-73b2-11e8-8b19-3b571b63a592.png

I did some research trying to find the root cause and it seems that I found it.

Seems to be an issue in formatWebpackMessages.js

// Remove unnecessary stack added by `thread-loader`
  var threadLoaderIndex = -1;
  lines.forEach(function(line, index) {
    if (threadLoaderIndex !== -1) {
      return;
    }
    if (/thread.loader/i.test(line)) {
      threadLoaderIndex = index;
    }
  });

  if (threadLoaderIndex !== -1) {
    lines = lines.slice(0, threadLoaderIndex);
  }

This piece is deletes everything after 'thread-loader'. So when you have an error or warning it will be striped out to the path only. So message like that:

./src/elements/FormSignIn/index.js
Module Warning (from ./node_modules/thread-loader/dist/cjs.js): <<<< Takes this line index

/Users/andriilos/Projects/<annon>/<annon>/src/elements/FormSignIn/index.js
  6:13  warning  'UI' is defined but never used              no-unused-vars
  9:7   warning  'sleep' is assigned a value but never used  no-unused-vars

✖ 2 problems (0 errors, 2 warnings)

 @ ./src/pages/SignIn/index.js 1:2249-2293 1:3910-3920
 @ ./src/App.js
 @ ./src/index.js
 @ multi ./node_modules/revolut-react-scripts/config/polyfills.js ./src/index.js <<< removes all till that line

End up like:

./src/elements/FormSignIn/index.js

So effectively changing

  if (threadLoaderIndex !== -1) {
    lines = lines.slice(0, threadLoaderIndex);
  }

to

  if (threadLoaderIndex !== -1) {
    lines.splice(threadLoaderIndex, 1);
  }

May fix this, I'm not sure about other errors and warnings formats so a little discussion will be a nice thing to do before I open a PR if you like.

RIP21 commented 6 years ago

The resulted error message is not ideal, but way better than nothing.

./src/elements/FormSignIn/index.js << This is not ideal, since it's unneeded repetition.

/Users/andriilos/Projects/<annon>/<annon>/src/elements/FormSignIn/index.js
  6:13  warning  'UI' is defined but never used              no-unused-vars
  9:7   warning  'sleep' is assigned a value but never used  no-unused-vars

✖ 2 problems (0 errors, 2 warnings)

RIP21 commented 6 years ago

I opened PR #5009 If anyone has any suggestion please let me know.

Timer commented 6 years ago

This is now fixed on next, there were tons of edge cases we needed to consider. Thanks for the report!