Angular 4 到 5 更新 ./node_modules/@angular/core/esm5/core.js 中的警告

2023-12-28

我已根据此更新了 Angular 4 至 5tutorial https://hackernoon.com/understanding-creating-and-subscribing-to-observables-in-angular-426dbf0b04a3,在此之后我的 webpack 构建失败并出现两个警告:

  WARNING in ./node_modules/@angular/core/esm5/core.js
      6553:15-36 Critical dependency: the request of a dependency is an expression
       @ ./node_modules/@angular/core/esm5/core.js
       @ ./ClientApp/boot.browser.ts
       @ multi event-source-polyfill webpack-hot-middleware/client?path=__webpack_hmr&dynamicPublicPath=true ./ClientApp/boot.browser.ts

  WARNING in ./node_modules/@angular/core/esm5/core.js
  6573:15-102 Critical dependency: the request of a dependency is an expression
   @ ./node_modules/@angular/core/esm5/core.js
   @ ./ClientApp/boot.browser.ts
   @ multi event-source-polyfill webpack-hot-middleware/client?path=__webpack_hmr&dynamicPublicPath=true ./ClientApp/boot.browser.ts

我经历过这个topic https://github.com/angular/angular/issues/14898,但没有任何帮助(也许我错过了一些东西)。这是我的 webpack.config.vendor.js 插件的外观:

    plugins: [
        new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery', Popper: 'popper.js' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable)
        new webpack.ContextReplacementPlugin(/\@angular\b.*\b(bundles|linker)/, path.join(__dirname, './ClientApp')), // Workaround for https://github.com/angular/angular/issues/11580
        new webpack.ContextReplacementPlugin(/angular(\\|\/)core(\\|\/)@angular/, path.join(__dirname, './ClientApp')), // Workaround for https://github.com/angular/angular/issues/14898
        new webpack.IgnorePlugin(/^vertx$/) // Workaround for https://github.com/stefanpenner/es6-promise/issues/100
    ] 

我最初使用来自 Visual Studio 的 Angular 模板和 .NET Core API。


当您使用 VS 2017 附带的较新的 Angular 模板并将 Angular 版本 4 升级到 5.x.x 时,您需要运行以下命令以避免在编译时收到一些警告。

webpack --config webpack.config.vendor.js

在项目根目录下从命令提示符运行此命令会删除您在上面的操作中看到的警告。

这样做的作用是重建供应商.js文件在wwwroot/dist文件夹以根据您已安装的 Angular(和其他)npm 软件包进行更新。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Angular 4 到 5 更新 ./node_modules/@angular/core/esm5/core.js 中的警告 的相关文章

随机推荐