ngcc deep import warnings for generated types
See original GitHub issueπ bug report
Affected Package
The issue is caused by package @angular/compiler-cliIs this a regression?
Probably not a regression.
Description
We have two repositories, both full of Angular libraries.
Both repositories have generated typings in the root folder called generated
which is ignored by git.
Libraries from one repository depend on libraries of another (one direction only).
What happens is that once we install certain library, that library expects generated
path with typings inside.
This actually works perfectly fine, but ngcc throws warning like:
WARNING in Entry point βlibrary/nameβ contains deep imports into βabsolute-path/generated/globalTypes.d.tsβ. This is probably not a problem, but may cause the compilation of entry points to be out of order
Additionally we use TS Paths in order for ngcc to recognize the folder in the first place:
"generated/*": [
"generated/*"
],
First workaround is to silence the warning with the snippet bellow, but we would have to repeat the entry for each and every library we produce.
// ngcc.config.js
module.exports = {
packages: {
'library/name': {
ignorableDeepImportMatchers: [
/generated\//,
]
},
},
};
Second workaround would be to release ngcc.config.js
with each library, looking like:
module.exports = {
ignorableDeepImportMatchers: [/generated\//]
};
and add ngcc.config.js
to assets of ng-package.json
:
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/library/name",
"assets": ["./ngcc.config.js"]
}
Third workaround is to use impor type
syntax for all generated types:
import type { MyType } from 'generated';
π¬ Minimal Reproduction
This would take a massive effort to reproduce. I will attempt on doing so if we cannot proceed verbally only.
π Your Environment
Angular Version:
Angular CLI: 10.2.0
Node: 12.18.2
OS: darwin x64
Angular: 10.2.0
... animations, cli, common, compiler, compiler-cli, core
... elements, forms, language-service, localize
... platform-browser, platform-browser-dynamic, router
... service-worker
Ivy Workspace: Yes
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1002.0
@angular-devkit/build-angular 0.1002.0
@angular-devkit/core 10.2.0
@angular-devkit/schematics 10.2.0
@angular/cdk 10.2.6
@angular/flex-layout 10.0.0-beta.32
@angular/material 10.2.6
@angular/pwa 0.1002.0
@schematics/angular 10.2.0
@schematics/update 0.1002.0
ng-packagr 10.1.2
rxjs 6.6.3
typescript 4.0.5
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Hi @klemenoslaj,
Thereβs a couple of things you can do to silence the warning. The easiest would probably be to ship an
ngcc.config.json
file with the libraries itself:This avoids the need for a project-level config of all package names. And actually I notice now that you amended this into the issue description as well.
Alternatively, you could extend the project-level config file to build the config file dynamically, as itβs just a JS file that will be executed when ngcc loads it.
IMO ngcc is already offering the necessary tools here and no further action is needed. Feel free to continue the discussion below; Iβll close this for now.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.