simplify class default exports
This commit is contained in:
@@ -7,21 +7,13 @@ exports.ExportDeclaration = function (node, parent, scope, context, file) {
|
||||
|
||||
if (node.default) {
|
||||
if (t.isClassDeclaration(declar)) {
|
||||
// we need to replace default class declarations with an assignment
|
||||
// because VariableDeclaration nodes aren't allowed in `export default`
|
||||
node.declaration = t.assignmentExpression("=", declar.id, t.toExpression(declar));
|
||||
|
||||
return [
|
||||
t.variableDeclaration("let", [
|
||||
t.variableDeclarator(declar.id)
|
||||
]),
|
||||
node
|
||||
];
|
||||
node.declaration = declar.id;
|
||||
return [declar, node];
|
||||
}
|
||||
} else {
|
||||
if (t.isFunctionDeclaration(declar)) {
|
||||
node.specifiers = [t.importSpecifier(declar.id, declar.id)];
|
||||
node.declaration = null;
|
||||
node.specifiers = [t.importSpecifier(declar.id, declar.id)];
|
||||
node._blockHoist = 2;
|
||||
return [declar, node];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user