Dependency compiled to ES5 during build process even though target is ES2015 and ngcc is run on postinstall
See original GitHub issueπ Bug report
Command (mark with an x
)
- build
Is this a regression?
Not that Iβm aware of.
Description
A clear and concise description of the problem...Our CI (Jenkins) gets stuck in the build process after upgrading to Angular 10. After some investigation it turns out that the issue it that when building our apps in parallel it they all trigger ngcc at the same time. A warning about parallel builds is shown for all apps but the one, and those apps never exists the process even though the build is complete.
So the ngcc part is somehow causing the process to never finish. The main issue causing this I just discovered in the logs. If you look at the last line you can see that ngcc is compiling @fortawesome/angular-fontawesome
into ES5, but the target of the applications are ES2015 and Iβm running ngcc as a postinstall hook, so all modules are already compiled into ES2015.
web-app-prime
|
| > web-app-prime@0.0.0-PLACEHOLDER webpack C:\Users\***\repo\monorepo-new\packages\web-app-prime
| > node --max_old_space_size=8192 node_modules\webpack\bin\webpack.js "--config" "config/webpack.prod.ts" "--bail"
|
web-app-edit
|
| > web-app-edit@0.0.0-PLACEHOLDER webpack C:\Users\***\repo\monorepo-new\packages\web-app-edit
| > node --max_old_space_size=8192 node_modules\webpack\bin\webpack.js "--config" "config/webpack.prod.ts" "--bail"
|
web-app-prime
|
| Compiling @fortawesome/angular-fontawesome : module as esm5
As you can see itβs compiled to ES2015:
> oas@6.0.1027 postinstall C:\Users\***\repo\monorepo-new
> ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points
Compiling @fortawesome/angular-fontawesome : es2015 as esm2015
π¬ Minimal Reproduction
https://github.com/JonWallsten/monorepo-new/tree/angular-10-repro Start with a clean slate since the error goes away after first build.
- npm run full-install
- npm run build
- Profit!
π₯ Exception or Error
| ERROR in ngcc is already running at process with id 33256.
| If you are running multiple builds in parallel then you should pre-process your node_modules via the command line ngcc tool before starting the builds;
| See https://v9.angular.io/guide/ivy#speeding-up-ngcc-compilation.
| (If you are sure no ngcc process is running then you should delete the lock-file at C:/Users/***/repo/monorepo-new/node_modules/@angular/compiler-cli/ngcc/__ngcc_lock_file__.)
π Your Environment
Angular CLI: 10.0.1
Node: 12.16.1
OS: win32 x64
Angular: 10.0.2
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: <error>
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.1000.1
@angular-devkit/build-optimizer 0.1000.1
@angular-devkit/core 10.0.1
@angular-devkit/schematics 10.0.1
@angular/cdk 10.0.1
@angular/cli 10.0.1
@angular/material 10.0.1
@ngtools/webpack 10.0.1
@schematics/angular 10.0.1
@schematics/update 0.1000.1
rxjs 6.5.5
typescript 3.9.5
webpack 4.43.0
Anything else relevant?
"extends": "../../tsconfig.json",
"compilerOptions": {
"target": "es2015",
"outDir": "./dist",
"strictNullChecks": true,
"noImplicitReturns": true,
"typeRoots": [
"./node_modules/@types",
"../../node_modules/@types"
]
}
We also have one Angular.JS application in the mix, but itβs clear itβs not involved.
Edit: It seems like itβs running on every build but the issue (and error) only appears when thereβs something to compile. Note: The log in from another repo but with the same setup.
web-app-prime
| Another process, with id 34620, is currently running ngcc.
| Waiting up to 250s for it to finish.
| (If you are sure no ngcc process is running then you should delete the lock-file at C:/Users/***/repo/oas-web/node_modules/@angular/compiler-cli/ngcc/__ngcc_lock_file__.)
web-app-edit
| Another process, with id 34620, is currently running ngcc.
| Waiting up to 250s for it to finish.
| (If you are sure no ngcc process is running then you should delete the lock-file at C:/Users/***/repo/oas-web/node_modules/@angular/compiler-cli/ngcc/__ngcc_lock_file__.)
| Another process, with id 47668, is currently running ngcc.
| Waiting up to 250s for it to finish.
| (If you are sure no ngcc process is running then you should delete the lock-file at C:/Users/***/repo/oas-web/node_modules/@angular/compiler-cli/ngcc/__ngcc_lock_file__.)
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (12 by maintainers)
Top GitHub Comments
@alan-agius4: Your solution worked fine. Iβll check for changes in Angularβs config next time. Thanks!
I see. Yes, this behavior is expected.
To give some context:
Ngcc will write the lockfile as soon as it is invoked. Ngccβs work has two phases: First, it analyzes the entry-points and their dependencies and determines what compilation tasks need to be performed (and in what order). Then, it does the actual processing of the necessary entry-points.
So, even if it turns out that there is no actual compiling to be done, ngcc will still write a lockfile while analyzing the project. (FWIW, the analysis phase is pretty quick compared to the compilation phase and it is even faster if the dependencies and ngcc command-line options havenβt changed since the last ngcc invocation (because ngcc stores metadata to speed up the analysis on subsequent invocactions).)