【问题标题】:WEBPACK deprecation array to set warning in angular 11 using web pack 5WEBPACK 弃用数组使用 web pack 5 在角度 11 中设置警告
【发布时间】:2021-06-16 17:45:28
【问题描述】:

我将我的应用程序从 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)

知道我应该怎么做吗?用 Set 替换所有 Array?我可以在哪里把这个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

【问题讨论】:

  • 嗨,你能告诉你具体在哪里添加 --trace-deprecation 吗?

标签: node.js angular webpack warnings deprecation-warning


【解决方案1】:

目前,带有 Webpack 5 的 Angular 11 仍处于试验阶段,仅可与 Yarn 一起使用,如 here 所述。因此,您可能会在这里和那里看到一些警告和错误。我认为现在最好避免使用它进行生产构建。

Angular 12 很可能会正式支持它。您可以看到 here @angular-devkit/build-optimizer 库将在版本 12 中支持 Webpack 5。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-06
    • 2014-04-11
    • 2017-02-09
    • 1970-01-01
    • 1970-01-01
    • 2013-11-03
    相关资源
    最近更新 更多