node.js - WEBPACK 弃用数组以使用 web pack 5 在 angular 11 中设置警告

标签 node.js angular webpack warnings deprecation-warning

我将我的应用程序从 angular 10 迁移到 11,并使用以下命令更新到 webpack 5:

      "resolutions": {
        "webpack": "^5.0.0"
      }
当我构建/服务时,我收到以下警告 =
(node:3926) [DEP_WEBPACK_DEPRECATION_ARRAY_TO_SET_INDEXER] DeprecationWarning: chunk.files was changed from Array to Set (indexing Array is deprecated)
(Use `node --trace-deprecation ...` to show where the warning was created)
知道我该怎么做吗?用集合替换所有数组?我可以把这个放在哪里node --trace-deprecation 在我的应用程序中以了解导致此问题的文件?
谢谢你。
更新
我在构建过程中添加了 --trace-deprecation 并得到以下日志:
(node:12987) [DEP_WEBPACK_DEPRECATION_ARRAY_TO_SET_INDEXER] DeprecationWarning: chunk.files was changed from Array to Set (indexing Array is deprecated)
    at Set.fn (/Users/xxxxx/node_modules/webpack/lib/util/deprecation.js:128:4)
    at xxx/node_modules/@angular-devkit/build-angular/src/webpack/plugins/analytics.js:173:57
    at Array.forEach (<anonymous>)
    at NgBuildAnalyticsPlugin._collectBundleStats (/xxxx/node_modules/@angular-devkit/build-angular/src/webpack/plugins/analytics.js:172:14)
    at NgBuildAnalyticsPlugin._done (/xxx/node_modules/@angular-devkit/build-angular/src/webpack/plugins/analytics.js:242:14)
    at Hook.eval [as callAsync] (eval at create (/xxx/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:14:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/xxx/node_modules/tapable/lib/Hook.js:18:14)
    at /xxx/node_modules/webpack/lib/Compiler.js:468:23
    at Compiler.emitRecords (/xxx/node_modules/webpack/lib/Compiler.js:846:39)
    at /xxx/node_modules/webpack/lib/Compiler.js:460:11

最佳答案

目前,带有 Webpack 5 的 Angular 11 仍处于试验阶段,仅如前面提到的那样与 Yarn 一起使用 here .因此,您可能会在这里和那里看到一些警告和错误。我相信现在最好避免使用它进行生产构建。
很可能它会被 Angular 12 正式支持。你可以看到 here @angular-devkit/build-optimizer 库将在版本 12 中支持 Webpack 5。

关于node.js - WEBPACK 弃用数组以使用 web pack 5 在 angular 11 中设置警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66706102/

相关文章:

node.js - 将 Node 命令行选项传递给 npm 可执行文件?

node.js - 使用getmac获取node.js当前机器的mac地址

javascript - Webpack 2编译但不运行javascript

node.js - 如何在 webpack 上自动安装 npm 包

node.js - KeystoneJS 变量相关帖子

javascript - 当我不是node.exe的调用者时,如何在Windows上的nodejs中调试javascript

Angular 2 - 复选框不同步

Angular 验证错误为 'ngClass',因为它不是 'div' 的已知属性。 (

javascript - ngFor 中的下拉列表仅显示第一个列表项

javascript - 当他们说 "compile"我的 js 代码时,那些 javascript 前端构建工具是什么意思?