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"),
|
comprehensions: require("./generators/comprehensions"),
|
||||||
expressions: require("./generators/expressions"),
|
expressions: require("./generators/expressions"),
|
||||||
statements: require("./generators/statements"),
|
statements: require("./generators/statements"),
|
||||||
playground: require("./generators/playground"),
|
|
||||||
classes: require("./generators/classes"),
|
classes: require("./generators/classes"),
|
||||||
methods: require("./generators/methods"),
|
methods: require("./generators/methods"),
|
||||||
modules: require("./generators/modules"),
|
modules: require("./generators/modules"),
|
||||||
|
|||||||
@ -23,41 +23,9 @@ def("AssignmentPattern")
|
|||||||
.field("left", def("Pattern"))
|
.field("left", def("Pattern"))
|
||||||
.field("right", def("Expression"));
|
.field("right", def("Expression"));
|
||||||
|
|
||||||
// Acorn - Same as ImportNamespaceSpecifier but `id` is `name`
|
|
||||||
def("ImportBatchSpecifier")
|
|
||||||
.bases("Specifier")
|
|
||||||
.build("name")
|
|
||||||
.field("name", def("Identifier"));
|
|
||||||
|
|
||||||
def("RestElement")
|
def("RestElement")
|
||||||
.bases("Pattern")
|
.bases("Pattern")
|
||||||
.build("argument")
|
.build("argument")
|
||||||
.field("argument", def("expression"));
|
.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();
|
types.finalize();
|
||||||
|
|||||||
@ -19,12 +19,6 @@
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"react": {
|
|
||||||
"description": "",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
|
|
||||||
"highlightErrors": {
|
"highlightErrors": {
|
||||||
"description": "ANSI syntax highlight error messages",
|
"description": "ANSI syntax highlight error messages",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|||||||
@ -18,7 +18,7 @@ export default class CommonJSFormatter extends DefaultFormatter {
|
|||||||
};
|
};
|
||||||
|
|
||||||
importSpecifier(specifier, node, nodes) {
|
importSpecifier(specifier, node, nodes) {
|
||||||
var variableName = t.getSpecifierName(specifier);
|
var variableName = node.local;
|
||||||
|
|
||||||
var ref = this.getExternalReference(node, nodes);
|
var ref = this.getExternalReference(node, nodes);
|
||||||
|
|
||||||
|
|||||||
@ -13,11 +13,11 @@ export default class TransformerPass {
|
|||||||
this.handlers = transformer.handlers;
|
this.handlers = transformer.handlers;
|
||||||
this.file = file;
|
this.file = file;
|
||||||
|
|
||||||
this.canRun = this._canRun();
|
this.canTransform = this._canTransform();
|
||||||
this.ran = false;
|
this.ran = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_canRun(): boolean {
|
_canTransform(): boolean {
|
||||||
var transformer = this.transformer;
|
var transformer = this.transformer;
|
||||||
|
|
||||||
var opts = this.file.opts;
|
var opts = this.file.opts;
|
||||||
|
|||||||
@ -44,7 +44,7 @@ export function check(node) {
|
|||||||
export function VariableDeclaration(node, parent, scope, file) {
|
export function VariableDeclaration(node, parent, scope, file) {
|
||||||
if (!isLet(node, parent)) return;
|
if (!isLet(node, parent)) return;
|
||||||
|
|
||||||
if (isLetInitable(node) && file.transformers["es6.blockScopingTDZ"].canRun) {
|
if (isLetInitable(node) && file.transformers["es6.blockScopingTDZ"].canTransform) {
|
||||||
var nodes = [node];
|
var nodes = [node];
|
||||||
|
|
||||||
for (var i = 0; i < node.declarations.length; i++) {
|
for (var i = 0; i < node.declarations.length; i++) {
|
||||||
|
|||||||
@ -24,7 +24,11 @@ export function ImportDeclaration(node, parent, scope, file) {
|
|||||||
return nodes;
|
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
|
// flow type
|
||||||
if (this.get("declaration").isTypeAlias()) return;
|
if (this.get("declaration").isTypeAlias()) return;
|
||||||
|
|
||||||
|
|||||||
@ -62,7 +62,7 @@ exports.Function = function (node, parent, scope, file) {
|
|||||||
param.traverse(iifeVisitor, state);
|
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);
|
pushDefNode(param.node, t.identifier("undefined"), i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,10 +3,6 @@
|
|||||||
import build from "../../helpers/build-binary-assignment-operator-transformer";
|
import build from "../../helpers/build-binary-assignment-operator-transformer";
|
||||||
import * as t from "../../../types";
|
import * as t from "../../../types";
|
||||||
|
|
||||||
export var metadata = {
|
|
||||||
optional: true
|
|
||||||
};
|
|
||||||
|
|
||||||
var MATH_POW = t.memberExpression(t.identifier("Math"), t.identifier("pow"));
|
var MATH_POW = t.memberExpression(t.identifier("Math"), t.identifier("pow"));
|
||||||
|
|
||||||
build(exports, {
|
build(exports, {
|
||||||
|
|||||||
@ -5,7 +5,7 @@ export function Program(program, parent, scope, file) {
|
|||||||
program.body = file.dynamicImports.concat(program.body);
|
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) {
|
if (file.moduleFormatter.transform) {
|
||||||
file.moduleFormatter.transform(program);
|
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);
|
ImportDeclaration.apply(this, arguments);
|
||||||
|
|
||||||
// flow type
|
|
||||||
if (node.isType) return;
|
|
||||||
|
|
||||||
var declar = node.declaration;
|
var declar = node.declaration;
|
||||||
|
|
||||||
var getDeclar = function () {
|
var getDeclar = function () {
|
||||||
@ -30,7 +27,6 @@ export function ExportDeclaration(node, parent, scope) {
|
|||||||
return declar;
|
return declar;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (node.default) {
|
|
||||||
if (t.isClassDeclaration(declar)) {
|
if (t.isClassDeclaration(declar)) {
|
||||||
// export default class Foo {};
|
// export default class Foo {};
|
||||||
this.node = [getDeclar(), node];
|
this.node = [getDeclar(), node];
|
||||||
@ -49,7 +45,18 @@ export function ExportDeclaration(node, parent, scope) {
|
|||||||
node.declaration = declar.id;
|
node.declaration = declar.id;
|
||||||
return [getDeclar(), node];
|
return [getDeclar(), node];
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
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)) {
|
if (t.isClassDeclaration(declar)) {
|
||||||
// export class Foo {}
|
// export class Foo {}
|
||||||
node.specifiers = [t.importSpecifier(declar.id, declar.id)];
|
node.specifiers = [t.importSpecifier(declar.id, declar.id)];
|
||||||
@ -69,7 +76,6 @@ export function ExportDeclaration(node, parent, scope) {
|
|||||||
var id = bindings[key];
|
var id = bindings[key];
|
||||||
specifiers.push(t.exportSpecifier(id, id));
|
specifiers.push(t.exportSpecifier(id, id));
|
||||||
}
|
}
|
||||||
return [declar, t.exportDeclaration(null, specifiers)];
|
return [declar, t.exportNamedDeclaration(null, specifiers)];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import * as t from "../../../types";
|
import * as t from "../../../types";
|
||||||
|
|
||||||
export function Program(program, parent, scope, file) {
|
export function Program(program, parent, scope, file) {
|
||||||
if (file.transformers.strict.canRun) {
|
if (file.transformers.strict.canTransform) {
|
||||||
var directive = file.get("existingStrictDirective");
|
var directive = file.get("existingStrictDirective");
|
||||||
|
|
||||||
if (!directive) {
|
if (!directive) {
|
||||||
|
|||||||
@ -1,9 +1,5 @@
|
|||||||
import * as t from "../../../types";
|
import * as t from "../../../types";
|
||||||
|
|
||||||
export var metadata = {
|
|
||||||
react: true
|
|
||||||
};
|
|
||||||
|
|
||||||
export function Flow(node) {
|
export function Flow(node) {
|
||||||
this.remove();
|
this.remove();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,8 +6,7 @@ export function manipulateOptions(opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export var metadata = {
|
export var metadata = {
|
||||||
optional: true,
|
optional: true
|
||||||
react: true
|
|
||||||
};
|
};
|
||||||
|
|
||||||
require("../../helpers/build-react-transformer")(exports, {
|
require("../../helpers/build-react-transformer")(exports, {
|
||||||
|
|||||||
@ -3,10 +3,6 @@ import * as t from "../../../types";
|
|||||||
|
|
||||||
var JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/;
|
var JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/;
|
||||||
|
|
||||||
export var metadata = {
|
|
||||||
react: true
|
|
||||||
};
|
|
||||||
|
|
||||||
export function Program(node, parent, scope, file) {
|
export function Program(node, parent, scope, file) {
|
||||||
var id = "React.createElement";
|
var id = "React.createElement";
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user