升级到Angular 10-修复CommonJS或AMD依赖项可能会导致优化援助 [英] Upgrading to Angular 10 - Fix CommonJS or AMD dependencies can cause optimization bailouts
问题描述
我正在尝试将我的angular 9应用程序升级到angular 10版本,但升级后低于警告
I am trying to upgrade my angular 9 app to angular 10 version, but getting below warning after the upgrade
rxjs\BehaviorSubject.js depends on rxjs-compat/BehaviorSubject
有什么办法解决这个问题吗?
Any idea how to fix this?
提前谢谢!
推荐答案
当您使用CommonJS打包的依赖项时,可能会导致速度较慢的应用程序
When you use a dependency that is packaged with CommonJS, it can result in larger slower applications
从版本10开始,当您的构建引入这些捆绑软件之一时,Angular现在会警告您.如果您开始对依赖项看到这些警告,请让您的依赖项知道您更喜欢ECMAScript模块(ESM)捆绑包.
Starting with version 10, Angular now warns you when your build pulls in one of these bundles. If you’ve started seeing these warnings for your dependencies, let your dependency know that you’d prefer an ECMAScript module (ESM) bundle.
这是官方文档-配置CommonJS依赖项
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"allowedCommonJsDependencies": [
"rxjs-compat"
]
...
}
...
},
这篇关于升级到Angular 10-修复CommonJS或AMD依赖项可能会导致优化援助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!