【问题标题】:Angular 10 - CommonJS or AMD dependencies can cause optimization bailoutsAngular 10 - CommonJS 或 AMD 依赖项可能导致优化救助
【发布时间】:2020-06-26 19:15:30
【问题描述】:

我已经从 angular 7.1.4 更新到 10。 现在我收到类似这样的奇怪警告:

C:\Sviluppo\Welcome\welcome-cloud-app\src\app\calendario-fasce\mese\mese.component.ts 中的警告取决于 src/app/interfaces/calendar/calendar.component。 CommonJS 或 AMD 依赖项可能会导致优化救助。 欲了解更多信息,请参阅:https://angular.io/guide/build#configuring-commonjs-dependencies

对于像这样的其他警告,我在 angular.json 中添加了相关行,例如:

"allowedCommonJsDependencies": [
    "moment",
    ....
]"

我如何解决这个与我的组件相关的警告?

【问题讨论】:

  • 能分享一下mese.component.ts中calendar.component的导入代码吗?

标签: angular dependencies amd commonjs


【解决方案1】:

删除 TS 别名可能会起作用。

import { x } from '@auth/auth....'           // Warning
...to...
import { x } from '../auth/...'              // Warning goes away

更多信息请参考link

【讨论】:

  • 嗨 Arun,MeseComponent 中的导入定义如下: import { CalendarComponent } from 'src/app/interfaces/calendar/calendar.component';这个定义在我所有的项目中都是一样的。 VsCode 默认是这样声明的,我觉得不是这个问题。
  • 我在切换到 Angular 10 时遇到了类似的警告,虽然这对我也有效,但我希望我知道原因。如果只是“以不同的方式查找模块”消除了警告,这似乎是一个错误。
  • 出于某种原因,这对我有用并解决了我的问题
猜你喜欢
  • 2020-11-30
  • 1970-01-01
  • 2020-10-16
  • 2020-10-16
  • 2020-11-07
  • 2021-03-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多