-
Notifications
You must be signed in to change notification settings - Fork 27.1k
NGCC failure with libraries of similar names #40352
Description
🐞 bug report
Affected Package
@angular/compiler-cli - ngcc
Is this a regression?
Pretty sure it worked in older versions.
Description
If two libraries have the same name, but the second one has the additional suffix, the ngcc will fail.
Example
- library:
demo-lib - library:
demo-lib-shell
demo-lib imports demo-lib-shell module and demo-lib is imported by the application.
Additional observation
To my surprise, the failure only happens if demo-lib-shell library is configured after demo-lib in tsconfig.json paths, as in:
{
"compilerOptions": {
"paths": {
"demo-lib": [
"dist/demo-lib/demo-lib",
"dist/demo-lib"
],
"demo-lib-shell": [
"dist/demo-lib-shell/demo-lib-shell",
"dist/demo-lib-shell"
]
}
}
}If this configuration is reversed, ngcc will not fail.
🔬 Minimal Reproduction
Clone: https://github.com/klemenoslaj/ngcc-failure--library-name
Install dependencies: yarn
Reproduce the issue: yarn reproduce OR yarn reproduce:docker
NOTE: There is a chance that on the first try right after dependency installation this will succeed, but will fail when yarn reproduce is executed again. This probably has something to do with the fact that the rest of dependencies from node_modules are processed as well first time, but I could be wrong.
NOTE 2: This seems to fail consistantly even on the first try in Docker. To that end I have added a docker file and updated the reproduction above accordingly.
🔥 Exception or Error
⠋ Generating browser application bundles...
Compiling demo-lib-shell : es2015 as esm2015
Compiling demo-lib : es2015 as esm2015
✔ Browser application bundle generation complete.
Error: Failed to compile entry-point demo-lib (es2015 as esm2015) due to compilation errors:
dist/demo-lib-shell/lib/demo-lib-shell.module.d.ts:1:22 - error NG6002: Appears in the NgModule.imports of DemoLibModule, but could not be resolved to an NgModule class.
This likely means that the dependency (demo-lib-shell) which declares DemoLibShellModule has not been processed correctly by ngcc.
1 export declare class DemoLibShellModule {
~~~~~~~~~~~~~~~~~~
error Command failed with exit code 1.
🌍 Your Environment
Angular Version:
Angular CLI: 11.0.6
Node: 14.15.0
OS: darwin x64
Angular: 11.0.7
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1100.6
@angular-devkit/build-angular 0.1100.6
@angular-devkit/core 11.0.6
@angular-devkit/schematics 11.0.6
@angular/cli 11.0.6
@schematics/angular 11.0.6
@schematics/update 0.1100.6
ng-packagr 11.0.3
rxjs 6.6.3
typescript 4.0.5