fix remaining issues in estree port
This commit is contained in:
@@ -79,9 +79,7 @@ export function ImportDeclaration(node, print) {
|
||||
this.push(", ");
|
||||
}
|
||||
|
||||
var isDefault = t.isSpecifierDefault(spec);
|
||||
|
||||
if (!isDefault && spec.type !== "ImportNamespaceSpecifier" && !foundImportSpecifier) {
|
||||
if (!t.isSpecifierDefault(spec) && !foundImportSpecifier) {
|
||||
foundImportSpecifier = true;
|
||||
this.push("{ ");
|
||||
}
|
||||
|
||||
@@ -215,17 +215,15 @@ export default class DefaultFormatter {
|
||||
}
|
||||
|
||||
exportAllDeclaration(node, nodes) {
|
||||
var nodes = [];
|
||||
var ref = this.getExternalReference(node, nodes);
|
||||
nodes.push(this.buildExportsWildcard(ref, node));
|
||||
return nodes;
|
||||
}
|
||||
|
||||
exportSpecifier(specifier, node, nodes) {
|
||||
if (node.source) {
|
||||
var ref = this.getExternalReference(node, nodes);
|
||||
|
||||
if (t.isSpecifierDefault(specifier) && !this.noInteropRequireExport) {
|
||||
if (specifier.local.name === "default" && !this.noInteropRequireExport) {
|
||||
// importing a default so we need to normalize it
|
||||
ref = t.callExpression(this.file.addHelper("interop-require"), [ref]);
|
||||
} else {
|
||||
|
||||
@@ -2,6 +2,14 @@ import * as t from "../../../types";
|
||||
|
||||
export { check } from "../internal/modules";
|
||||
|
||||
function keepBlockHoist(node, nodes) {
|
||||
if (node._blockHoist) {
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
nodes[i]._blockHoist = node._blockHoist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function ImportDeclaration(node, parent, scope, file) {
|
||||
// flow type
|
||||
if (node.isType) return;
|
||||
@@ -27,12 +35,14 @@ export function ImportDeclaration(node, parent, scope, file) {
|
||||
export function ExportAllDeclaration(node, parent, scope, file) {
|
||||
var nodes = [];
|
||||
file.moduleFormatter.exportAllDeclaration(node, nodes, parent);
|
||||
keepBlockHoist(node, nodes);
|
||||
return nodes;
|
||||
}
|
||||
|
||||
export function ExportDefaultDeclaration(node, parent, scope, file) {
|
||||
var nodes = [];
|
||||
file.moduleFormatter.exportDeclaration(node, nodes, parent);
|
||||
keepBlockHoist(node, nodes);
|
||||
return nodes;
|
||||
}
|
||||
|
||||
@@ -57,11 +67,7 @@ export function ExportNamedDeclaration(node, parent, scope, file) {
|
||||
}
|
||||
}
|
||||
|
||||
if (node._blockHoist) {
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
nodes[i]._blockHoist = node._blockHoist;
|
||||
}
|
||||
}
|
||||
keepBlockHoist(node, nodes);
|
||||
|
||||
return nodes;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ export var metadata = {
|
||||
};
|
||||
|
||||
export function manipulateOptions(opts) {
|
||||
if (opts.whitelist.length) opts.whitelist.push("es6.destructuring");
|
||||
if (opts.whitelist) opts.whitelist.push("es6.destructuring");
|
||||
}
|
||||
|
||||
var hasSpread = function (node) {
|
||||
|
||||
@@ -11,6 +11,22 @@ export function ForOfStatement(node, parent, scope, file) {
|
||||
|
||||
export { ForOfStatement as ForInStatement };
|
||||
|
||||
export function MethodDefinition(node) {
|
||||
if (node.kind !== "constructor") {
|
||||
// get constructor() {}
|
||||
var isConstructor = !node.computed && t.isIdentifier(node.key, { name: "constructor" });
|
||||
|
||||
// get ["constructor"]() {}
|
||||
isConstructor ||= t.isLiteral(node.key, { value: "constructor" });
|
||||
|
||||
if (isConstructor) {
|
||||
throw this.errorWithNode(messages.get("classesIllegalConstructorKind"));
|
||||
}
|
||||
}
|
||||
|
||||
Property.apply(this, arguments);
|
||||
}
|
||||
|
||||
export function Property(node, parent, scope, file) {
|
||||
if (node.kind === "set") {
|
||||
if (node.value.params.length !== 1) {
|
||||
@@ -24,8 +40,6 @@ export function Property(node, parent, scope, file) {
|
||||
}
|
||||
}
|
||||
|
||||
export { Property as MethodDefinition };
|
||||
|
||||
export function BlockStatement(node) {
|
||||
for (var i = 0; i < node.body.length; i++) {
|
||||
var bodyNode = node.body[i];
|
||||
|
||||
Reference in New Issue
Block a user