WSL react-scripts build hangs when terser parallel is true
Created by: agilecollab
Is this a bug report?
Yes, this bug affecting use with react-create-app on WSL systems
Did you try recovering your dependencies?
Yes Yarn version 1.13.0
Which terms did you search for in User Guide?
webpack hang wsl terser parallel
Environment
Environment Info:
System: OS: Linux 4.4 Ubuntu 18.04.1 LTS (Bionic Beaver) CPU: x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz Binaries: Node: 10.13.0 - ~/.nvm/versions/node/v10.13.0/bin/node Yarn: 1.13.0 - /usr/bin/yarn npm: 6.4.1 - ~/.nvm/versions/node/v10.13.0/bin/npm npmPackages: react: ^16.7.0 => 16.8.5 react-dom: ^16.7.0 => 16.8.5 react-scripts: 2.1.1 => 2.1.1 npmGlobalPackages: create-react-app: Not Found
Steps to Reproduce
(Write your steps here:)
- setup WSL
- run
yarn build
in project with code splitting; wasn't an issue until we introduced code splitting
Expected Behavior
Expected yarn build to complete or throw an error.
Actual Behavior
Yarn build hangs during webpack build. Last output we see from react-scripts build is "Creating an optimized production build... "
After review, this is caused by webpack TerserPlugin. It appears that WSL has issue with running TerserPlugin with parallel configuration property set to true.
Temporary Fix:
To those that may be affected by this issue, you can update .node_modules/react-scripts/config/webpack.config.prod.js
and set the TerserPlugin config option parallel to false.
Suggested Fix: Add environment variable check to determine if Terser should run in parallel:
const shouldTerserRunParallel = process.env.TERSER_PARALLEL !== 'false';
Reproducible Demo
Issue has been seen with other projects using TerserPlugin on WSL: https://github.com/gatsbyjs/gatsby/pull/12636