在构建Angular应用程序时收到如下警告消息:
/Users/deb/Documents/ProjectName/src/app/services/filename.service.ts中的警告取决于'rxjs / observable / dom / WebSocketSubject'。 CommonJS或AMD依赖项可能会导致优化援助。 有关更多信息,请参见:https://angular.io/guide/build#configuring-commonjs-dependencies
"allowedCommonJsDependencies": [
"lodash"
],
即使我们遵循角度指南,它仍然会发出相同的警告消息。
角度版本:10.x
那么如何解决它。
答案 0 :(得分:0)
在角度文档 https://angular.io/guide/build#configuring-commonjs-dependencies
他们刚刚展示了在 angular.json 文件的选项对象中的 allowedCommonJsDependencies[] 中添加您的依赖项
请看看我是如何添加依赖项的 “allowedCommonJsDependencies”:[ “网址加入”, "洛达什", "rxjs/add/observable/forkJoin", "日期-fns", "@firebase/组件", "@firebase/util", ],
我的 angular.json 文件
$ conda install gcc_linux-64
$ conda install gxx_linux-64
答案 1 :(得分:0)
我的建议编辑您的代码
"allowedCommonJsDependencies": [
"rxjs/observable/dom/WebSocketSubject"
],