Skip to content

Commit 65e8014

Browse files
committed
fixed a bug where called imported were not parsed
1 parent fd1e68f commit 65e8014

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

lib/dependencies/HarmonyImportDependencyParserPlugin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@ module.exports = AbstractPlugin.create({
3333
return true;
3434
},
3535
"call imported var": function(expr) {
36+
var args = expr.arguments;
3637
expr = expr.callee;
3738
var name = expr.name;
3839
var settings = this.state.harmonySpecifier["$" + name];
3940
var dep = new HarmonyImportSpecifierDependency(settings[0], settings[1], settings[2], name, expr.range);
4041
dep.call = true;
4142
dep.loc = expr.loc;
4243
this.state.current.addDependency(dep);
44+
if(args)
45+
this.walkExpressions(args);
4346
return true;
4447
},
4548
"hot accept callback": function(expr, requests) {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import {x, f} from "./x";
2+
3+
it("should import into object literal", function() {
4+
({ x: x }).should.be.eql({x: 1});
5+
var obj = { x: x };
6+
obj.should.be.eql({x: 1});
7+
});
8+
9+
function func(z) {
10+
return z;
11+
}
12+
13+
it("should import into function argument", function() {
14+
func(x).should.be.eql(1);
15+
f(x).should.be.eql(1);
16+
func({x:x}).should.be.eql({x:1});
17+
f({x:x}).should.be.eql({x:1});
18+
var y = f(x);
19+
y.should.be.eql(1);
20+
y = function() {
21+
return x;
22+
};
23+
y().should.be.eql(1);
24+
});
25+
26+
it("should import into array literal", function() {
27+
([x, f(2)]).should.be.eql([1, 2]);
28+
([{
29+
value: x
30+
}]).should.be.eql([{ value: x }]);
31+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export var x = 1;
2+
export function f(x) {
3+
return x;
4+
}

0 commit comments

Comments
 (0)