Angular 14 doesn't build library with multiple entry points

See original GitHub issue

Which @angular/* package(s) are the source of the bug?

compiler-cli, compiler, upgrade

Is this a regression?

Yes

Description

Hi everyone, I am about to migrate from v13 to v14, but I faced with the following issue. When I try to build library project it fails on the first entry point which has reference to another entry with the error:

------------------------------------------------------------------------------
Building entry point 'xxx'
------------------------------------------------------------------------------
✖ Compiling with Angular sources in Ivy partial compilation mode.
PATH_TO_TS - error TS2305: Module '"yyy"' has no exported member 'xyz'.

But the thing is that everything is in place and it works fine with ng v13. Moreover ng serve is working fine, but not the build.

I created a repo for this issue, main branch contains working version (ng v13) and ng-14 branch has the same code after ng update @angular/core@14 @angular/cli@14 with the issue.

To reproduce the issue.

  1. Clone main branch
  2. Make sure that it builds the lib by running npm run build-components (ng build components)
  3. Update angular to v14 by running ng update @angular/core@14 @angular/cli@14
  4. Build component library npm run build-components

Result: failed to build

Any thoughts?

Please provide a link to a minimal reproduction of the bug

https://github.com/mgameover/app-n-lib/tree/ng-14

Please provide the exception or error you saw

> ng build components

------------------------------------------------------------------------------
Building entry point '@my/components'
------------------------------------------------------------------------------
✔ Compiling with Angular sources in Ivy partial compilation mode.
✔ Writing FESM bundles
✔ Copying assets
✔ Writing package manifest
✔ Built @my/components

------------------------------------------------------------------------------
Building entry point '@my/components/shared'
------------------------------------------------------------------------------
✔ Compiling with Angular sources in Ivy partial compilation mode.
✔ Writing FESM bundles
✔ Built @my/components/shared

------------------------------------------------------------------------------
Building entry point '@my/components/component'
------------------------------------------------------------------------------
✖ Compiling with Angular sources in Ivy partial compilation mode.
projects/components/component/components.component.ts:3:10 - error TS2305: Module '"@my/components/shared"' has no exported member 'isDefined'.

3 import { isDefined } from '@my/components/shared';

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 14.0.0
Node: 16.14.2
Package Manager: npm 8.5.5
OS: win32 x64

Angular: 14.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1400.0
@angular-devkit/build-angular   14.0.0
@angular-devkit/core            14.0.0
@angular-devkit/schematics      14.0.0
@schematics/angular             14.0.0
ng-packagr                      14.0.0
rxjs                            7.5.5
typescript                      4.6.4

Anything else?

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10

github_iconTop GitHub Comments

2reactions
dmitry-stepanenkocommented, Jun 29, 2022

For anyone coming across this with a slightly different error

Entry point 'my-lib' has an 'index.ts' parallel to the 'entryFilePath'. The 'entryFilePath' should be updated to point to the 'index.ts' file.

Make sure you don’t have internal imports in the library, that point to the main index.ts file of the lib.

1reaction
alan-agius4commented, Jun 10, 2022

In your particular case the best action would be to rename public-api.ts to index.ts and update ng-package.json

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building an Angular Library with multiple entry points | Articles
An Angular library lets you share code between multiple projects. For a larger library it's recommended to use subentry points. We'll build a ......
Read more >
Creating Secondary Entry Points for your Angular Library
In this article, we will take a look at how we can utilise ng-packagr secondary entry points to split our Angular Library even...
Read more >
Angular library secondary entry points that depend on each ...
It happens that the secondary entry points are built BEFORE the main one, so having a shared logic, I will need to put...
Read more >
Secondary entry points in angular library - YouTube
Secondary entry points in angular library : We create a npm package using ng-packagr and also creates a secondary entry point for the ......
Read more >
Angular Libraries Adding Secondary EntryPoints - YouTube
This is the second part of Angular Libraries, where we add a secondary entrypoint to make Angular libraries Tree-shakable.
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