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.

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

  1. clone https://github.com/jeripeierSBB/lib-with-secondary-entry-points
  2. ng build my-lib --prod
  3. ng build showcase --prod (or ng 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

  1. ng build my-lib --prod
  2. copy content of dist folder to node_modules
  3. remove compilerOptions.paths in tsconfig.json
  4. ng build showcase --prod (or ng serve)
  5. compiles successfully

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
petebacondarwincommented, Feb 7, 2020

Hopefully #35227 will fix this. I am just building and trying out on the reproduction from above.

1reaction
petebacondarwincommented, Feb 7, 2020

I can confirm that, locally, this PR fixes the repro.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating Secondary Entry Points for your Angular Library
1. Place the folders for secondary entry points directly under the library folder. · 2. Create additional package.json and public-api. · 3. Remove ......
Read more >
Angular CLI 9 (Ivy) App build with local library (mono-repo ...
The main issue here was that my tsconfig.app.json which is what the ng compiler uses ... dist folder, where my library was being...
Read more >
Building an Angular Library with multiple entry points | Articles
No main entry point: You can move all modules, components and services into multiple subentry points and don't use the main entry point....
Read more >
How to improve your Angular library | Developapa
Now just one step is missing in order to use the secondary entry points. Go to your tsconfig.json (in your root directory). And...
Read more >
Angular package format
Packages that use APF are compatible with the tooling offered by the ... and zero or more secondary entrypoints (for example, @angular/common/http )....
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