-
-
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
Slow compilation still after upgrade to new version 4.0.1 #10154
Comments
I concur. I have upgraded to 4.0.1 (using Typescript 4.1.2). Initial compile times are better. But each time I modify a single tsx file, the diff re-"Compiling..." cycle is taking way longer than pre v4. Previously it takes around 2-3 seconds to reflect in browser, now it takes upwards of 15 seconds. I tried with both setting in .env file FAST_REFRESH = true and false, no difference. |
I have the same issue. Extremely slow compile and recompile times. I tried measuring the compile time with https://github.com/stephencookdev/speed-measure-webpack-plugin to see what's so slow. This is my benchmark: Unfortunately I couldn't run it on re-compile after a file update because apparently it breaks. Might have something to do with stephencookdev/speed-measure-webpack-plugin#44 But, it's extremely slow lol. And also the discussions (like this - #9909) aren't very helpful |
Did you guys notice any slow build time as well? |
@ahrbil could you detail your issues some more about the CI? I encountered the same issue today. Build keeps timing out (even though it's already built the static files!): |
I tried to debug my app using
You can try if it works in your case by commenting out the plugin in As a temporary solution you can use module.exports = (config) => {
config.plugins = config.plugins.filter(
(plugin) => !(plugin.options && plugin.options.eslintPath)
);
return config;
}; |
@maxsbelt Thanks, the speeds after that change are amazing, just a couple of seconds for initial compilation and 1s for recompilation. Here's a patch for those using diff --git a/node_modules/react-scripts/config/webpack.config.js b/node_modules/react-scripts/config/webpack.config.js
index eddca1b..954abe9 100644
--- a/node_modules/react-scripts/config/webpack.config.js
+++ b/node_modules/react-scripts/config/webpack.config.js
@@ -750,7 +750,7 @@ module.exports = function (webpackEnv) {
// The formatter is invoked directly in WebpackDevServerUtils during development
formatter: isEnvProduction ? typescriptFormatter : undefined,
}),
- new ESLintPlugin({
+ isEnvProduction && new ESLintPlugin({
// Plugin options
extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
formatter: require.resolve('react-dev-utils/eslintFormatter'), |
Not worked for me |
May be related to #10119. |
@jamiehaywood |
@JanJakes that's true, the issue seems to be related to I've added that to the I've tested it with overriding the config. If you have overrideWebpackConfig: ({ webpackConfig }) => {
webpackConfig.plugins = webpackConfig.plugins.filter(
(plugin) => !(plugin.options && 'eslintPath' in plugin.options)
);
webpackConfig.plugins.unshift(new ESLintPlugin({
// Plugin options
extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
formatter: require.resolve('react-dev-utils/eslintFormatter'),
eslintPath: require.resolve('eslint'),
context: './src',
cache: true,
// Setting threads to false boost compiling speed back to previous levels
threads: false,
// ESLint class options
cwd: fs.realpathSync(process.cwd()),
resolvePluginsRelativeTo: __dirname,
baseConfig: {
extends: [require.resolve('eslint-config-react-app/base')],
rules: {
'react/react-in-jsx-scope': 'error',
},
},
}));
return webpackConfig;
} replace cc - webpack-contrib/eslint-webpack-plugin#50 (comment) |
@eek I have done the same thing and but it's not working |
I have added yarn module and using the yarn now, but not working ... with recompile |
Thanks @maxsbelt, commenting ESLintPlugin helped my compile time from 32s to 16s. My |
for anyone that is using "resolutions": {
"react-scripts/eslint-webpack-plugin": "2.3.0"
} to the root |
@jamiehaywood It was fixed in |
@PraveenVerma17 As I'm using npm and can't pin diff --git a/node_modules/react-scripts/config/webpack.config.js b/node_modules/react-scripts/config/webpack.config.js
index eddca1b..8652fc3 100644
--- a/node_modules/react-scripts/config/webpack.config.js
+++ b/node_modules/react-scripts/config/webpack.config.js
@@ -757,6 +757,7 @@ module.exports = function (webpackEnv) {
eslintPath: require.resolve('eslint'),
context: paths.appSrc,
cache: true,
+ threads: false,
// ESLint class options
cwd: paths.appPath,
resolvePluginsRelativeTo: __dirname, |
@PraveenVerma17 Are you using |
@PraveenVerma17 just delete the |
@eek Correct, there's no longer need for a patch as it works correctly on |
Hi folks 👋 |
using resolutions worked correctly for me, btw thanks @eek and @jamiehaywood "resolutions": {
"react-scripts/eslint-webpack-plugin": "2.4.1"
} |
@eek I have updated to "eslint-webpack-plugin": "^2.4.1", but its not solve, |
Is there an update with this issue? 4.x is still unusable for me as compile times are way too long. Especially the initial startup. Im all up to date versioning have cleared my node modules, followed other suggestion but everything is still extremely slow. |
Our initial startup time has gone from ~40s (react-scripts 3.4.0) to ~3m30s (react-scripts 4.0.1), a 5x increase. EDIT: Disabling ESLintPlugin brings it down to around 1m20s, but still not very happy about it 😕 (2x increase) |
Anyone tried if the 4.0.2 update that just dropped fixes this issue? |
at least for us it improved |
I'm still getting quite slow
|
Resolutions resolved the issue for me on initial build time |
Can you tell me the file and the file path where to set this? |
Root Problem in my caseCreate React App uses Notes about these changesThe That being said I think this change could help a few people:
Testing these changes on the largest CRA project I've contributed to (AppSmith) made the following changes. Before (8 minutes)After (2.2 minutes)^ timings are averages over 3 runs SolutionWe are going to replace both the Craco configconst SpeedMeasurePlugin = require("speed-measure-webpack-plugin");
const MomentLocalesPlugin = require("moment-locales-webpack-plugin");
module.exports = {
plugins: [
{
plugin: {
overrideWebpackConfig: ({ webpackConfig }) => {
// remove CaseSensitivePathsPlugin (replace with tsconfig setting or eslint setting)
webpackConfig.plugins = webpackConfig.plugins.filter(
(plugin) => plugin.constructor.name !== "CaseSensitivePathsPlugin"
);
// remove IgnorePlugin
webpackConfig.plugins = webpackConfig.plugins.filter(
(plugin) => plugin.constructor.name !== "IgnorePlugin"
);
// add new ContextReplacementPlugin via moment-locales-webpack-plugin
webpackConfig.plugins.push(new MomentLocalesPlugin()); // exclude all locales except en
const smp = new SpeedMeasurePlugin({
outputFormat: "humanVerbose",
loaderTopFiles: 5,
});
return smp.wrap(webpackConfig);
},
}
}
]
}; What is case-sensitive-paths-webpack-plugin doing?See the code in CRA webconfig However I want to keep it around just in case someone on my team develops on another OS. One option is to use ESLint instead with the What is IgnorePlugin doing?See the code in CRA webconfig Maintainer for Performance?@gaearon / @Timer / @ianschmitz Any thoughts on adding a maintainer for performance related issues. As you know perf issues are normally the last priority so there might be some value in a dedicated perf maintainer. (related #8096 (comment)) |
I just tested the above suggestions and I couldn't observe any performance difference at all in my setup. I'm on macOS Big Sur on a Late 2014 iMac 5k (3.5 GHz Quad-Core Intel Core i5) What I noticed is that |
For our project, the performance gain is dramatic. I followed SamKirkland comment and simply filtered CaseSensitivePathsPlugin and IgnorePlugin Before/After |
In out case it's babel-loader SMP ⏱ Loaders OR even @pmmmwh/react-refresh-webpack-plugin, and did anyone faced the issue? |
Hi everyone,
|
Unfortunately this didn't work for me, we ended up regressing back to react-scripts 3.4.3, where it's still slow but not as slow as 4.0.1 or 5.0.1. I'm gonna give the craco solution a try to see if that helps at all. In our case we have multiple packages but not in a monorepo, just yarn linked. We're not fussed so much about build times but more about recompile time after making changes (hmr) |
This issue has been fixed in 4.0.1.
https://github.com/facebook/create-react-app/releases/tag/v4.0.1
The performance is much, much better now! Thank you! ❤🎉
This issue did not fix yet, still take around 30s to 40s to recompile the changes after a small change in the files
Originally posted by @raRaRa in #9966 (comment)
The text was updated successfully, but these errors were encountered: