question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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.

  1. npm run full-install
  2. npm run build
  3. 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:closed
  • Created 3 years ago
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
JonWallstencommented, Jul 3, 2020

@alan-agius4: Your solution worked fine. I’ll check for changes in Angular’s config next time. Thanks!

1reaction
gkalpakcommented, Jul 4, 2020

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).)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 11 is not running ngcc - ivy - Stack Overflow
I was able to run the command manually as npx ngcc : forest@forest:~/....$ npx ngcc Compiling @angular/core : fesm2015 as esm2015Β ...
Read more >
After upgrading to Angular 10, ivy ngcc is compiling as a esm5 ...
Output when building with "postinstall": "ngcc --properties es5 browser module main --first-only --create-ivy-entry-points. Compiling ...
Read more >
error: failed to initialize angular compilation - ngcc failed.
I had the error: Unknown arguments: use-program-dependencies, useProgramDependencies An unhandled exception occurred: NGCC failed. See "C:\...\angular-errors.
Read more >
Upgrading tips for Angular 10 projects - The NativeScript Blog
1. Update package.json Β· Using your preferred console app, after setting your working directory to your project path, run: node update_package.
Read more >
Angular with Ivy - Build performance review - inDepth.dev
Dive into bundle-size and compilation speed insights. Was Ivy project worth waiting for?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found