Skip to content

Commit 1fb9eb1

Browse files
committed
fixes webpack#5624
1 parent fb8afe7 commit 1fb9eb1

6 files changed

Lines changed: 31 additions & 0 deletions

File tree

lib/dependencies/HarmonyImportDependencyParserPlugin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ module.exports = class HarmonyImportDependencyParserPlugin {
5656
if(this.strictThisContextOnImports) {
5757
// only in case when we strictly follow the spec we need a special case here
5858
parser.plugin("call imported var.*", (expr) => {
59+
if(expr.callee.type !== "MemberExpression") return;
60+
if(expr.callee.object.type !== "Identifier") return;
5961
const name = expr.callee.object.name;
6062
const settings = parser.state.harmonySpecifier[`$${name}`];
6163
if(settings[2] !== null)
@@ -75,6 +77,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
7577
const args = expr.arguments;
7678
const fullExpr = expr;
7779
expr = expr.callee;
80+
if(expr.type !== "Identifier") return;
7881
const name = expr.name;
7982
const settings = parser.state.harmonySpecifier[`$${name}`];
8083
const dep = new HarmonyImportSpecifierDependency(settings[0], settings[1], settings[2], name, expr.range, this.strictExportPresence);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { fn } from "./module";
2+
3+
it("should allow conditionals as callee", function() {
4+
var x = (true ? fn : fn)();
5+
x.should.be.eql("ok");
6+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function fn() {
2+
return "ok";
3+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as M from "./module";
2+
3+
it("should allow conditionals as callee", function() {
4+
var x = (true ? M.fn : M.fn)();
5+
x.should.be.eql("ok");
6+
});
7+
8+
it("should allow conditionals as object", function() {
9+
var x = (true ? M : M).fn();
10+
x.should.be.eql("ok");
11+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function fn() {
2+
return "ok";
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
module: {
3+
strictThisContextOnImports: true
4+
}
5+
};

0 commit comments

Comments
 (0)