-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
react-scripts@2.0 takes forever to build #5068
Comments
I don’t think rewires are compatible with 2.x. AFAIK that project is not actively maintained anymore either. |
Unfortunately, removing any packages related to react-app-rewired and config-overrides.js didn't seem to work either. I've tried yarn build & yarn start but they both get stuck for hours. |
Could you please share this project? Hours seems quite excessive ... how are production build times the second build (without removing |
@Timer sorry, it's a private project, so I can't share it. Although I mentioned that it takes hours, in reality, I couldn't complete the production build. Because it takes over 3 hours stucking with "Creating an optimized..." message, so I just shut it down. The normal build time was ~950s, for react-scripts v1.1.5 + react-app-rewired. If I were to remove rewire packages, I would end up getting this error, which I think was caused by insufficient optimization in react-scripts v1. |
What is your rewired doing for you? |
Please try running |
I used rewired for uglifying and vendor splitting. Since react-scripts v1 seems to not support automatic vendor chunking without the latter library, I switched to react-scripts v2.0 to use webpack 4 features, including vendor splitting and terser (uglifyjs) plugin. |
I would definitely remove your rewire then with v2, it might be causing some bad configuration. Unfortunately, we're not going to be of much help unless if you can share the project with us privately. |
Thank @Timer, it's actually significantly faster when using react-scripts v1, down to ~600s. I'll try with react-scripts v2. It's my company's project, so unfortunately, I don't think sharing the project would be a good idea. |
You can try completely disabling Terser by temporarily commenting it out in the config. This will tell you whether it’s webpack or Terser that hangs. You can also try adding webpack’s built in ProfilerPlugin to trace its execution. |
Funnily enough, it looked like I was able to build successfully with source map disabled and no wires applied (react-scripts@2.0). The build time was reduced to just ~348s, much faster than what I would've expected. However, there's much more sub 1KB chunk files produced during the process, which I believe will hurt the performance. "yarn build" with source map enabled remains stuck, but let's see how long it will hang. |
Interesting, but how could you enable those configurations in the webpack config file without even ejecting and no rewires? I tried editing webpack.config.prod.js in the node_modules, but I don't think this is a viable option, because the file remains intact whenever I rebuild the project. |
Interesting, I'm happy to hear v2 is faster! Can you disable Terser and re-enable sourcemaps and see if the build completes? To edit config, I suggest you commit all changes, eject, and then revert the eject when you're done testing. |
Sorry, I only meant to suggest editing as a temporary way to try to diagnose the issue. It wouldn’t persist indeed. |
It's okay, looks like Terser isn't what causes the hang, the build still gets stuck even when I commented it out. Besides, for unknown reasons, In addition, I was wondering how I could apply other third libraries like ant design without using rewires. |
react-scripts@2.0.0-next.a671462c (previous version) works for me. I am using rewired and ant design. |
Does upgrading actually break compilation for you @superandrew213? Or are you just on the old version? |
@Timer just upgraded to latest react-scripts and react-app-rewired and everything works for me and nothing breaks. Build is as fast as v1. |
#5096 should make this better |
Closing since we were not given a reproducing project |
Recently, I upgraded a CRA project to the latest react-scripts v2 release (2.0.0-next.2150693d), and quickly realized that "yarn build" takes hours to build my project. Seems like it hangs at "Creating an optimized production build" for some reasons. That was quite unexpected since the previous version of react-scripts that I used (v1.1.5) could build the project just fine, though production build took a fairly long time (~15min).
FYI, before I was able to build, I had to manually update eslint to version 5.6.0, because react-scripts v2 requires it and a different version of eslint (3.9.1) detected higher up in the tree isn't compatible with react-scripts@2.0, sorta similar to this known issue. I guess this approach could prevent users from breaking react-scripts initial dev dependency? (link).
Environment
node -v:
v8.12.0npm -v
: v6.4.1yarn -v
: (if you use Yarn): v1.9.4Expected Behavior
yarn build succeeds
Actual Behavior
Get stuck at "Creating an optimized production build..." forever.
Reproducible Demo
Here's my package.json
The text was updated successfully, but these errors were encountered: