split up class expressions in export default
This commit is contained in:
@@ -2,13 +2,20 @@
|
||||
|
||||
var t = require("../../../types");
|
||||
|
||||
exports.ExportDeclaration = function (node) {
|
||||
exports.ExportDeclaration = function (node, parent, scope) {
|
||||
var declar = node.declaration;
|
||||
|
||||
if (node.default) {
|
||||
if (t.isClassDeclaration(declar)) {
|
||||
node.declaration = declar.id;
|
||||
return [declar, node];
|
||||
} else if (t.isClassExpression(declar)) {
|
||||
var temp = scope.generateUidIdentifier("default");
|
||||
declar = t.variableDeclaration("var", [
|
||||
t.variableDeclarator(temp, declar)
|
||||
]);
|
||||
node.declaration = temp;
|
||||
return [declar, node];
|
||||
}
|
||||
} else {
|
||||
if (t.isFunctionDeclaration(declar)) {
|
||||
|
||||
@@ -8,8 +8,9 @@ define(["exports", "module"], function (exports, module) {
|
||||
module.exports = foo;
|
||||
module.exports = function () {};
|
||||
|
||||
module.exports = function () {};
|
||||
var _default = function _default() {};
|
||||
|
||||
module.exports = _default;
|
||||
function foo() {}
|
||||
var Foo = function Foo() {};
|
||||
|
||||
|
||||
@@ -7,8 +7,9 @@ module.exports = [];
|
||||
module.exports = foo;
|
||||
module.exports = function () {};
|
||||
|
||||
module.exports = function () {};
|
||||
var _default = function _default() {};
|
||||
|
||||
module.exports = _default;
|
||||
function foo() {}
|
||||
var Foo = function Foo() {};
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
var _default = function _default() {};
|
||||
|
||||
function foo() {}
|
||||
var Foo = function Foo() {};
|
||||
@@ -1,7 +1,7 @@
|
||||
System.register([], function (_export) {
|
||||
"use strict";
|
||||
|
||||
var Foo;
|
||||
var _default, Foo;
|
||||
_export("default", foo);
|
||||
|
||||
function foo() {}
|
||||
@@ -18,7 +18,9 @@ System.register([], function (_export) {
|
||||
|
||||
_export("default", function () {});
|
||||
|
||||
_export("default", function () {});
|
||||
_default = function _default() {};
|
||||
|
||||
_export("default", _default);
|
||||
|
||||
Foo = function Foo() {};
|
||||
|
||||
|
||||
@@ -14,8 +14,9 @@
|
||||
module.exports = foo;
|
||||
module.exports = function () {};
|
||||
|
||||
module.exports = function () {};
|
||||
var _default = function _default() {};
|
||||
|
||||
module.exports = _default;
|
||||
function foo() {}
|
||||
var Foo = function Foo() {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user