remove playground code gen, remove react metadata, start update of modules to estree
This commit is contained in:
parent
ec526f9224
commit
4f00de50d6
@ -1,7 +0,0 @@
|
||||
import each from "lodash/collection/each";
|
||||
|
||||
each(["BindMemberExpression", "BindFunctionExpression"], function (type) {
|
||||
exports[type] = function () {
|
||||
throw new ReferenceError(`Trying to render non-standard playground node ${JSON.stringify(type)}`);
|
||||
};
|
||||
});
|
||||
@ -59,7 +59,6 @@ class CodeGenerator {
|
||||
comprehensions: require("./generators/comprehensions"),
|
||||
expressions: require("./generators/expressions"),
|
||||
statements: require("./generators/statements"),
|
||||
playground: require("./generators/playground"),
|
||||
classes: require("./generators/classes"),
|
||||
methods: require("./generators/methods"),
|
||||
modules: require("./generators/modules"),
|
||||
|
||||
@ -23,41 +23,9 @@ def("AssignmentPattern")
|
||||
.field("left", def("Pattern"))
|
||||
.field("right", def("Expression"));
|
||||
|
||||
// Acorn - Same as ImportNamespaceSpecifier but `id` is `name`
|
||||
def("ImportBatchSpecifier")
|
||||
.bases("Specifier")
|
||||
.build("name")
|
||||
.field("name", def("Identifier"));
|
||||
|
||||
def("RestElement")
|
||||
.bases("Pattern")
|
||||
.build("argument")
|
||||
.field("argument", def("expression"));
|
||||
|
||||
// Abstract references
|
||||
def("VirtualPropertyExpression")
|
||||
.bases("Expression")
|
||||
.build("object", "property")
|
||||
.field("object", def("Expression"))
|
||||
.field("property", or(def("Identifier"), def("Expression")));
|
||||
|
||||
def("PrivateDeclaration")
|
||||
.bases("Declaration")
|
||||
.build("declarations")
|
||||
.field("declarations", [def("Identifier")]);
|
||||
|
||||
// Playground
|
||||
def("BindMemberExpression")
|
||||
.bases("Expression")
|
||||
.build("object", "property", "arguments")
|
||||
.field("object", def("Expression"))
|
||||
.field("property", or(def("Identifier"), def("Expression")))
|
||||
.field("arguments", [def("Expression")]);
|
||||
|
||||
def("BindFunctionExpression")
|
||||
.bases("Expression")
|
||||
.build("callee", "arguments")
|
||||
.field("callee", def("Expression"))
|
||||
.field("arguments", [def("Expression")]);
|
||||
|
||||
types.finalize();
|
||||
|
||||
@ -19,12 +19,6 @@
|
||||
|
||||
},
|
||||
|
||||
"react": {
|
||||
"description": "",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
|
||||
"highlightErrors": {
|
||||
"description": "ANSI syntax highlight error messages",
|
||||
"type": "boolean",
|
||||
|
||||
@ -18,7 +18,7 @@ export default class CommonJSFormatter extends DefaultFormatter {
|
||||
};
|
||||
|
||||
importSpecifier(specifier, node, nodes) {
|
||||
var variableName = t.getSpecifierName(specifier);
|
||||
var variableName = node.local;
|
||||
|
||||
var ref = this.getExternalReference(node, nodes);
|
||||
|
||||
|
||||
@ -13,11 +13,11 @@ export default class TransformerPass {
|
||||
this.handlers = transformer.handlers;
|
||||
this.file = file;
|
||||
|
||||
this.canRun = this._canRun();
|
||||
this.ran = false;
|
||||
this.canTransform = this._canTransform();
|
||||
this.ran = false;
|
||||
}
|
||||
|
||||
_canRun(): boolean {
|
||||
_canTransform(): boolean {
|
||||
var transformer = this.transformer;
|
||||
|
||||
var opts = this.file.opts;
|
||||
|
||||
@ -44,7 +44,7 @@ export function check(node) {
|
||||
export function VariableDeclaration(node, parent, scope, file) {
|
||||
if (!isLet(node, parent)) return;
|
||||
|
||||
if (isLetInitable(node) && file.transformers["es6.blockScopingTDZ"].canRun) {
|
||||
if (isLetInitable(node) && file.transformers["es6.blockScopingTDZ"].canTransform) {
|
||||
var nodes = [node];
|
||||
|
||||
for (var i = 0; i < node.declarations.length; i++) {
|
||||
|
||||
@ -24,7 +24,11 @@ export function ImportDeclaration(node, parent, scope, file) {
|
||||
return nodes;
|
||||
}
|
||||
|
||||
export function ExportDeclaration(node, parent, scope, file) {
|
||||
export function ExportAllDeclaration(node, parent, scope, file) {
|
||||
return file.moduleFormatter.exportAllDeclaration(node, parent);
|
||||
}
|
||||
|
||||
export function ExportNamedDeclaration(node, parent, scope, file) {
|
||||
// flow type
|
||||
if (this.get("declaration").isTypeAlias()) return;
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ exports.Function = function (node, parent, scope, file) {
|
||||
param.traverse(iifeVisitor, state);
|
||||
}
|
||||
|
||||
if (file.transformers["es6.blockScopingTDZ"].canRun && param.isIdentifier()) {
|
||||
if (file.transformers["es6.blockScopingTDZ"].canTransform && param.isIdentifier()) {
|
||||
pushDefNode(param.node, t.identifier("undefined"), i);
|
||||
}
|
||||
|
||||
|
||||
@ -3,10 +3,6 @@
|
||||
import build from "../../helpers/build-binary-assignment-operator-transformer";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var metadata = {
|
||||
optional: true
|
||||
};
|
||||
|
||||
var MATH_POW = t.memberExpression(t.identifier("Math"), t.identifier("pow"));
|
||||
|
||||
build(exports, {
|
||||
|
||||
@ -5,7 +5,7 @@ export function Program(program, parent, scope, file) {
|
||||
program.body = file.dynamicImports.concat(program.body);
|
||||
});
|
||||
|
||||
if (!file.transformers["es6.modules"].canRun) return;
|
||||
if (!file.transformers["es6.modules"].canTransform) return;
|
||||
|
||||
if (file.moduleFormatter.transform) {
|
||||
file.moduleFormatter.transform(program);
|
||||
|
||||
@ -17,12 +17,9 @@ export function ImportDeclaration(node, parent, scope, file) {
|
||||
}
|
||||
}
|
||||
|
||||
export function ExportDeclaration(node, parent, scope) {
|
||||
export function ExportDefaultDeclaration(node, parent, scope) {
|
||||
ImportDeclaration.apply(this, arguments);
|
||||
|
||||
// flow type
|
||||
if (node.isType) return;
|
||||
|
||||
var declar = node.declaration;
|
||||
|
||||
var getDeclar = function () {
|
||||
@ -30,46 +27,55 @@ export function ExportDeclaration(node, parent, scope) {
|
||||
return declar;
|
||||
};
|
||||
|
||||
if (node.default) {
|
||||
if (t.isClassDeclaration(declar)) {
|
||||
// export default class Foo {};
|
||||
this.node = [getDeclar(), node];
|
||||
node.declaration = declar.id;
|
||||
} else if (t.isClassExpression(declar)) {
|
||||
// export default class {};
|
||||
var temp = scope.generateUidIdentifier("default");
|
||||
declar = t.variableDeclaration("var", [
|
||||
t.variableDeclarator(temp, declar)
|
||||
]);
|
||||
node.declaration = temp;
|
||||
return [getDeclar(), node];
|
||||
} else if (t.isFunctionDeclaration(declar)) {
|
||||
// export default function Foo() {}
|
||||
node._blockHoist = 2;
|
||||
node.declaration = declar.id;
|
||||
return [getDeclar(), node];
|
||||
}
|
||||
} else {
|
||||
if (t.isClassDeclaration(declar)) {
|
||||
// export class Foo {}
|
||||
node.specifiers = [t.importSpecifier(declar.id, declar.id)];
|
||||
node.declaration = null;
|
||||
return [getDeclar(), node];
|
||||
} else if (t.isFunctionDeclaration(declar)) {
|
||||
// export function Foo() {}
|
||||
node.specifiers = [t.importSpecifier(declar.id, declar.id)];
|
||||
node.declaration = null;
|
||||
node._blockHoist = 2;
|
||||
return [getDeclar(), node];
|
||||
} else if (t.isVariableDeclaration(declar)) {
|
||||
// export var foo = "bar";
|
||||
var specifiers = [];
|
||||
var bindings = this.get("declaration").getBindingIdentifiers();
|
||||
for (var key in bindings) {
|
||||
var id = bindings[key];
|
||||
specifiers.push(t.exportSpecifier(id, id));
|
||||
}
|
||||
return [declar, t.exportDeclaration(null, specifiers)];
|
||||
}
|
||||
if (t.isClassDeclaration(declar)) {
|
||||
// export default class Foo {};
|
||||
this.node = [getDeclar(), node];
|
||||
node.declaration = declar.id;
|
||||
} else if (t.isClassExpression(declar)) {
|
||||
// export default class {};
|
||||
var temp = scope.generateUidIdentifier("default");
|
||||
declar = t.variableDeclaration("var", [
|
||||
t.variableDeclarator(temp, declar)
|
||||
]);
|
||||
node.declaration = temp;
|
||||
return [getDeclar(), node];
|
||||
} else if (t.isFunctionDeclaration(declar)) {
|
||||
// export default function Foo() {}
|
||||
node._blockHoist = 2;
|
||||
node.declaration = declar.id;
|
||||
return [getDeclar(), node];
|
||||
}
|
||||
}
|
||||
|
||||
export function ExportNamedDeclaration(node, parent, scope) {
|
||||
ImportDeclaration.apply(this, arguments);
|
||||
|
||||
var declar = node.declaration;
|
||||
|
||||
var getDeclar = function () {
|
||||
declar._ignoreUserWhitespace = true;
|
||||
return declar;
|
||||
};
|
||||
|
||||
if (t.isClassDeclaration(declar)) {
|
||||
// export class Foo {}
|
||||
node.specifiers = [t.importSpecifier(declar.id, declar.id)];
|
||||
node.declaration = null;
|
||||
return [getDeclar(), node];
|
||||
} else if (t.isFunctionDeclaration(declar)) {
|
||||
// export function Foo() {}
|
||||
node.specifiers = [t.importSpecifier(declar.id, declar.id)];
|
||||
node.declaration = null;
|
||||
node._blockHoist = 2;
|
||||
return [getDeclar(), node];
|
||||
} else if (t.isVariableDeclaration(declar)) {
|
||||
// export var foo = "bar";
|
||||
var specifiers = [];
|
||||
var bindings = this.get("declaration").getBindingIdentifiers();
|
||||
for (var key in bindings) {
|
||||
var id = bindings[key];
|
||||
specifiers.push(t.exportSpecifier(id, id));
|
||||
}
|
||||
return [declar, t.exportNamedDeclaration(null, specifiers)];
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import * as t from "../../../types";
|
||||
|
||||
export function Program(program, parent, scope, file) {
|
||||
if (file.transformers.strict.canRun) {
|
||||
if (file.transformers.strict.canTransform) {
|
||||
var directive = file.get("existingStrictDirective");
|
||||
|
||||
if (!directive) {
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var metadata = {
|
||||
react: true
|
||||
};
|
||||
|
||||
export function Flow(node) {
|
||||
this.remove();
|
||||
}
|
||||
|
||||
@ -6,8 +6,7 @@ export function manipulateOptions(opts) {
|
||||
}
|
||||
|
||||
export var metadata = {
|
||||
optional: true,
|
||||
react: true
|
||||
optional: true
|
||||
};
|
||||
|
||||
require("../../helpers/build-react-transformer")(exports, {
|
||||
|
||||
@ -3,10 +3,6 @@ import * as t from "../../../types";
|
||||
|
||||
var JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/;
|
||||
|
||||
export var metadata = {
|
||||
react: true
|
||||
};
|
||||
|
||||
export function Program(node, parent, scope, file) {
|
||||
var id = "React.createElement";
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user