Skip to content
Permalink
Browse files
Merge pull request #6296 from shellscape/fix/hmr-before-node-stuff
Ensure the HMRPlugin assigns module.hot before NodeStuffPlugin
  • Loading branch information
sokra committed Feb 24, 2018
2 parents 7a07901 + 90ab23a commit dd93716ce9b55a0c59f98722b50dc52a1c4b6bff
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/HotModuleReplacementPlugin.js
@@ -203,7 +203,10 @@ module.exports = class HotModuleReplacementPlugin {
const handler = (parser, parserOptions) => {
parser.hooks.expression.for("__webpack_hash__").tap("HotModuleReplacementPlugin", ParserHelpers.toConstantDependencyWithWebpackRequire(parser, "__webpack_require__.h()"));
parser.hooks.evaluateTypeof.for("__webpack_hash__").tap("HotModuleReplacementPlugin", ParserHelpers.evaluateToString("string"));
parser.hooks.evaluateIdentifier.for("module.hot").tap("HotModuleReplacementPlugin", expr => {
parser.hooks.evaluateIdentifier.for("module.hot").tap({
name: "HotModuleReplacementPlugin",
before: "NodeStuffPlugin"
}, expr => {
return ParserHelpers.evaluateToIdentifier("module.hot", !!parser.state.compilation.hotUpdateChunkTemplate)(expr);
});
// TODO webpack 5: refactor this, no custom hooks

0 comments on commit dd93716

Please sign in to comment.