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.

ngcc deep import warnings for generated types

See original GitHub issue

🐞 bug report

Affected Package

The issue is caused by package @angular/compiler-cli

Is 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
JoostKcommented, Nov 3, 2020

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:

module.exports = {
  ignorableDeepImportMatchers: [
    /generated\//,
  ],
};

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.

0reactions
angular-automatic-lock-bot[bot]commented, Dec 5, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DevExtreme - "Entry point ... contains deep imports" warnings ...
Angular 9 has been finally released yesterday. After upgrading ng build --prod produces a lot of deep import warnings.
Read more >
Warning: Entry point '@libray-package' contains deep imports ...
In this github topic it is informed that it may be a false positive. To solve this problem, it is necessary to create...
Read more >
Guide Leading Up to Angular 9.0.0 Release - HUSPI
now outdated ngcc artifacts are cleaned automatically. Bug Fixes ... DTS deep imports aren't added to missing packages list in ngcc ...
Read more >
Upgrading tips for Angular 10 projects - The NativeScript Blog
WARNING : Make sure to have your project changes committed and pushed to your remote ... Having deep imports seem to break my...
Read more >
Angular App build and compile issue #428 | Support Center
Warning : Entry point '@volo/abp.ng.theme.lepton' contains deep imports into '/root/core-platform/SCV.Litmus/angular/node_modules/@volo/abp.
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