Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Updating aspnet-webpack-react to work with react-hot-loader v4 #1675

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aspnet-webpack-react",
"version": "3.0.0",
"version": "4.0.0",
"description": "Helpers for using Webpack with React in ASP.NET Core projects. Works in conjunction with the Microsoft.AspNetCore.SpaServices NuGet package.",
"main": "index.js",
"scripts": {
Expand All @@ -17,12 +17,12 @@
"url": "https://github.com/aspnet/JavaScriptServices.git"
},
"devDependencies": {
"@types/webpack": "^2.2.0",
"@types/webpack": "^4.4.0",
"rimraf": "^2.5.4",
"typescript": "^2.0.0",
"webpack": "^2.2.0"
"webpack": "^4.16.0"
},
"peerDependencies": {
"webpack": "^2.2.0"
"webpack": "^4.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as webpack from 'webpack';

const reactHotLoaderWebpackLoader = 'react-hot-loader/webpack';
const reactHotLoaderPatch = 'react-hot-loader/patch';
const supportedTypeScriptLoaders = ['ts-loader', 'awesome-typescript-loader'];

export function addReactHotModuleReplacementConfig(webpackConfig: webpack.Configuration) {
Expand All @@ -27,12 +25,6 @@ export function addReactHotModuleReplacementConfig(webpackConfig: webpack.Config
continue;
}

// This is the one - prefix it with the react-hot-loader loader
// (unless it's already in there somewhere)
if (!containsLoader(loadersArray, reactHotLoaderWebpackLoader)) {
loadersArray.unshift(reactHotLoaderWebpackLoader);
rule.use = loadersArray; // In case we normalised it to an array
}
break;
}

Expand All @@ -48,11 +40,6 @@ export function addReactHotModuleReplacementConfig(webpackConfig: webpack.Config
// Normalise to array
entryConfig[entrypointName] = [entryConfig[entrypointName] as string];
}

let entryValueArray = entryConfig[entrypointName] as string[];
if (entryValueArray.indexOf(reactHotLoaderPatch) < 0) {
entryValueArray.unshift(reactHotLoaderPatch);
}
});
}

Expand Down