Ivy compiler doesn't work with secondary entry points in libraries using dist folder
See original GitHub issue🐞 bug report
Affected Package
@angular/compiler@9.0.0 (ngcc)
Is this a regression?
Not known
Description
We have a monorepo managed with the Angular CLI with several libraries, each with secondary entry points, and a showcase. We build the libraries using the ViewEngine compiler and the showcase with Ivy. Once we build the showcase, Ivy seems to fail to compile imported symbols in secondary entry points, which results in the error code NG6002 (See error below).
We used the following guide for secondary entry points: https://github.com/ng-packagr/ng-packagr/blob/v9.0.0/docs/secondary-entrypoints.md The built library artifacts reside in the dist folder (default Angular CLI configuration)
Strangely enough, when we copy the build artifacts into node_modules and remove the compilerOptions.paths
entry in tsconfig.json, ngcc seems to compile it successfully.
If we leave it in dist, ngcc seems to stop compiling secondary entrypoints after the first/entry file.
🔬 Minimal Reproduction
- clone https://github.com/jeripeierSBB/lib-with-secondary-entry-points
ng build my-lib --prod
ng build showcase --prod
(orng serve
)
🔥 Exception or Error
ERROR in dist/my-lib/my-feature/my-feature.module.d.ts:1:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class
1 export declare class MyFeatureModule {
🌍 Your Environment
Angular Version:
Angular CLI: 9.0.0
Node: 13.7.0
OS: darwin x64
Angular: 9.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.900.0
@angular-devkit/build-angular 0.900.0
@angular-devkit/build-ng-packagr 0.900.0
@angular-devkit/build-optimizer 0.900.0
@angular-devkit/build-webpack 0.900.0
@angular-devkit/core 9.0.0
@angular-devkit/schematics 9.0.0
@ngtools/webpack 9.0.0
@schematics/angular 9.0.0
@schematics/update 0.900.0
ng-packagr 9.0.0
rxjs 6.5.4
typescript 3.7.5
webpack 4.41.2
Anything else relevant?
Workaround
ng build my-lib --prod
- copy content of dist folder to node_modules
- remove
compilerOptions.paths
in tsconfig.json ng build showcase --prod
(orng serve
)- compiles successfully
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:6 (5 by maintainers)
Hopefully #35227 will fix this. I am just building and trying out on the reproduction from above.
I can confirm that, locally, this PR fixes the repro.