Wednesday, May 9, 2018

Page 48 of "ASP.NET Core 2 and Angular 5" by Valerio De Sanctis suggests a manual correction to webpack.config.vendor.js at an ASP.NET Core Angular application.

It turns out that webpack.config.js is not the lastmost file in the Solution Explorer. If you click it, it will expand to reveal webpack.config.vendor.js which has:

plugins: [
   new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }),
// 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

]

 
 

...which needs five items instead of four. It needs to look like this:

plugins: [
   new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }),
// 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.ContextReplacementPlugin(/angular(\\|\/)core(\\|\/)esm5/,
        path.join(__dirname, './ClientApp')),
// Workaround for
        https://github.com/angular/angular/issues/20357

   new webpack.IgnorePlugin(/^vertx$/)
// Workaround for
        https://github.com/stefanpenner/es6-promise/issues/100

]

 
 

This is to fix https://github.com/angular/angular/issues/20357 which seems to have to do with errors which say:

Critical dependency: the request of a dependency is an expression

No comments:

Post a Comment