Skip to content

Commit 18ea85d

Browse files
authored
Merge pull request webpack#3263 from webpack/fix/indexed-import
fixes indexed import
2 parents 5b2afd0 + 1237fde commit 18ea85d

4 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎lib/dependencies/HarmonyImportDependencyParserPlugin.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = AbstractPlugin.create({
4040
var settings = this.state.harmonySpecifier["$" + name];
4141
if(settings[2] !== null)
4242
return false;
43-
var dep = new HarmonyImportSpecifierDependency(settings[0], settings[1], expr.property.name, name, expr.range);
43+
var dep = new HarmonyImportSpecifierDependency(settings[0], settings[1], expr.property.name || expr.property.value, name, expr.range);
4444
dep.shorthand = this.scope.inShorthand;
4545
dep.directImport = false;
4646
dep.loc = expr.loc;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export default "default";
2+
export var abc = "abc";
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export default "default";
2+
export var abc = "abc";
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as file from "./file";
2+
import * as file2 from "./file2";
3+
4+
it("should translate indexed access to harmony import correctly", function() {
5+
file["default"].should.be.eql("default");
6+
file["abc"].should.be.eql("abc");
7+
});
8+
9+
it("should translate dynamic indexed access to harmony import correctly", function() {
10+
var fault = "fault";
11+
file2["de" + fault].should.be.eql("default");
12+
file2["abc"].should.be.eql("abc");
13+
});

0 commit comments

Comments
 (0)