-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Build times very slow with NX 12 #5370
Comments
I also noticed that nx adds 3 terser minimizers:
I got it by adding following to
|
I did a small experiment. Looks like 2 extra terser plugins reduce final bundle size from 2.0M to 1.9M, but add extra 188s (5x times slow). Packages: react, antd, firebase, apollo, and some more Command: Custom webpack configuration, optimization=true, 2 terser plugins are removed Time: 45.76s
Default webpack configuration, optimization=true, @nrwl/react/plugins/webpack Time: 233.86s
|
So I did some more digging with the SpeedMeasurePlugin and It seems sass-loader is the main culprit for us:
Any ideas how to fix this? What was changed on the scss part on version 12? |
Off topic.
I cannot make it works. Thanks! |
There is a comment early in the referenced angular/cli thread about the terser plugin, it's lack of file system caching using webpack v5 as well as performance hits in sass. The performance issues you are having have to do with cli v12 and the issues mentioned above, this isn't a problem that NX can solve. So you either have to go back to Angular 11.x and wait or contend with the performance degradation for the time being unfortunately. |
@HaveF as kenptr pointed out you set the webpack config path in your workspace.json. Then you can use something like this: const nxWebpack = require('@nrwl/react/plugins/webpack');
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
const webpack = require('webpack');
const logConfig = false;
const profileWebpack = false;
const measureSpeed = true;
module.exports = (config, context) => {
let newConfig = nxWebpack(config, context);
if(measureSpeed) {
const smp = new SpeedMeasurePlugin();
newConfig = smp.wrap(newConfig);
}
if(profileWebpack) {
const profilePlugin = new webpack.debug.ProfilingPlugin();
newConfig.plugins.push(profilePlugin)
}
if(logConfig)
console.log(JSON.stringify(newConfig.module, null, 4));
return newConfig;
}; With profiling I found the error actually It seems that 'babel-plugin-transform-typescript-metadata' is the problem here and takes 30 minutes to detect that my 5mb client.ts file is too large to process. I disabled 'emitDecoratorMetadata', which is enabled by default, for now which works as a workaround. Is there an option to use NX without Babel? Because I would prefer to keep out as much build tools written in pure JS as possible, because in general I think they are low quality and hard to debug. |
any news regarding this one? |
Anyone have any ideas, I'm experiencing 1hour+ build times |
@soer7022 I don't think we can solve this problem. I think as of now nx needs better ways to debug and profile the build process, because we just need to accept the fact that a lot of the JS build tools are kinda awful IMO. |
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Current Behavior
Since the upgrade to NX 12.0.6 the build on my dev machine(3700x, 32gb Ram) takes ~30 minutes. It took like 2 minute max. When I run with --progress=true It gets stuck while showing '30% building x/n modules 50 active'. I noticed that only one core will be utilized, while the rest stays idle and the memory usage reached the default threshold(2 GB) and then drops to ~700 MB multiple times. Once the cache is build the build times become fast again.
Expected Behavior
Build time should be on par with 11.4.
Steps to Reproduce
I'm unable to do this right now. Our project:
When I edit this file and retry to compile It seems It will take ages to build again. So It definitely seems to be a problem with some babel/webpack plugin and larger code files.
Failure Logs
Environment
The text was updated successfully, but these errors were encountered: