Skip to content

Commit

Permalink
Merge pull request #6296 from shellscape/fix/hmr-before-node-stuff
Browse files Browse the repository at this point in the history
Ensure the HMRPlugin assigns module.hot before NodeStuffPlugin
  • Loading branch information
sokra authored Feb 24, 2018
2 parents 7a07901 + 90ab23a commit dd93716
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/HotModuleReplacementPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dd93716

Please sign in to comment.