Merge pull request #296 from caseywebdev/fix-295
Fix incorrect object reference in #295
This commit is contained in:
commit
e7cbbefc11
@ -65,25 +65,16 @@ AMDFormatter.prototype.import = function (node) {
|
||||
|
||||
AMDFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
|
||||
var key = t.getSpecifierName(specifier);
|
||||
var id = specifier.id;
|
||||
|
||||
// import foo from "foo";
|
||||
if (specifier.default) {
|
||||
id = t.identifier("default");
|
||||
}
|
||||
|
||||
var ref;
|
||||
var ref = this._push(node);
|
||||
|
||||
if (t.isImportBatchSpecifier(specifier)) {
|
||||
// import * as bar from "foo";
|
||||
ref = this._push(node);
|
||||
} else {
|
||||
} else if (specifier.default) {
|
||||
// import foo from "foo";
|
||||
ref = t.memberExpression(this._push(node), id, false);
|
||||
|
||||
if (specifier.default) {
|
||||
ref = t.callExpression(this.file.addDeclaration("interop-require"), [ref]);
|
||||
}
|
||||
ref = t.callExpression(this.file.addDeclaration("interop-require"), [ref]);
|
||||
} else {
|
||||
// import {foo} from "foo";
|
||||
ref = t.memberExpression(ref, specifier.id, false);
|
||||
}
|
||||
|
||||
nodes.push(t.variableDeclaration("var", [
|
||||
|
||||
@ -5,7 +5,7 @@ define(["exports", "foo"], function (exports, _foo) {
|
||||
return obj && (obj["default"] || obj);
|
||||
};
|
||||
|
||||
var foo = _interopRequire(_foo["default"]);
|
||||
var foo = _interopRequire(_foo);
|
||||
|
||||
var foo = _foo["default"];
|
||||
});
|
||||
|
||||
@ -5,7 +5,7 @@ define(["exports", "foo"], function (exports, _foo) {
|
||||
return obj && (obj["default"] || obj);
|
||||
};
|
||||
|
||||
var foo = _interopRequire(_foo["default"]);
|
||||
var foo = _interopRequire(_foo);
|
||||
|
||||
var xyz = _foo.baz;
|
||||
});
|
||||
|
||||
@ -5,7 +5,7 @@ define(["exports", "foo", "foo-bar", "./directory/foo-bar"], function (exports,
|
||||
return obj && (obj["default"] || obj);
|
||||
};
|
||||
|
||||
var foo = _interopRequire(_foo["default"]);
|
||||
var foo = _interopRequire(_foo);
|
||||
|
||||
var foo = _foo;
|
||||
var bar = _foo.bar;
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
return obj && (obj["default"] || obj);
|
||||
};
|
||||
|
||||
var foo = _interopRequire(_foo["default"]);
|
||||
var foo = _interopRequire(_foo);
|
||||
|
||||
var foo = _foo["default"];
|
||||
});
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
return obj && (obj["default"] || obj);
|
||||
};
|
||||
|
||||
var foo = _interopRequire(_foo["default"]);
|
||||
var foo = _interopRequire(_foo);
|
||||
|
||||
var xyz = _foo.baz;
|
||||
});
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
return obj && (obj["default"] || obj);
|
||||
};
|
||||
|
||||
var foo = _interopRequire(_foo["default"]);
|
||||
var foo = _interopRequire(_foo);
|
||||
|
||||
var foo = _foo;
|
||||
var bar = _foo.bar;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user