Skip to content

Commit

Permalink
Merge pull request #6962 from justinhelmer/bug/6919
Browse files Browse the repository at this point in the history
hot.accept tap interceptor returns T/F based on the number of args
  • Loading branch information
sokra committed Apr 17, 2018
2 parents ec4ec8e + 2a7fdc4 commit aee2491
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/HotModuleReplacementPlugin.js
Expand Up @@ -343,13 +343,17 @@ module.exports = class HotModuleReplacementPlugin {
parser.state.module.addDependency(dep);
requests.push(request);
});
if (expr.arguments.length > 1)
if (expr.arguments.length > 1) {
parser.hooks.hotAcceptCallback.call(
expr.arguments[1],
requests
);
else
parser.walkExpression(expr.arguments[1]); // other args are ignored
return true;
} else {
parser.hooks.hotAcceptWithoutCallback.call(expr, requests);
return true;
}
}
}
});
Expand Down
3 changes: 3 additions & 0 deletions test/hotCases/define/issue-6962/a.js
@@ -0,0 +1,3 @@
export default 1;
---
export default 2;
1 change: 1 addition & 0 deletions test/hotCases/define/issue-6962/index.js
@@ -0,0 +1 @@
import "./module";
19 changes: 19 additions & 0 deletions test/hotCases/define/issue-6962/module.js
@@ -0,0 +1,19 @@
import value1 from "./a";

it("should have the expected static path defined", function() {
DEFINE_PATH.should.be.eql('./a');
});

it("should hot.accept the module located at the static file path without breaking the compiler", function() {
module.hot.accept("./a");
value1.should.be.eql(1);
});

it("should hot.accept the module located at the defined file path without breaking the compiler, when one argument is passed to hot.accept", function() {
module.hot.accept(DEFINE_PATH);
});

it("should hot.accept the module located at the defined file path without breaking the compiler, when multiple arguments are passed to hot.accept", function(done) {
module.hot.accept(DEFINE_PATH, () => done());
NEXT(require("../../update")(done));
});
11 changes: 11 additions & 0 deletions test/hotCases/define/issue-6962/webpack.config.js
@@ -0,0 +1,11 @@
"use strict";

const webpack = require("../../../../");

module.exports = {
plugins: [
new webpack.DefinePlugin({
DEFINE_PATH: JSON.stringify("./a")
})
]
};

0 comments on commit aee2491

Please sign in to comment.