Title: NgccProcessor slowing down subsequent builds with AngularCompilerPlugin · Issue #15078 · angular/angular-cli · GitHub
Open Graph Title: NgccProcessor slowing down subsequent builds with AngularCompilerPlugin · Issue #15078 · angular/angular-cli
X Title: NgccProcessor slowing down subsequent builds with AngularCompilerPlugin · Issue #15078 · angular/angular-cli
Description: I'm using the AngularCompilerPlugin for a medium-sized project and I've observed a slowdown in build times after enabling Ivy which appears to come from ngcc. When Ivy is enabled the AngularCompilerPlugin runs the NgccProcessor which is ...
Open Graph Description: I'm using the AngularCompilerPlugin for a medium-sized project and I've observed a slowdown in build times after enabling Ivy which appears to come from ngcc. When Ivy is enabled the AngularCompile...
X Description: I'm using the AngularCompilerPlugin for a medium-sized project and I've observed a slowdown in build times after enabling Ivy which appears to come from ngcc. When Ivy is enabled the Angula...
Opengraph URL: https://github.com/angular/angular-cli/issues/15078
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"NgccProcessor slowing down subsequent builds with AngularCompilerPlugin","articleBody":"I'm using the `AngularCompilerPlugin` for a medium-sized project and I've observed a slowdown in build times after enabling Ivy which appears to come from `ngcc`. When Ivy is enabled the `AngularCompilerPlugin` runs the `NgccProcessor` which is supposed to compile the `node_modules` for Ivy on the first run, however in my case any subsequent builds are slowed down as well.\r\n\r\nI have a hacky way to disable the `NgccProcessor` which I've used to measure the differences in build times. Here's what it looks like:\r\n\r\n```ts\r\nclass MyAngularCompilerPlugin extends AngularCompilerPlugin {\r\n public apply(compiler: Compiler): void {\r\n super.apply(compiler);\r\n \r\n compiler.hooks.environment.tap('angular-compiler', () => {\r\n (this as any)._compilerHost.ngccProcessor = undefined;\r\n });\r\n }\r\n}\r\n```\r\n\r\nHere are the timings for 5 production builds on my own machine. Note that these times **are after `ngcc` has been run once** over the `node_modules` in a `postinstall` script. \r\n\r\n```\r\n// Without ngcc (80737ms on average)\r\n84520ms\r\n72547ms\r\n81733ms\r\n85043ms\r\n79844ms\r\n------------------------\r\n// With ngcc (94208ms on average)\r\n93741ms\r\n93714ms\r\n92922ms\r\n97220ms\r\n93444ms\r\n```\r\n\r\nThe 15s slower build time for a production build isn't a big deal locally, however the difference becomes even larger when running it on our CI server. For our production builds we need to run about 30 Webpack builds (10 at a time in parallel), about 20 which go through the `AngularCompilerPlugin`. Disabling the `NgccProcessor` on our CI server reduced our build time from around **10 minutes to about 6 minutes**. Furthermore keeping the `NgccProcessor` led to some flakiness in our builds, presumably because 10 different `ngcc` processes were trying to access file at the same time. Our build script looks something like this:\r\n\r\n1. Run `npm ci`.\r\n2. Run `ngcc` programmatically as follows:\r\n```ts\r\nconst ngcc = require('@angular/compiler-cli/ngcc');\r\nngcc.process({\r\n basePath: path.join(projectRoot, 'node_modules'),\r\n compileAllFormats: false,\r\n propertiesToConsider: ['browser', 'module', 'main'],\r\n createNewEntryPointFormats: true\r\n});\r\n```\r\n3. Run `webpack --mode=production` 30 times by splitting them into chunks of 10 that are run concurrently. We have some logic that tries to make sure that we always run the maximum number of builds, but it stays the same no matter whether `ngcc` is enabled so it shouldn't have an effect on the times.\r\n\r\nI can see a couple of ways to get around this:\r\n\r\n1. Short term: add an option to the `AngularCompilerPlugin` config that allows users that know what they're doing to disable the `NgccProcessor`.\r\n2. Long term: rework either `ngcc` or `NgccProcessor` so that it doesn't have to spend time analyzing the `node_modules` after it has been run already.\r\n\r\ncc @filipesilva \r\n","author":{"url":"https://github.com/crisbeto","@type":"Person","name":"crisbeto"},"datePublished":"2019-07-15T08:10:30Z","url":"https://github.com/angular/angular-cli/issues/15078"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bc4ad53a-3aa2-e4b6-7a11-d82a9d9e981d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D920:2E3FEE:10EDA39:157AA69:6B011644 |
| html-safe-nonce | 4c7764f3cd53bc0028e3e25c9e4f2a626a9ed989c3654c733a575f15c4c08b5b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTIwOjJFM0ZFRToxMEVEQTM5OjE1N0FBNjk6NkIwMTE2NDQiLCJ2aXNpdG9yX2lkIjoiNTQzMjI1OTgyNDQzMzgyOTQ0NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 348f90f78826ea5629aedc3bfa53d74e5c57c58140d6d6e7094fe2ed54fb9e31 |
| hovercard-subject-tag | issue:467993358 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/15078/issue_layout |
| twitter:image | https://opengraph.githubassets.com/980272b5c85ee0a0700322e740458f67a831e7b645df3b87c45d25e375769253/angular/angular-cli/issues/15078 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/980272b5c85ee0a0700322e740458f67a831e7b645df3b87c45d25e375769253/angular/angular-cli/issues/15078 |
| og:image:alt | I'm using the AngularCompilerPlugin for a medium-sized project and I've observed a slowdown in build times after enabling Ivy which appears to come from ngcc. When Ivy is enabled the AngularCompile... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | crisbeto |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width