diff --git a/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack-react/src/HotModuleReplacement.ts b/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack-react/src/HotModuleReplacement.ts index de88046..4f63516 100644 --- a/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack-react/src/HotModuleReplacement.ts +++ b/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack-react/src/HotModuleReplacement.ts @@ -3,7 +3,7 @@ import * as webpack from 'webpack'; const supportedTypeScriptLoaders = ['ts-loader', 'awesome-typescript-loader']; export function addReactHotModuleReplacementConfig(webpackConfig: webpack.Configuration) { - const moduleConfig = webpackConfig.module as webpack.NewModule; + const moduleConfig = webpackConfig.module as webpack.Module; const moduleRules = moduleConfig.rules; if (!moduleRules) { return; // Unknown rules list format. Might be Webpack 1.x, which is not supported. @@ -13,13 +13,13 @@ export function addReactHotModuleReplacementConfig(webpackConfig: webpack.Config // to its array of loaders for (let ruleIndex = 0; ruleIndex < moduleRules.length; ruleIndex++) { // We only support NewUseRule (i.e., { use: ... }) because OldUseRule doesn't accept array values - const rule = moduleRules[ruleIndex] as webpack.NewUseRule; + const rule = moduleRules[ruleIndex] as webpack.RuleSetRule; if (!rule.use) { continue; } // We're looking for the first 'use' value that's a TypeScript loader - const loadersArray = rule.use instanceof Array ? rule.use : [rule.use]; + const loadersArray: webpack.RuleSetUseItem[] = rule.use instanceof Array ? rule.use : [rule.use as webpack.RuleSetUseItem]; const isTypescriptLoader = supportedTypeScriptLoaders.some(typeScriptLoaderName => containsLoader(loadersArray, typeScriptLoaderName)); if (!isTypescriptLoader) { continue; @@ -43,11 +43,11 @@ export function addReactHotModuleReplacementConfig(webpackConfig: webpack.Config }); } -function containsLoader(loadersArray: webpack.Loader[], loaderName: string) { +function containsLoader(loadersArray: webpack.RuleSetUseItem[], loaderName: string) { return loadersArray.some(loader => { // Allow 'use' values to be either { loader: 'name' } or 'name' // No need to support legacy webpack.OldLoader - const actualLoaderName = (loader as webpack.NewLoader).loader || (loader as string); + const actualLoaderName = (loader as webpack.RuleSetLoader).loader || (loader as string); return actualLoaderName && new RegExp(`\\b${ loaderName }\\b`).test(actualLoaderName); }); }