Skip to content

Commit 8ae762b

Browse files
author
Justin Helmer
committed
hot.accept parser stops traversing based on number of args
1 parent f010546 commit 8ae762b

File tree

5 files changed

+39
-2
lines changed

5 files changed

+39
-2
lines changed

lib/HotModuleReplacementPlugin.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,13 @@ module.exports = class HotModuleReplacementPlugin {
215215
this.state.module.addDependency(dep);
216216
requests.push(request);
217217
});
218-
if(expr.arguments.length > 1)
218+
if(expr.arguments.length > 1) {
219219
this.applyPluginsBailResult("hot accept callback", expr.arguments[1], requests);
220-
else
220+
parser.walkExpression(expr.arguments[1]); // other args are ignored
221+
} else {
221222
this.applyPluginsBailResult("hot accept without callback", expr, requests);
223+
}
224+
return true;
222225
}
223226
}
224227
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default 1;
2+
---
3+
export default 2;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "./module";
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import value1 from "./a";
2+
3+
it("should have the expected static path defined", function() {
4+
DEFINE_PATH.should.be.eql('./a');
5+
});
6+
7+
it("should hot.accept the module located at the static file path without breaking the compiler", function() {
8+
module.hot.accept("./a");
9+
value1.should.be.eql(1);
10+
});
11+
12+
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() {
13+
module.hot.accept(DEFINE_PATH);
14+
});
15+
16+
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) {
17+
module.hot.accept(DEFINE_PATH, () => done());
18+
NEXT(require("../../update")(done));
19+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"use strict";
2+
3+
const webpack = require("../../../../");
4+
5+
module.exports = {
6+
plugins: [
7+
new webpack.DefinePlugin({
8+
DEFINE_PATH: JSON.stringify("./a")
9+
})
10+
]
11+
};

0 commit comments

Comments
 (0)