简体   繁体   English

Angular - 警告:入口点“@libray-package”包含对“模块/文件”的深度导入

[英]Angular - Warning: Entry point '@libray-package' contains deep imports into 'module/file'

After upgrading the project to Angular 9.1, the CLI is throwing multiple warnings for various libraries like below:将项目升级到 Angular 9.1 后,CLI 为各种库抛出多个警告,如下所示:

Warning: Entry point '@azure/msal-angular' contains deep imports into 'node_modules/msal/lib-commonjs/utils/UrlUtils'.警告:入口点“@azure/msal-angular”包含对“node_modules/msal/lib-commonjs/utils/UrlUtils”的深度导入。 This is probably not a problem, but may cause the compilation of entry points to be out of order.这可能不是问题,但可能会导致入口点的编译出现问题。

Warning: Entry point 'ngx-toastr' contains deep imports into 'node_modules/@angular/compiler/src/core'.警告:入口点“ngx-toastr”包含对“node_modules/@angular/compiler/src/core”的深度导入。 This is probably not a problem, but may cause the compilation of entry points to be out of order.这可能不是问题,但可能会导致入口点的编译出现问题。

I search for this warning and got this Github issue: https://github.com/angular/angular/issues/35615我搜索这个警告并得到这个 Github 问题: https://github.com/angular/angular/issues/35615

This slilences the warning.这会消除警告。 But what is the root cause of this warning and how to fix it instead of just supressing the warning?但是这个警告的根本原因是什么以及如何解决它而不是仅仅抑制警告?

Not sure if this will help you, but I solved the same "ngx-toastr" warning message by installing the latest version from https://www.npmjs.com/package/ngx-toastr/v/12.0.1不确定这是否会对您有所帮助,但我通过安装https://www.npmjs.com/package/ngx-toastr/v/12.0.1的最新版本解决了相同的“ngx-toastr”警告消息

Perhaps the older version(s) of "ngx-toastr" aren't compatible with Angular CLI 9.1?也许“ngx-toastr”的旧版本与 Angular CLI 9.1 不兼容?

This is the relevant section of my package.json post update.这是我的 package.json 更新后的相关部分。

.
.
.
 "ngx-toastr": "^12.0.1",
.
.
.

Perhaps "@azure/msal-angular" can be resolved in the same way (although I haven't used this package).也许“@azure/msal-angular”可以用同样的方式解决(虽然我没有使用过这个包)。

Good Luck!祝你好运!

Robin罗宾

In this github topic it is informed that it may be a false positive.在这个github 主题中,它被告知它可能是误报。 To solve this problem, it is necessary to create a file with the name ngcc.config.js in the root of the project and in this structure, inform the folders to be ignored.要解决此问题,需要在项目的根目录中创建一个名为 ngcc.config.js 的文件,并在此结构中通知要忽略的文件夹。

In my case the false positive pointed to the lib "angular2-text-mask".在我的例子中,误报指向了库“angular2-text-mask”。

module.exports = {
    packages: {
      'angular2-text-mask': {
        ignorableDeepImportMatchers: [
          /text-mask-core\//,
        ]
      },
    },
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM