我已根据此更新了 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。