start using es6 modules
This commit is contained in:
parent
307ffcd107
commit
7729cb4b68
@ -1,32 +1,25 @@
|
||||
var isFunction = require("lodash/lang/isFunction");
|
||||
var transform = require("../transformation");
|
||||
var util = require("../util");
|
||||
var fs = require("fs");
|
||||
import isFunction from "lodash/lang/isFunction";
|
||||
import fs from "fs";
|
||||
|
||||
exports.version = require("../../../package").version;
|
||||
export { default as _util, canCompile } from "../util";
|
||||
export { default as transform } from "../transformation";
|
||||
|
||||
exports.buildExternalHelpers = require("../build-external-helpers");
|
||||
export { version } from "../../../package";
|
||||
|
||||
exports.types = require("../types");
|
||||
export { default as buildExternalHelpers } from "../build-external-helpers";
|
||||
export { default as types } from "../types";
|
||||
|
||||
exports.register = function (opts) {
|
||||
export function register(opts) {
|
||||
var register = require("./register/node");
|
||||
if (opts != null) register(opts);
|
||||
return register;
|
||||
};
|
||||
}
|
||||
|
||||
exports.polyfill = function () {
|
||||
export function polyfill() {
|
||||
require("../polyfill");
|
||||
};
|
||||
}
|
||||
|
||||
exports.canCompile = util.canCompile;
|
||||
|
||||
// do not use this - this is for use by official maintained babel plugins
|
||||
exports._util = util;
|
||||
|
||||
exports.transform = transform;
|
||||
|
||||
exports.transformFile = function (filename, opts, callback) {
|
||||
export function transformFile(filename, opts, callback) {
|
||||
if (isFunction(opts)) {
|
||||
callback = opts;
|
||||
opts = {};
|
||||
@ -47,10 +40,10 @@ exports.transformFile = function (filename, opts, callback) {
|
||||
|
||||
callback(null, result);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
exports.transformFileSync = function (filename, opts) {
|
||||
export function transformFileSync(filename, opts) {
|
||||
opts ||= {};
|
||||
opts.filename = filename;
|
||||
return transform(fs.readFileSync(filename), opts);
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// required to safely use babel/register within a browserify codebase
|
||||
|
||||
module.exports = function () {};
|
||||
export default function () {};
|
||||
|
||||
require("../../polyfill");
|
||||
import "../../polyfill";
|
||||
|
||||
@ -1,22 +1,22 @@
|
||||
var path = require("path");
|
||||
var os = require("os");
|
||||
var fs = require("fs");
|
||||
import path from "path";
|
||||
import os from "os";
|
||||
import fs from "fs";
|
||||
|
||||
var FILENAME = process.env.BABEL_CACHE_PATH || path.join(os.tmpdir(), "babel.json");
|
||||
var data = {};
|
||||
|
||||
exports.save = function () {
|
||||
export function save() {
|
||||
fs.writeFileSync(FILENAME, JSON.stringify(data, null, " "));
|
||||
};
|
||||
}
|
||||
|
||||
exports.load = function () {
|
||||
export function load() {
|
||||
if (process.env.BABEL_DISABLE_CACHE) return;
|
||||
|
||||
process.on("exit", exports.save);
|
||||
process.on("exit", save);
|
||||
|
||||
var sigint = function () {
|
||||
process.removeListener("SIGINT", sigint);
|
||||
exports.save();
|
||||
save();
|
||||
process.kill(process.pid, "SIGINT");
|
||||
};
|
||||
|
||||
@ -29,8 +29,8 @@ exports.load = function () {
|
||||
} catch (err) {
|
||||
return;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.get = function () {
|
||||
export function get() {
|
||||
return data;
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
require("../../polyfill");
|
||||
|
||||
var sourceMapSupport = require("source-map-support");
|
||||
var registerCache = require("./cache");
|
||||
var resolveRc = require("./resolve-rc");
|
||||
var extend = require("lodash/object/extend");
|
||||
var babel = require("../node");
|
||||
var each = require("lodash/collection/each");
|
||||
var util = require("../../util");
|
||||
var fs = require("fs");
|
||||
import "../../polyfill";
|
||||
import sourceMapSupport from "source-map-support";
|
||||
import * as registerCache from "./cache";
|
||||
import resolveRc from "./resolve-rc";
|
||||
import extend from "lodash/object/extend";
|
||||
import babel from "../node";
|
||||
import each from "lodash/collection/each";
|
||||
import * as util from "../../util";
|
||||
import fs from "fs";
|
||||
|
||||
sourceMapSupport.install({
|
||||
handleUncaughtExceptions: false,
|
||||
@ -139,7 +138,7 @@ var hookExtensions = function (_exts) {
|
||||
|
||||
hookExtensions(util.canCompile.EXTENSIONS);
|
||||
|
||||
module.exports = function (opts) {
|
||||
export default function (opts) {
|
||||
// normalize options
|
||||
opts ||= {};
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
var merge = require("lodash/object/merge");
|
||||
var path = require("path");
|
||||
var fs = require("fs");
|
||||
import merge from "lodash/object/merge";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
|
||||
var cache = {};
|
||||
|
||||
@ -10,9 +10,8 @@ function exists(filename) {
|
||||
return cache[filename] = fs.existsSync(filename);
|
||||
}
|
||||
|
||||
module.exports = function (loc, opts) {
|
||||
export default function (loc, opts = {}) {
|
||||
var rel = ".babelrc";
|
||||
opts ||= {};
|
||||
|
||||
function find(start, rel) {
|
||||
var file = path.join(start, rel);
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
var buildHelpers = require("./build-helpers");
|
||||
var generator = require("./generation");
|
||||
var util = require("./util");
|
||||
var t = require("./types");
|
||||
import buildHelpers from "./build-helpers";
|
||||
import generator from "./generation";
|
||||
import * as util from "./util";
|
||||
import t from "./types";
|
||||
|
||||
module.exports = function (whitelist) {
|
||||
export default function (whitelist) {
|
||||
var namespace = t.identifier("babelHelpers");
|
||||
|
||||
var body = [];
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
var File = require("./transformation/file");
|
||||
var util = require("./util");
|
||||
var each = require("lodash/collection/each");
|
||||
var t = require("./types");
|
||||
import File from "./transformation/file";
|
||||
import * as util from "./util";
|
||||
import each from "lodash/collection/each";
|
||||
import t from "./types";
|
||||
|
||||
module.exports = function (body, namespace, whitelist = []) {
|
||||
export default function (body, namespace, whitelist = []) {
|
||||
each(File.helpers, function (name) {
|
||||
if (whitelist.length && whitelist.indexOf(name) == -1) return;
|
||||
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
module.exports = detect;
|
||||
import SYNTAX_KEYS from "./syntax-keys";
|
||||
import traverse from "../traversal";
|
||||
|
||||
var SYNTAX_KEYS = require("./syntax-keys");
|
||||
var traverse = require("../traversal");
|
||||
var visitors = traverse.explode(require("./visitors"));
|
||||
var visitors = traverse.explode(require("./visitors"));
|
||||
|
||||
function detect(ast) {
|
||||
export default function (ast) {
|
||||
var stats = {
|
||||
syntax: {},
|
||||
builtins: {}
|
||||
@ -26,4 +25,4 @@ function detect(ast) {
|
||||
});
|
||||
|
||||
return stats;
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,19 +1,19 @@
|
||||
var t = require("../types");
|
||||
var includes = require("lodash/collection/includes");
|
||||
import includes from "lodash/collection/includes";
|
||||
import t from "../types";
|
||||
|
||||
exports.AssignmentExpression = function (node, parent, detected) {
|
||||
export function AssignmentExpression(node, parent, detected) {
|
||||
if (node.operator === "**=") {
|
||||
detected("es6.exponentation");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.BinaryExpression = function (node, parent, detected) {
|
||||
export function BinaryExpression(node, parent, detected) {
|
||||
if (node.operator === "**") {
|
||||
detected("es6.exponentation");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.VariableDeclaration = function (node, parent, detected) {
|
||||
export function VariableDeclaration(node, parent, detected) {
|
||||
if (node.kind === "let" || node.kind === "const") {
|
||||
detected("es6.blockScoping");
|
||||
}
|
||||
@ -21,9 +21,9 @@ exports.VariableDeclaration = function (node, parent, detected) {
|
||||
if (node.kind === "const") {
|
||||
detected("es6.constants");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.Property = function (node, parent, detected) {
|
||||
export function Property(node, parent, detected) {
|
||||
if (node.shorthand || node.method) {
|
||||
detected("es6.properties.shorthand");
|
||||
}
|
||||
@ -35,15 +35,15 @@ exports.Property = function (node, parent, detected) {
|
||||
if (node.computed) {
|
||||
detected("es6.properties.computed");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.AssignmentPattern = function (node, parent, detected) {
|
||||
export function AssignmentPattern(node, parent, detected) {
|
||||
if (t.isFunction(parent) && includes(parent.params, node)) {
|
||||
detected("es6.parameters.default");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.Function = function (node, parent, detected) {
|
||||
export function Function(node, parent, detected) {
|
||||
if (node.generator) {
|
||||
detected("es6.generators");
|
||||
}
|
||||
@ -51,4 +51,4 @@ exports.Function = function (node, parent, detected) {
|
||||
if (node.async) {
|
||||
detected("es7.asyncFunctions");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
var repeating = require("repeating");
|
||||
var trimRight = require("trim-right");
|
||||
var isBoolean = require("lodash/lang/isBoolean");
|
||||
var includes = require("lodash/collection/includes");
|
||||
var isNumber = require("lodash/lang/isNumber");
|
||||
import repeating from "repeating";
|
||||
import trimRight from "trim-right";
|
||||
import isBoolean from "lodash/lang/isBoolean";
|
||||
import includes from "lodash/collection/includes";
|
||||
import isNumber from "lodash/lang/isNumber";
|
||||
|
||||
export default class Buffer {
|
||||
constructor(position, format) {
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
exports.File = function (node, print) {
|
||||
export function File(node, print) {
|
||||
print(node.program);
|
||||
};
|
||||
}
|
||||
|
||||
exports.Program = function (node, print) {
|
||||
export function Program(node, print) {
|
||||
print.sequence(node.body);
|
||||
};
|
||||
}
|
||||
|
||||
exports.BlockStatement = function (node, print) {
|
||||
export function BlockStatement(node, print) {
|
||||
if (node.body.length === 0) {
|
||||
this.push("{}");
|
||||
} else {
|
||||
@ -16,4 +16,4 @@ exports.BlockStatement = function (node, print) {
|
||||
this.removeLast("\n");
|
||||
this.rightBrace();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ exports.ClassDeclaration = function (node, print) {
|
||||
print(node.body);
|
||||
};
|
||||
|
||||
exports.ClassBody = function (node, print) {
|
||||
export function ClassBody(node, print) {
|
||||
if (node.body.length === 0) {
|
||||
this.push("{}");
|
||||
} else {
|
||||
@ -29,12 +29,12 @@ exports.ClassBody = function (node, print) {
|
||||
|
||||
this.rightBrace();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.MethodDefinition = function (node, print) {
|
||||
export function MethodDefinition(node, print) {
|
||||
if (node.static) {
|
||||
this.push("static ");
|
||||
}
|
||||
|
||||
this._method(node, print);
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
exports.ComprehensionBlock = function (node, print) {
|
||||
export function ComprehensionBlock(node, print) {
|
||||
this.keyword("for");
|
||||
this.push("(");
|
||||
print(node.left);
|
||||
@ -7,7 +7,7 @@ exports.ComprehensionBlock = function (node, print) {
|
||||
this.push(")");
|
||||
};
|
||||
|
||||
exports.ComprehensionExpression = function (node, print) {
|
||||
export function ComprehensionExpression(node, print) {
|
||||
this.push(node.generator ? "(" : "[");
|
||||
|
||||
print.join(node.blocks, { separator: " " });
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
var isInteger = require("is-integer");
|
||||
var isNumber = require("lodash/lang/isNumber");
|
||||
var t = require("../../types");
|
||||
import isInteger from "is-integer";
|
||||
import isNumber from "lodash/lang/isNumber";
|
||||
import t from "../../types";
|
||||
|
||||
exports.UnaryExpression = function (node, print) {
|
||||
export function UnaryExpression(node, print) {
|
||||
var hasSpace = /[a-z]$/.test(node.operator);
|
||||
var arg = node.argument;
|
||||
|
||||
@ -17,9 +17,9 @@ exports.UnaryExpression = function (node, print) {
|
||||
this.push(node.operator);
|
||||
if (hasSpace) this.push(" ");
|
||||
print(node.argument);
|
||||
};
|
||||
}
|
||||
|
||||
exports.UpdateExpression = function (node, print) {
|
||||
export function UpdateExpression(node, print) {
|
||||
if (node.prefix) {
|
||||
this.push(node.operator);
|
||||
print(node.argument);
|
||||
@ -27,9 +27,9 @@ exports.UpdateExpression = function (node, print) {
|
||||
print(node.argument);
|
||||
this.push(node.operator);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.ConditionalExpression = function (node, print) {
|
||||
export function ConditionalExpression(node, print) {
|
||||
print(node.test);
|
||||
this.space();
|
||||
this.push("?");
|
||||
@ -39,25 +39,25 @@ exports.ConditionalExpression = function (node, print) {
|
||||
this.push(":");
|
||||
this.space();
|
||||
print(node.alternate);
|
||||
};
|
||||
}
|
||||
|
||||
exports.NewExpression = function (node, print) {
|
||||
export function NewExpression(node, print) {
|
||||
this.push("new ");
|
||||
print(node.callee);
|
||||
this.push("(");
|
||||
print.list(node.arguments);
|
||||
this.push(")");
|
||||
};
|
||||
}
|
||||
|
||||
exports.SequenceExpression = function (node, print) {
|
||||
export function SequenceExpression(node, print) {
|
||||
print.list(node.expressions);
|
||||
};
|
||||
}
|
||||
|
||||
exports.ThisExpression = function () {
|
||||
export function ThisExpression() {
|
||||
this.push("this");
|
||||
};
|
||||
}
|
||||
|
||||
exports.CallExpression = function (node, print) {
|
||||
export function CallExpression(node, print) {
|
||||
print(node.callee);
|
||||
|
||||
this.push("(");
|
||||
@ -80,7 +80,7 @@ exports.CallExpression = function (node, print) {
|
||||
}
|
||||
|
||||
this.push(")");
|
||||
};
|
||||
}
|
||||
|
||||
var buildYieldAwait = function (keyword) {
|
||||
return function (node, print) {
|
||||
@ -97,17 +97,17 @@ var buildYieldAwait = function (keyword) {
|
||||
};
|
||||
};
|
||||
|
||||
exports.YieldExpression = buildYieldAwait("yield");
|
||||
exports.AwaitExpression = buildYieldAwait("await");
|
||||
export var YieldExpression = buildYieldAwait("yield");
|
||||
export var AwaitExpression = buildYieldAwait("await");
|
||||
|
||||
exports.EmptyStatement = function () {
|
||||
export function EmptyStatement() {
|
||||
this.semicolon();
|
||||
};
|
||||
}
|
||||
|
||||
exports.ExpressionStatement = function (node, print) {
|
||||
export function ExpressionStatement(node, print) {
|
||||
print(node.expression);
|
||||
this.semicolon();
|
||||
};
|
||||
}
|
||||
|
||||
exports.BinaryExpression =
|
||||
exports.LogicalExpression =
|
||||
@ -123,7 +123,7 @@ exports.AssignmentExpression = function (node, print) {
|
||||
|
||||
var SCIENTIFIC_NOTATION = /e/i;
|
||||
|
||||
exports.MemberExpression = function (node, print) {
|
||||
export function MemberExpression(node, print) {
|
||||
var obj = node.object;
|
||||
print(obj);
|
||||
|
||||
@ -149,4 +149,4 @@ exports.MemberExpression = function (node, print) {
|
||||
this.push(".");
|
||||
print(node.property);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,43 +1,43 @@
|
||||
var t = require("../../types");
|
||||
var each = require("lodash/collection/each");
|
||||
import each from "lodash/collection/each";
|
||||
import t from "../../types";
|
||||
|
||||
exports.JSXAttribute = function (node, print) {
|
||||
export function JSXAttribute(node, print) {
|
||||
print(node.name);
|
||||
if (node.value) {
|
||||
this.push("=");
|
||||
print(node.value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.JSXIdentifier = function (node) {
|
||||
export function JSXIdentifier(node) {
|
||||
this.push(node.name);
|
||||
};
|
||||
}
|
||||
|
||||
exports.JSXNamespacedName = function (node, print) {
|
||||
export function JSXNamespacedName(node, print) {
|
||||
print(node.namespace);
|
||||
this.push(":");
|
||||
print(node.name);
|
||||
};
|
||||
}
|
||||
|
||||
exports.JSXMemberExpression = function (node, print) {
|
||||
export function JSXMemberExpression(node, print) {
|
||||
print(node.object);
|
||||
this.push(".");
|
||||
print(node.property);
|
||||
};
|
||||
}
|
||||
|
||||
exports.JSXSpreadAttribute = function (node, print) {
|
||||
export function JSXSpreadAttribute(node, print) {
|
||||
this.push("{...");
|
||||
print(node.argument);
|
||||
this.push("}");
|
||||
};
|
||||
}
|
||||
|
||||
exports.JSXExpressionContainer = function (node, print) {
|
||||
export function JSXExpressionContainer(node, print) {
|
||||
this.push("{");
|
||||
print(node.expression);
|
||||
this.push("}");
|
||||
};
|
||||
}
|
||||
|
||||
exports.JSXElement = function (node, print) {
|
||||
export function JSXElement(node, print) {
|
||||
var open = node.openingElement;
|
||||
print(open);
|
||||
if (open.selfClosing) return;
|
||||
@ -53,9 +53,9 @@ exports.JSXElement = function (node, print) {
|
||||
this.dedent();
|
||||
|
||||
print(node.closingElement);
|
||||
};
|
||||
}
|
||||
|
||||
exports.JSXOpeningElement = function (node, print) {
|
||||
export function JSXOpeningElement(node, print) {
|
||||
this.push("<");
|
||||
print(node.name);
|
||||
if (node.attributes.length > 0) {
|
||||
@ -63,12 +63,12 @@ exports.JSXOpeningElement = function (node, print) {
|
||||
print.join(node.attributes, { separator: " " });
|
||||
}
|
||||
this.push(node.selfClosing ? " />" : ">");
|
||||
};
|
||||
}
|
||||
|
||||
exports.JSXClosingElement = function (node, print) {
|
||||
export function JSXClosingElement(node, print) {
|
||||
this.push("</");
|
||||
print(node.name);
|
||||
this.push(">");
|
||||
};
|
||||
}
|
||||
|
||||
exports.JSXEmptyExpression = function () {};
|
||||
export function JSXEmptyExpression() {};
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
var t = require("../../types");
|
||||
import t from "../../types";
|
||||
|
||||
exports._params = function (node, print) {
|
||||
export function _params(node, print) {
|
||||
this.push("(");
|
||||
print.list(node.params);
|
||||
this.push(")");
|
||||
};
|
||||
}
|
||||
|
||||
exports._method = function (node, print) {
|
||||
export function _method(node, print) {
|
||||
var value = node.value;
|
||||
var kind = node.kind;
|
||||
var key = node.key;
|
||||
@ -32,7 +32,7 @@ exports._method = function (node, print) {
|
||||
this._params(value, print);
|
||||
this.push(" ");
|
||||
print(value.body);
|
||||
};
|
||||
}
|
||||
|
||||
exports.FunctionDeclaration =
|
||||
exports.FunctionExpression = function (node, print) {
|
||||
@ -52,7 +52,7 @@ exports.FunctionExpression = function (node, print) {
|
||||
print(node.body);
|
||||
};
|
||||
|
||||
exports.ArrowFunctionExpression = function (node, print) {
|
||||
export function ArrowFunctionExpression(node, print) {
|
||||
if (node.async) this.push("async ");
|
||||
|
||||
if (node.params.length === 1 && t.isIdentifier(node.params[0])) {
|
||||
@ -63,4 +63,4 @@ exports.ArrowFunctionExpression = function (node, print) {
|
||||
|
||||
this.push(" => ");
|
||||
print(node.body);
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,27 +1,27 @@
|
||||
var t = require("../../types");
|
||||
var each = require("lodash/collection/each");
|
||||
import each from "lodash/collection/each";
|
||||
import t from "../../types";
|
||||
|
||||
exports.ImportSpecifier = function (node, print) {
|
||||
export function ImportSpecifier(node, print) {
|
||||
if (t.isSpecifierDefault(node)) {
|
||||
print(t.getSpecifierName(node));
|
||||
} else {
|
||||
return exports.ExportSpecifier.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.ExportSpecifier = function (node, print) {
|
||||
export function ExportSpecifier(node, print) {
|
||||
print(node.id);
|
||||
if (node.name) {
|
||||
this.push(" as ");
|
||||
print(node.name);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.ExportBatchSpecifier = function () {
|
||||
export function ExportBatchSpecifier() {
|
||||
this.push("*");
|
||||
};
|
||||
}
|
||||
|
||||
exports.ExportDeclaration = function (node, print) {
|
||||
export function ExportDeclaration(node, print) {
|
||||
this.push("export ");
|
||||
|
||||
var specifiers = node.specifiers;
|
||||
@ -53,9 +53,9 @@ exports.ExportDeclaration = function (node, print) {
|
||||
}
|
||||
|
||||
this.ensureSemicolon();
|
||||
};
|
||||
}
|
||||
|
||||
exports.ImportDeclaration = function (node, print) {
|
||||
export function ImportDeclaration(node, print) {
|
||||
this.push("import ");
|
||||
|
||||
if (node.isType) {
|
||||
@ -90,9 +90,9 @@ exports.ImportDeclaration = function (node, print) {
|
||||
|
||||
print(node.source);
|
||||
this.semicolon();
|
||||
};
|
||||
}
|
||||
|
||||
exports.ImportBatchSpecifier = function (node, print) {
|
||||
export function ImportBatchSpecifier(node, print) {
|
||||
this.push("* as ");
|
||||
print(node.name);
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var each = require("lodash/collection/each");
|
||||
import each from "lodash/collection/each";
|
||||
|
||||
each(["BindMemberExpression", "BindFunctionExpression"], function (type) {
|
||||
exports[type] = function () {
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
var repeating = require("repeating");
|
||||
var t = require("../../types");
|
||||
import repeating from "repeating";
|
||||
import t from "../../types";
|
||||
|
||||
exports.WithStatement = function (node, print) {
|
||||
export function WithStatement(node, print) {
|
||||
this.keyword("with");
|
||||
this.push("(");
|
||||
print(node.object);
|
||||
this.push(")");
|
||||
print.block(node.body);
|
||||
};
|
||||
}
|
||||
|
||||
exports.IfStatement = function (node, print) {
|
||||
export function IfStatement(node, print) {
|
||||
this.keyword("if");
|
||||
this.push("(");
|
||||
print(node.test);
|
||||
@ -23,9 +23,9 @@ exports.IfStatement = function (node, print) {
|
||||
this.push("else ");
|
||||
print.indentOnComments(node.alternate);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.ForStatement = function (node, print) {
|
||||
export function ForStatement(node, print) {
|
||||
this.keyword("for");
|
||||
this.push("(");
|
||||
|
||||
@ -45,15 +45,15 @@ exports.ForStatement = function (node, print) {
|
||||
|
||||
this.push(")");
|
||||
print.block(node.body);
|
||||
};
|
||||
}
|
||||
|
||||
exports.WhileStatement = function (node, print) {
|
||||
export function WhileStatement(node, print) {
|
||||
this.keyword("while");
|
||||
this.push("(");
|
||||
print(node.test);
|
||||
this.push(")");
|
||||
print.block(node.body);
|
||||
};
|
||||
}
|
||||
|
||||
var buildForXStatement = function (op) {
|
||||
return function (node, print) {
|
||||
@ -67,10 +67,10 @@ var buildForXStatement = function (op) {
|
||||
};
|
||||
};
|
||||
|
||||
exports.ForInStatement = buildForXStatement("in");
|
||||
exports.ForOfStatement = buildForXStatement("of");
|
||||
export var ForInStatement = buildForXStatement("in");
|
||||
export var ForOfStatement = buildForXStatement("of");
|
||||
|
||||
exports.DoWhileStatement = function (node, print) {
|
||||
export function DoWhileStatement(node, print) {
|
||||
this.keyword("do");
|
||||
print(node.body);
|
||||
this.space();
|
||||
@ -78,7 +78,7 @@ exports.DoWhileStatement = function (node, print) {
|
||||
this.push("(");
|
||||
print(node.test);
|
||||
this.push(");");
|
||||
};
|
||||
}
|
||||
|
||||
var buildLabelStatement = function (prefix, key) {
|
||||
return function (node, print) {
|
||||
@ -94,17 +94,17 @@ var buildLabelStatement = function (prefix, key) {
|
||||
};
|
||||
};
|
||||
|
||||
exports.ContinueStatement = buildLabelStatement("continue");
|
||||
exports.ReturnStatement = buildLabelStatement("return", "argument");
|
||||
exports.BreakStatement = buildLabelStatement("break");
|
||||
export var ContinueStatement = buildLabelStatement("continue");
|
||||
export var ReturnStatement = buildLabelStatement("return", "argument");
|
||||
export var BreakStatement = buildLabelStatement("break");
|
||||
|
||||
exports.LabeledStatement = function (node, print) {
|
||||
export function LabeledStatement(node, print) {
|
||||
print(node.label);
|
||||
this.push(": ");
|
||||
print(node.body);
|
||||
};
|
||||
}
|
||||
|
||||
exports.TryStatement = function (node, print) {
|
||||
export function TryStatement(node, print) {
|
||||
this.keyword("try");
|
||||
print(node.block);
|
||||
this.space();
|
||||
@ -123,23 +123,23 @@ exports.TryStatement = function (node, print) {
|
||||
this.push("finally ");
|
||||
print(node.finalizer);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.CatchClause = function (node, print) {
|
||||
export function CatchClause(node, print) {
|
||||
this.keyword("catch");
|
||||
this.push("(");
|
||||
print(node.param);
|
||||
this.push(") ");
|
||||
print(node.body);
|
||||
};
|
||||
}
|
||||
|
||||
exports.ThrowStatement = function (node, print) {
|
||||
export function ThrowStatement(node, print) {
|
||||
this.push("throw ");
|
||||
print(node.argument);
|
||||
this.semicolon();
|
||||
};
|
||||
}
|
||||
|
||||
exports.SwitchStatement = function (node, print) {
|
||||
export function SwitchStatement(node, print) {
|
||||
this.keyword("switch");
|
||||
this.push("(");
|
||||
print(node.discriminant);
|
||||
@ -155,9 +155,9 @@ exports.SwitchStatement = function (node, print) {
|
||||
});
|
||||
|
||||
this.push("}");
|
||||
};
|
||||
}
|
||||
|
||||
exports.SwitchCase = function (node, print) {
|
||||
export function SwitchCase(node, print) {
|
||||
if (node.test) {
|
||||
this.push("case ");
|
||||
print(node.test);
|
||||
@ -170,13 +170,13 @@ exports.SwitchCase = function (node, print) {
|
||||
this.newline();
|
||||
print.sequence(node.consequent, { indent: true });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.DebuggerStatement = function () {
|
||||
export function DebuggerStatement() {
|
||||
this.push("debugger;");
|
||||
};
|
||||
}
|
||||
|
||||
exports.VariableDeclaration = function (node, print, parent) {
|
||||
export function VariableDeclaration(node, print, parent) {
|
||||
this.push(node.kind + " ");
|
||||
|
||||
var hasInits = false;
|
||||
@ -202,15 +202,15 @@ exports.VariableDeclaration = function (node, print, parent) {
|
||||
if (!t.isFor(parent)) {
|
||||
this.semicolon();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.PrivateDeclaration = function (node, print) {
|
||||
export function PrivateDeclaration(node, print) {
|
||||
this.push("private ");
|
||||
print.join(node.declarations, { separator: ", " });
|
||||
this.semicolon();
|
||||
};
|
||||
}
|
||||
|
||||
exports.VariableDeclarator = function (node, print) {
|
||||
export function VariableDeclarator(node, print) {
|
||||
if (node.init) {
|
||||
print(node.id);
|
||||
this.space();
|
||||
@ -220,4 +220,4 @@ exports.VariableDeclarator = function (node, print) {
|
||||
} else {
|
||||
print(node.id);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
var each = require("lodash/collection/each");
|
||||
import each from "lodash/collection/each";
|
||||
|
||||
exports.TaggedTemplateExpression = function (node, print) {
|
||||
export function TaggedTemplateExpression(node, print) {
|
||||
print(node.tag);
|
||||
print(node.quasi);
|
||||
};
|
||||
}
|
||||
|
||||
exports.TemplateElement = function (node) {
|
||||
export function TemplateElement(node) {
|
||||
this._push(node.value.raw);
|
||||
};
|
||||
}
|
||||
|
||||
exports.TemplateLiteral = function (node, print) {
|
||||
export function TemplateLiteral(node, print) {
|
||||
this.push("`");
|
||||
|
||||
var quasis = node.quasis;
|
||||
@ -26,4 +26,4 @@ exports.TemplateLiteral = function (node, print) {
|
||||
});
|
||||
|
||||
this._push("`");
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
var each = require("lodash/collection/each");
|
||||
import each from "lodash/collection/each";
|
||||
|
||||
exports.Identifier = function (node) {
|
||||
export function Identifier(node) {
|
||||
this.push(node.name);
|
||||
};
|
||||
}
|
||||
|
||||
exports.RestElement =
|
||||
exports.SpreadElement =
|
||||
@ -11,11 +11,11 @@ exports.SpreadProperty = function (node, print) {
|
||||
print(node.argument);
|
||||
};
|
||||
|
||||
exports.VirtualPropertyExpression = function (node, print) {
|
||||
export function VirtualPropertyExpression(node, print) {
|
||||
print(node.object);
|
||||
this.push("::");
|
||||
print(node.property);
|
||||
};
|
||||
}
|
||||
|
||||
exports.ObjectExpression =
|
||||
exports.ObjectPattern = function (node, print) {
|
||||
@ -34,7 +34,7 @@ exports.ObjectPattern = function (node, print) {
|
||||
}
|
||||
};
|
||||
|
||||
exports.Property = function (node, print) {
|
||||
export function Property(node, print) {
|
||||
if (node.method || node.kind === "get" || node.kind === "set") {
|
||||
this._method(node, print);
|
||||
} else {
|
||||
@ -51,7 +51,7 @@ exports.Property = function (node, print) {
|
||||
this.space();
|
||||
print(node.value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.ArrayExpression =
|
||||
exports.ArrayPattern = function (node, print) {
|
||||
@ -78,7 +78,7 @@ exports.ArrayPattern = function (node, print) {
|
||||
this.push("]");
|
||||
};
|
||||
|
||||
exports.Literal = function (node) {
|
||||
export function Literal(node) {
|
||||
var val = node.value;
|
||||
var type = typeof val;
|
||||
|
||||
@ -100,4 +100,4 @@ exports.Literal = function (node) {
|
||||
} else if (val === null) {
|
||||
this.push("null");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
var detectIndent = require("detect-indent");
|
||||
var Whitespace = require("./whitespace");
|
||||
var repeating = require("repeating");
|
||||
var SourceMap = require("./source-map");
|
||||
var Position = require("./position");
|
||||
var messages = require("../messages");
|
||||
var Buffer = require("./buffer");
|
||||
var extend = require("lodash/object/extend");
|
||||
var each = require("lodash/collection/each");
|
||||
var n = require("./node");
|
||||
var t = require("../types");
|
||||
import detectIndent from "detect-indent";
|
||||
import Whitespace from "./whitespace";
|
||||
import repeating from "repeating";
|
||||
import SourceMap from "./source-map";
|
||||
import Position from "./position";
|
||||
import * as messages from "../messages";
|
||||
import Buffer from "./buffer";
|
||||
import extend from "lodash/object/extend";
|
||||
import each from "lodash/collection/each";
|
||||
import n from "./node";
|
||||
import t from "../types";
|
||||
|
||||
class CodeGenerator {
|
||||
constructor(ast, opts, code) {
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
var whitespace = require("./whitespace");
|
||||
var parens = require("./parentheses");
|
||||
var each = require("lodash/collection/each");
|
||||
var some = require("lodash/collection/some");
|
||||
var t = require("../../types");
|
||||
import whitespace from "./whitespace";
|
||||
import * as parens from "./parentheses";
|
||||
import each from "lodash/collection/each";
|
||||
import some from "lodash/collection/some";
|
||||
import t from "../../types";
|
||||
|
||||
var find = function (obj, node, parent) {
|
||||
if (!obj) return;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
var t = require("../../types");
|
||||
var each = require("lodash/collection/each");
|
||||
import each from "lodash/collection/each";
|
||||
import t from "../../types";
|
||||
|
||||
var PRECEDENCE = {};
|
||||
|
||||
@ -21,14 +21,14 @@ each([
|
||||
});
|
||||
});
|
||||
|
||||
exports.UpdateExpression = function (node, parent) {
|
||||
export function UpdateExpression(node, parent) {
|
||||
if (t.isMemberExpression(parent) && parent.object === node) {
|
||||
// (foo++).test()
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.ObjectExpression = function (node, parent) {
|
||||
export function ObjectExpression(node, parent) {
|
||||
if (t.isExpressionStatement(parent)) {
|
||||
// ({ foo: "bar" });
|
||||
return true;
|
||||
@ -40,9 +40,9 @@ exports.ObjectExpression = function (node, parent) {
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
exports.Binary = function (node, parent) {
|
||||
export function Binary(node, parent) {
|
||||
if ((t.isCallExpression(parent) || t.isNewExpression(parent)) && parent.callee === node) {
|
||||
return true;
|
||||
}
|
||||
@ -70,9 +70,9 @@ exports.Binary = function (node, parent) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.BinaryExpression = function (node, parent) {
|
||||
export function BinaryExpression(node, parent) {
|
||||
if (node.operator === "in") {
|
||||
// var i = (1 in []);
|
||||
if (t.isVariableDeclarator(parent)) {
|
||||
@ -84,9 +84,9 @@ exports.BinaryExpression = function (node, parent) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.SequenceExpression = function (node, parent) {
|
||||
export function SequenceExpression(node, parent) {
|
||||
if (t.isForStatement(parent)) {
|
||||
// Although parentheses wouldn't hurt around sequence
|
||||
// expressions in the head of for loops, traditional style
|
||||
@ -102,9 +102,9 @@ exports.SequenceExpression = function (node, parent) {
|
||||
// Otherwise err on the side of overparenthesization, adding
|
||||
// explicit exceptions above if this proves overzealous.
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
exports.YieldExpression = function (node, parent) {
|
||||
export function YieldExpression(node, parent) {
|
||||
return t.isBinary(parent) ||
|
||||
t.isUnaryLike(parent) ||
|
||||
t.isCallExpression(parent) ||
|
||||
@ -112,17 +112,17 @@ exports.YieldExpression = function (node, parent) {
|
||||
t.isNewExpression(parent) ||
|
||||
t.isConditionalExpression(parent) ||
|
||||
t.isYieldExpression(parent);
|
||||
};
|
||||
}
|
||||
|
||||
exports.ClassExpression = function (node, parent) {
|
||||
export function ClassExpression(node, parent) {
|
||||
return t.isExpressionStatement(parent);
|
||||
};
|
||||
}
|
||||
|
||||
exports.UnaryLike = function (node, parent) {
|
||||
export function UnaryLike(node, parent) {
|
||||
return t.isMemberExpression(parent) && parent.object === node;
|
||||
};
|
||||
}
|
||||
|
||||
exports.FunctionExpression = function (node, parent) {
|
||||
export function FunctionExpression(node, parent) {
|
||||
// function () {};
|
||||
if (t.isExpressionStatement(parent)) {
|
||||
return true;
|
||||
@ -137,7 +137,7 @@ exports.FunctionExpression = function (node, parent) {
|
||||
if (t.isCallExpression(parent) && parent.callee === node) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.AssignmentExpression =
|
||||
exports.ConditionalExpression = function (node, parent) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
var isBoolean = require("lodash/lang/isBoolean");
|
||||
var each = require("lodash/collection/each");
|
||||
var map = require("lodash/collection/map");
|
||||
var t = require("../../types");
|
||||
import isBoolean from "lodash/lang/isBoolean";
|
||||
import each from "lodash/collection/each";
|
||||
import map from "lodash/collection/map";
|
||||
import t from "../../types";
|
||||
|
||||
var crawl = function (node, state) {
|
||||
state ||= {};
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
var sourceMap = require("source-map");
|
||||
var t = require("../types");
|
||||
import sourceMap from "source-map";
|
||||
import t from "../types";
|
||||
|
||||
export default class SourceMap {
|
||||
constructor(position, opts, code) {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var sortBy = require("lodash/collection/sortBy");
|
||||
import sortBy from "lodash/collection/sortBy";
|
||||
|
||||
/**
|
||||
* Returns `i`th number from `base`, continuing from 0 when `max` is reached.
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
var lineNumbers = require("line-numbers");
|
||||
var repeating = require("repeating");
|
||||
var jsTokens = require("js-tokens");
|
||||
var esutils = require("esutils");
|
||||
var chalk = require("chalk");
|
||||
var ary = require("lodash/function/ary");
|
||||
import lineNumbers from "line-numbers";
|
||||
import repeating from "repeating";
|
||||
import jsTokens from "js-tokens";
|
||||
import esutils from "esutils";
|
||||
import chalk from "chalk";
|
||||
import ary from "lodash/function/ary";
|
||||
|
||||
var defs = {
|
||||
string: chalk.red,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var t = require("../types");
|
||||
import t from "../types";
|
||||
|
||||
module.exports = function (ast, comments, tokens) {
|
||||
if (ast && ast.type === "Program") {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
var normalizeAst = require("./normalize-ast");
|
||||
var estraverse = require("estraverse");
|
||||
var codeFrame = require("./code-frame");
|
||||
var acorn = require("acorn-babel");
|
||||
import normalizeAst from "./normalize-ast";
|
||||
import estraverse from "estraverse";
|
||||
import codeFrame from "./code-frame";
|
||||
import acorn from "acorn-babel";
|
||||
|
||||
module.exports = function (opts, code, callback) {
|
||||
try {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
var util = require("util");
|
||||
import * as util from "util";
|
||||
|
||||
exports.messages = {
|
||||
export var messages = {
|
||||
tailCallReassignmentDeopt: "Function reference has been reassigned so it's probably be dereferenced so we can't optimise this with confidence",
|
||||
JSXNamespacedTags: "Namespace tags are not supported. ReactJSX is not XML.",
|
||||
classesIllegalBareSuper: "Illegal use of bare super",
|
||||
@ -21,7 +21,7 @@ exports.messages = {
|
||||
codeGeneratorDeopt: "Note: The code generator has deoptimised the styling of $1 as it exceeds the max of $2."
|
||||
};
|
||||
|
||||
exports.get = function (key) {
|
||||
export function get(key) {
|
||||
var msg = exports.messages[key];
|
||||
if (!msg) throw new ReferenceError("Unknown message `" + key + "`");
|
||||
|
||||
@ -34,9 +34,9 @@ exports.get = function (key) {
|
||||
return msg.replace(/\$(\d+)/g, function (str, i) {
|
||||
return args[--i];
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
exports.parseArgs = function (args) {
|
||||
export function parseArgs(args) {
|
||||
return args.map(function (val) {
|
||||
if (val != null && val.inspect) {
|
||||
return val.inspect();
|
||||
@ -48,4 +48,4 @@ exports.parseArgs = function (args) {
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
var extend = require("lodash/object/extend");
|
||||
var t = require("./types");
|
||||
import estraverse from "estraverse";
|
||||
import extend from "lodash/object/extend";
|
||||
import types from "ast-types";
|
||||
import t from "./types";
|
||||
|
||||
// estraverse
|
||||
|
||||
var estraverse = require("estraverse");
|
||||
extend(estraverse.VisitorKeys, t.VISITOR_KEYS);
|
||||
|
||||
// regenerator-babel/ast-types
|
||||
|
||||
var types = require("ast-types");
|
||||
var def = types.Type.def;
|
||||
var or = types.Type.or;
|
||||
|
||||
|
||||
@ -3,5 +3,5 @@ if (global._babelPolyfill) {
|
||||
}
|
||||
global._babelPolyfill = true;
|
||||
|
||||
require("core-js/shim");
|
||||
require("regenerator-babel/runtime");
|
||||
import "core-js/shim";
|
||||
import "regenerator-babel/runtime";
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
var sourceMapToComment = require("source-map-to-comment");
|
||||
var shebangRegex = require("shebang-regex");
|
||||
var isFunction = require("lodash/lang/isFunction");
|
||||
var transform = require("./index");
|
||||
var generate = require("../generation");
|
||||
var defaults = require("lodash/object/defaults");
|
||||
var includes = require("lodash/collection/includes");
|
||||
var assign = require("lodash/object/assign");
|
||||
var parse = require("../helpers/parse");
|
||||
var Scope = require("../traversal/scope");
|
||||
var slash = require("slash");
|
||||
var util = require("../util");
|
||||
var path = require("path");
|
||||
var each = require("lodash/collection/each");
|
||||
var t = require("../types");
|
||||
import sourceMapToComment from "source-map-to-comment";
|
||||
import shebangRegex from "shebang-regex";
|
||||
import isFunction from "lodash/lang/isFunction";
|
||||
import transform from "./index";
|
||||
import generate from "../generation";
|
||||
import defaults from "lodash/object/defaults";
|
||||
import includes from "lodash/collection/includes";
|
||||
import assign from "lodash/object/assign";
|
||||
import parse from "../helpers/parse";
|
||||
import Scope from "../traversal/scope";
|
||||
import slash from "slash";
|
||||
import * as util from "../util";
|
||||
import path from "path";
|
||||
import each from "lodash/collection/each";
|
||||
import t from "../types";
|
||||
|
||||
var checkTransformerVisitor = {
|
||||
enter(node, parent, scope, state) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
var explode = require("./explode-assignable-expression");
|
||||
var t = require("../../types");
|
||||
import explode from "./explode-assignable-expression";
|
||||
import t from "../../types";
|
||||
|
||||
module.exports = function (exports, opts) {
|
||||
var isAssignment = function (node) {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var t = require("../../types");
|
||||
import t from "../../types";
|
||||
|
||||
module.exports = function build(node, buildBody) {
|
||||
var self = node.blocks.shift();
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
var explode = require("./explode-assignable-expression");
|
||||
var t = require("../../types");
|
||||
import explode from "./explode-assignable-expression";
|
||||
import t from "../../types";
|
||||
|
||||
module.exports = function (exports, opts) {
|
||||
var buildAssignment = function (left, right) {
|
||||
|
||||
@ -3,11 +3,11 @@
|
||||
|
||||
// jsx
|
||||
|
||||
var isString = require("lodash/lang/isString");
|
||||
var messages = require("../../messages");
|
||||
var esutils = require("esutils");
|
||||
var react = require("./react");
|
||||
var t = require("../../types");
|
||||
import isString from "lodash/lang/isString";
|
||||
import * as messages from "../../messages";
|
||||
import esutils from "esutils";
|
||||
import react from "./react";
|
||||
import t from "../../types";
|
||||
|
||||
module.exports = function (exports, opts) {
|
||||
exports.check = function (node) {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
var cloneDeep = require("lodash/lang/cloneDeep");
|
||||
var traverse = require("../../traversal");
|
||||
var clone = require("lodash/lang/clone");
|
||||
var each = require("lodash/collection/each");
|
||||
var has = require("lodash/object/has");
|
||||
var t = require("../../types");
|
||||
import cloneDeep from "lodash/lang/cloneDeep";
|
||||
import traverse from "../../traversal";
|
||||
import clone from "lodash/lang/clone";
|
||||
import each from "lodash/collection/each";
|
||||
import has from "lodash/object/has";
|
||||
import t from "../../types";
|
||||
|
||||
exports.push = function (mutatorMap, key, kind, computed, value) {
|
||||
var alias;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var t = require("../../types");
|
||||
import t from "../../types";
|
||||
|
||||
var getObjRef = function (node, nodes, file, scope) {
|
||||
var ref;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var t = require("../../types");
|
||||
import t from "../../types";
|
||||
|
||||
module.exports = function (node) {
|
||||
var lastNonDefault = 0;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
var getFunctionArity = require("./get-function-arity");
|
||||
var util = require("../../util");
|
||||
var t = require("../../types");
|
||||
import getFunctionArity from "./get-function-arity";
|
||||
import * as util from "../../util";
|
||||
import t from "../../types";
|
||||
|
||||
var visitor = {
|
||||
enter(node, parent, scope, state) {
|
||||
|
||||
2
src/babel/transformation/helpers/react.js
vendored
2
src/babel/transformation/helpers/react.js
vendored
@ -1,4 +1,4 @@
|
||||
var t = require("../../types");
|
||||
import t from "../../types";
|
||||
|
||||
var isCreateClassCallExpression = t.buildMatchMemberExpression("React.createClass");
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var t = require("../../types");
|
||||
import t from "../../types";
|
||||
|
||||
var visitor = {
|
||||
enter(node) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
module.exports = ReplaceSupers;
|
||||
|
||||
var messages = require("../../messages");
|
||||
var t = require("../../types");
|
||||
import * as messages from "../../messages";
|
||||
import t from "../../types";
|
||||
|
||||
|
||||
var isIllegalBareSuper = function (node, parent) {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var t = require("../../types");
|
||||
import t from "../../types";
|
||||
|
||||
exports.has = function (node) {
|
||||
var first = node.body[0];
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
module.exports = transform;
|
||||
import normalizeAst from "../helpers/normalize-ast";
|
||||
import Transformer from "./transformer";
|
||||
import object from "../helpers/object";
|
||||
import File from "./file";
|
||||
import each from "lodash/collection/each";
|
||||
|
||||
var normalizeAst = require("../helpers/normalize-ast");
|
||||
var Transformer = require("./transformer");
|
||||
var object = require("../helpers/object");
|
||||
var File = require("./file");
|
||||
var each = require("lodash/collection/each");
|
||||
|
||||
function transform(code, opts) {
|
||||
export default function transform(code, opts) {
|
||||
var file = new File(opts);
|
||||
return file.parse(code);
|
||||
}
|
||||
@ -53,7 +51,7 @@ transform.namespaces = object();
|
||||
transform.deprecatedTransformerMap = require("./transformers/deprecated");
|
||||
transform.moduleFormatters = require("./modules");
|
||||
|
||||
var rawTransformers = require("./transformers");
|
||||
import rawTransformers from "./transformers";
|
||||
|
||||
each(rawTransformers, function (transformer, key) {
|
||||
var namespace = key.split(".")[0];
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
var messages = require("../../messages");
|
||||
var extend = require("lodash/object/extend");
|
||||
var object = require("../../helpers/object");
|
||||
var util = require("../../util");
|
||||
var t = require("../../types");
|
||||
import * as messages from "../../messages";
|
||||
import extend from "lodash/object/extend";
|
||||
import object from "../../helpers/object";
|
||||
import * as util from "../../util";
|
||||
import t from "../../types";
|
||||
|
||||
var remapVisitor = {
|
||||
enter(node, parent, scope, formatter) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
var util = require("../../util");
|
||||
import * as util from "../../util";
|
||||
|
||||
module.exports = function (Parent) {
|
||||
export default function (Parent) {
|
||||
var Constructor = function () {
|
||||
this.noInteropRequireImport = true;
|
||||
this.noInteropRequireExport = true;
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
var DefaultFormatter = require("./_default");
|
||||
var CommonFormatter = require("./common");
|
||||
var includes = require("lodash/collection/includes");
|
||||
var values = require("lodash/object/values");
|
||||
var util = require("../../util");
|
||||
var t = require("../../types");
|
||||
import DefaultFormatter from "./_default";
|
||||
import CommonFormatter from "./common";
|
||||
import includes from "lodash/collection/includes";
|
||||
import values from "lodash/object/values";
|
||||
import * as util from "../../util";
|
||||
import t from "../../types";
|
||||
|
||||
export default class AMDFormatter extends DefaultFormatter {
|
||||
init = CommonFormatter.prototype.init;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
var DefaultFormatter = require("./_default");
|
||||
var includes = require("lodash/collection/includes");
|
||||
var util = require("../../util");
|
||||
var t = require("../../types");
|
||||
import DefaultFormatter from "./_default";
|
||||
import includes from "lodash/collection/includes";
|
||||
import * as util from "../../util";
|
||||
import t from "../../types";
|
||||
|
||||
export default class CommonJSFormatter extends DefaultFormatter {
|
||||
init() {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var t = require("../../types");
|
||||
import t from "../../types";
|
||||
|
||||
export default class IgnoreFormatter {
|
||||
exportDeclaration(node, nodes) {
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
var DefaultFormatter = require("./_default");
|
||||
var AMDFormatter = require("./amd");
|
||||
var util = require("../../util");
|
||||
var last = require("lodash/array/last");
|
||||
var each = require("lodash/collection/each");
|
||||
var map = require("lodash/collection/map");
|
||||
var t = require("../../types");
|
||||
import DefaultFormatter from "./_default";
|
||||
import AMDFormatter from "./amd";
|
||||
import * as util from "../../util";
|
||||
import last from "lodash/array/last";
|
||||
import each from "lodash/collection/each";
|
||||
import map from "lodash/collection/map";
|
||||
import t from "../../types";
|
||||
|
||||
var hoistVariablesVisitor = {
|
||||
enter(node, parent, scope, hoistDeclarators) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
var AMDFormatter = require("./amd");
|
||||
var values = require("lodash/object/values");
|
||||
var util = require("../../util");
|
||||
var t = require("../../types");
|
||||
import AMDFormatter from "./amd";
|
||||
import values from "lodash/object/values";
|
||||
import * as util from "../../util";
|
||||
import t from "../../types";
|
||||
|
||||
export default class UMDFormatter extends AMDFormatter {
|
||||
transform(program) {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var includes = require("lodash/collection/includes");
|
||||
import includes from "lodash/collection/includes";
|
||||
|
||||
/**
|
||||
* This class is responsible for traversing over the provided `File`s
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
var TransformerPass = require("./transformer-pass");
|
||||
var isFunction = require("lodash/lang/isFunction");
|
||||
var traverse = require("../traversal");
|
||||
var isObject = require("lodash/lang/isObject");
|
||||
var assign = require("lodash/object/assign");
|
||||
var each = require("lodash/collection/each");
|
||||
import TransformerPass from "./transformer-pass";
|
||||
import isFunction from "lodash/lang/isFunction";
|
||||
import traverse from "../traversal";
|
||||
import isObject from "lodash/lang/isObject";
|
||||
import assign from "lodash/object/assign";
|
||||
import each from "lodash/collection/each";
|
||||
|
||||
/**
|
||||
* This is the class responsible for normalising a transformers handlers
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
var t = require("../../../types");
|
||||
import t from "../../../types";
|
||||
|
||||
exports.MemberExpression = function (node) {
|
||||
export function MemberExpression(node) {
|
||||
var prop = node.property;
|
||||
if (node.computed && t.isLiteral(prop) && t.isValidIdentifier(prop.value)) {
|
||||
// foo["bar"] => foo.bar
|
||||
@ -11,4 +11,4 @@ exports.MemberExpression = function (node) {
|
||||
node.property = t.literal(prop.name);
|
||||
node.computed = true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
var t = require("../../../types");
|
||||
import t from "../../../types";
|
||||
|
||||
exports.Property = function (node) {
|
||||
export function Property(node) {
|
||||
var key = node.key;
|
||||
if (t.isLiteral(key) && t.isValidIdentifier(key.value)) {
|
||||
// "foo": "bar" -> foo: "bar"
|
||||
@ -10,4 +10,4 @@ exports.Property = function (node) {
|
||||
// default: "bar" -> "default": "bar"
|
||||
node.key = t.literal(key.name);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
var defineMap = require("../../helpers/define-map");
|
||||
var t = require("../../../types");
|
||||
import defineMap from "../../helpers/define-map";
|
||||
import t from "../../../types";
|
||||
|
||||
exports.check = function (node) {
|
||||
export function check(node) {
|
||||
return t.isProperty(node) && (node.kind === "get" || node.kind === "set");
|
||||
};
|
||||
}
|
||||
|
||||
exports.ObjectExpression = function (node) {
|
||||
export function ObjectExpression(node) {
|
||||
var mutatorMap = {};
|
||||
var hasAny = false;
|
||||
|
||||
@ -25,4 +25,4 @@ exports.ObjectExpression = function (node) {
|
||||
t.memberExpression(t.identifier("Object"), t.identifier("defineProperties")),
|
||||
[node, defineMap.build(mutatorMap)]
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
var t = require("../../../types");
|
||||
import t from "../../../types";
|
||||
|
||||
exports.check = t.isArrowFunctionExpression;
|
||||
|
||||
exports.ArrowFunctionExpression = function (node) {
|
||||
export function ArrowFunctionExpression(node) {
|
||||
t.ensureBlock(node);
|
||||
|
||||
node._aliasFunction = "arrow";
|
||||
@ -10,4 +10,4 @@ exports.ArrowFunctionExpression = function (node) {
|
||||
node.type = "FunctionExpression";
|
||||
|
||||
return node;
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var t = require("../../../types");
|
||||
import t from "../../../types";
|
||||
|
||||
var visitor = {
|
||||
enter(node, parent, scope, state) {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
var traverse = require("../../../traversal");
|
||||
var object = require("../../../helpers/object");
|
||||
var util = require("../../../util");
|
||||
var t = require("../../../types");
|
||||
var values = require("lodash/object/values");
|
||||
var extend = require("lodash/object/extend");
|
||||
import traverse from "../../../traversal";
|
||||
import object from "../../../helpers/object";
|
||||
import * as util from "../../../util";
|
||||
import t from "../../../types";
|
||||
import values from "lodash/object/values";
|
||||
import extend from "lodash/object/extend";
|
||||
|
||||
exports.check = function (node) {
|
||||
return t.isVariableDeclaration(node) && (node.kind === "let" || node.kind === "const");
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
var ReplaceSupers = require("../../helpers/replace-supers");
|
||||
var nameMethod = require("../../helpers/name-method");
|
||||
var defineMap = require("../../helpers/define-map");
|
||||
var messages = require("../../../messages");
|
||||
var util = require("../../../util");
|
||||
var t = require("../../../types");
|
||||
import ReplaceSupers from "../../helpers/replace-supers";
|
||||
import nameMethod from "../../helpers/name-method";
|
||||
import defineMap from "../../helpers/define-map";
|
||||
import * as messages from "../../../messages";
|
||||
import * as util from "../../../util";
|
||||
import t from "../../../types";
|
||||
|
||||
exports.check = t.isClass;
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
var messages = require("../../../messages");
|
||||
var t = require("../../../types");
|
||||
import * as messages from "../../../messages";
|
||||
import t from "../../../types";
|
||||
|
||||
exports.check = function (node) {
|
||||
return t.isVariableDeclaration(node, { kind: "const" });
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
var messages = require("../../../messages");
|
||||
var t = require("../../../types");
|
||||
import * as messages from "../../../messages";
|
||||
import t from "../../../types";
|
||||
|
||||
exports.check = t.isPattern;
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
var messages = require("../../../messages");
|
||||
var util = require("../../../util");
|
||||
var t = require("../../../types");
|
||||
import * as messages from "../../../messages";
|
||||
import * as util from "../../../util";
|
||||
import t from "../../../types";
|
||||
|
||||
exports.check = t.isForOfStatement;
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var t = require("../../../types");
|
||||
import t from "../../../types";
|
||||
|
||||
exports.check = require("../internal/modules").check;
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
var ReplaceSupers = require("../../helpers/replace-supers");
|
||||
var t = require("../../../types");
|
||||
import ReplaceSupers from "../../helpers/replace-supers";
|
||||
import t from "../../../types";
|
||||
|
||||
exports.check = function (node) {
|
||||
return t.isIdentifier(node, { name: "super" });
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
var util = require("../../../util");
|
||||
var t = require("../../../types");
|
||||
import * as util from "../../../util";
|
||||
import t from "../../../types";
|
||||
|
||||
exports.check = function (node) {
|
||||
return t.isFunction(node) && hasDefaults(node);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
var isNumber = require("lodash/lang/isNumber");
|
||||
var util = require("../../../util");
|
||||
var t = require("../../../types");
|
||||
import isNumber from "lodash/lang/isNumber";
|
||||
import * as util from "../../../util";
|
||||
import t from "../../../types";
|
||||
|
||||
exports.check = t.isRestElement;
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var t = require("../../../types");
|
||||
import t from "../../../types";
|
||||
|
||||
exports.check = function (node) {
|
||||
return t.isProperty(node) && node.computed;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
var clone = require("lodash/lang/clone");
|
||||
var t = require("../../../types");
|
||||
import clone from "lodash/lang/clone";
|
||||
import t from "../../../types";
|
||||
|
||||
exports.check = function (node) {
|
||||
return t.isProperty(node) && (node.method || node.shorthand);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
var includes = require("lodash/collection/includes");
|
||||
var t = require("../../../types");
|
||||
import includes from "lodash/collection/includes";
|
||||
import t from "../../../types";
|
||||
|
||||
exports.check = t.isSpreadElement;
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
var reduceRight = require("lodash/collection/reduceRight");
|
||||
var messages = require("../../../messages");
|
||||
var flatten = require("lodash/array/flatten");
|
||||
var util = require("../../../util");
|
||||
var map = require("lodash/collection/map");
|
||||
var t = require("../../../types");
|
||||
import reduceRight from "lodash/collection/reduceRight";
|
||||
import * as messages from "../../../messages";
|
||||
import flatten from "lodash/array/flatten";
|
||||
import * as util from "../../../util";
|
||||
import map from "lodash/collection/map";
|
||||
import t from "../../../types";
|
||||
|
||||
exports.Function = function (node, parent, scope, file) {
|
||||
var tailCall = new TailCallTransformer(node, scope, file);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var t = require("../../../types");
|
||||
import t from "../../../types";
|
||||
|
||||
var buildBinaryExpression = function (left, right) {
|
||||
return t.binaryExpression("+", left, right);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
var rewritePattern = require("regexpu/rewrite-pattern");
|
||||
var pull = require("lodash/array/pull");
|
||||
var t = require("../../../types");
|
||||
import rewritePattern from "regexpu/rewrite-pattern";
|
||||
import pull from "lodash/array/pull";
|
||||
import t from "../../../types";
|
||||
|
||||
exports.check = function (node) {
|
||||
return t.isLiteral(node) && node.regex && node.regex.flags.indexOf("u") >= 0;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// https://github.com/zenparsing/es-abstract-refs
|
||||
|
||||
var util = require("../../../util");
|
||||
var t = require("../../../types");
|
||||
import * as util from "../../../util";
|
||||
import t from "../../../types";
|
||||
|
||||
exports.experimental = true;
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
var buildComprehension = require("../../helpers/build-comprehension");
|
||||
var traverse = require("../../../traversal");
|
||||
var util = require("../../../util");
|
||||
var t = require("../../../types");
|
||||
import buildComprehension from "../../helpers/build-comprehension";
|
||||
import traverse from "../../../traversal";
|
||||
import * as util from "../../../util";
|
||||
import t from "../../../types";
|
||||
|
||||
exports.experimental = true;
|
||||
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
|
||||
exports.experimental = true;
|
||||
|
||||
var build = require("../../helpers/build-binary-assignment-operator-transformer");
|
||||
var t = require("../../../types");
|
||||
import build from "../../helpers/build-binary-assignment-operator-transformer";
|
||||
import t from "../../../types";
|
||||
|
||||
var MATH_POW = t.memberExpression(t.identifier("Math"), t.identifier("pow"));
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// https://github.com/sebmarkbage/ecmascript-rest-spread
|
||||
|
||||
var t = require("../../../types");
|
||||
import t from "../../../types";
|
||||
|
||||
exports.experimental = true;
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
useStrict: require("./other/use-strict"),
|
||||
|
||||
"validation.undeclaredVariableCheck": require("./validation/undeclared-variable-check"),
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var t = require("../../../types");
|
||||
import t from "../../../types";
|
||||
|
||||
var functionChildrenVisitor = {
|
||||
enter(node, parent, scope, state) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
var groupBy = require("lodash/collection/groupBy");
|
||||
var flatten = require("lodash/array/flatten");
|
||||
var values = require("lodash/object/values");
|
||||
import groupBy from "lodash/collection/groupBy";
|
||||
import flatten from "lodash/array/flatten";
|
||||
import values from "lodash/object/values";
|
||||
|
||||
// Priority:
|
||||
//
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
var useStrict = require("../../helpers/use-strict");
|
||||
var t = require("../../../types");
|
||||
import useStrict from "../../helpers/use-strict";
|
||||
import t from "../../../types";
|
||||
|
||||
exports.secondPass = true;
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var useStrict = require("../../helpers/use-strict");
|
||||
import useStrict from "../../helpers/use-strict";
|
||||
|
||||
exports.Program = function (program, parent, scope, file) {
|
||||
if (!file.transformers["es6.modules"].canRun()) return;
|
||||
|
||||
@ -4,23 +4,21 @@
|
||||
// a generator function as a default then regenerator will destroy the export
|
||||
// declaration and leave a variable declaration in it's place... yeah, handy.
|
||||
|
||||
var t = require("../../../types");
|
||||
import t from "../../../types";
|
||||
|
||||
var resolveModuleSource = function (node, parent, scope, file) {
|
||||
export function check(node) {
|
||||
return t.isImportDeclaration(node) || t.isExportDeclaration(node);
|
||||
}
|
||||
|
||||
export function ImportDeclaration(node, parent, scope, file) {
|
||||
var resolveModuleSource = file.opts.resolveModuleSource;
|
||||
if (node.source && resolveModuleSource) {
|
||||
node.source.value = resolveModuleSource(node.source.value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.check = function (node) {
|
||||
return t.isImportDeclaration(node) || t.isExportDeclaration(node);
|
||||
};
|
||||
|
||||
exports.ImportDeclaration = resolveModuleSource;
|
||||
|
||||
exports.ExportDeclaration = function (node, parent, scope) {
|
||||
resolveModuleSource.apply(null, arguments);
|
||||
export function ExportDeclaration(node, parent, scope) {
|
||||
ImportDeclaration.apply(this, arguments);
|
||||
|
||||
// flow type
|
||||
if (node.isType) return;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
var t = require("../../../types");
|
||||
import t from "../../../types";
|
||||
|
||||
exports.Program = function (program, parent, scope, file) {
|
||||
export function Program(program, parent, scope, file) {
|
||||
if (file.transformers.useStrict.canRun()) {
|
||||
program.body.unshift(t.expressionStatement(t.literal("use strict")));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
var t = require("../../../types");
|
||||
import t from "../../../types";
|
||||
|
||||
exports.optional = true;
|
||||
export var optional = true;
|
||||
|
||||
exports.ExpressionStatement = function (node) {
|
||||
export function ExpressionStatement(node) {
|
||||
// remove consequence-less expressions such as local variables and literals
|
||||
// note: will remove directives
|
||||
//
|
||||
@ -14,9 +14,9 @@ exports.ExpressionStatement = function (node) {
|
||||
if (t.isLiteral(expr) || (t.isIdentifier(node) && t.hasBinding(node.name))) {
|
||||
this.remove();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.IfStatement = {
|
||||
export var IfStatement = {
|
||||
exit(node) {
|
||||
// todo: in scenarios where we can just return the consequent or
|
||||
// alternate we should drop the block statement if it contains no
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
var t = require("../../../types");
|
||||
import t from "../../../types";
|
||||
|
||||
var isConsole = t.buildMatchMemberExpression("console", true);
|
||||
|
||||
exports.optional = true;
|
||||
export var optional = true;
|
||||
|
||||
exports.CallExpression = function (node, parent) {
|
||||
export function CallExpression(node, parent) {
|
||||
if (isConsole(node.callee)) {
|
||||
if (t.isExpressionStatement(parent)) {
|
||||
this.parentPath.remove();
|
||||
@ -12,4 +12,4 @@ exports.CallExpression = function (node, parent) {
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
var t = require("../../../types");
|
||||
import t from "../../../types";
|
||||
|
||||
exports.optional = true;
|
||||
export var optional = true;
|
||||
|
||||
exports.ExpressionStatement = function (node) {
|
||||
export function ExpressionStatement(node) {
|
||||
if (t.isIdentifier(node.expression, { name: "debugger" })) {
|
||||
this.remove();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
//var t = require("../../../types");
|
||||
//import t from "../../../types";
|
||||
|
||||
exports.optional = true;
|
||||
export var optional = true;
|
||||
|
||||
exports.Scopable = function () {
|
||||
export function Scopable() {
|
||||
//for (var name in scope.bindings) {
|
||||
// scope.rename(name, scope.generateUidIdentifier("a").name);
|
||||
//}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
var remapAsyncToGenerator = require("../../helpers/remap-async-to-generator");
|
||||
var bluebirdCoroutines = require("./bluebird-coroutines");
|
||||
import remapAsyncToGenerator from "../../helpers/remap-async-to-generator";
|
||||
|
||||
exports.optional = true;
|
||||
export { manipulateOptions } from "./bluebird-coroutines";
|
||||
|
||||
exports.manipulateOptions = bluebirdCoroutines.manipulateOptions;
|
||||
export var optional = true;
|
||||
|
||||
exports.Function = function (node, parent, scope, file) {
|
||||
export function Function(node, parent, scope, file) {
|
||||
if (!node.async || node.generator) return;
|
||||
|
||||
return remapAsyncToGenerator(node, file.addHelper("async-to-generator"), scope);
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
var remapAsyncToGenerator = require("../../helpers/remap-async-to-generator");
|
||||
var t = require("../../../types");
|
||||
import remapAsyncToGenerator from "../../helpers/remap-async-to-generator";
|
||||
import t from "../../../types";
|
||||
|
||||
exports.manipulateOptions = function (opts) {
|
||||
export function manipulateOptions(opts) {
|
||||
opts.experimental = true;
|
||||
opts.blacklist.push("regenerator");
|
||||
};
|
||||
}
|
||||
|
||||
exports.optional = true;
|
||||
export var optional = true;
|
||||
|
||||
exports.Function = function (node, parent, scope, file) {
|
||||
export function Function(node, parent, scope, file) {
|
||||
if (!node.async || node.generator) return;
|
||||
|
||||
return remapAsyncToGenerator(
|
||||
@ -16,4 +16,4 @@ exports.Function = function (node, parent, scope, file) {
|
||||
t.memberExpression(file.addImport("bluebird", null, true), t.identifier("coroutine")),
|
||||
scope
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
var t = require("../../../types");
|
||||
import t from "../../../types";
|
||||
|
||||
exports.TypeCastExpression = function (node) {
|
||||
export function TypeCastExpression(node) {
|
||||
return node.expression;
|
||||
};
|
||||
}
|
||||
|
||||
exports.ImportDeclaration = function (node) {
|
||||
export function ImportDeclaration(node) {
|
||||
if (node.isType) this.remove();
|
||||
};
|
||||
}
|
||||
|
||||
exports.ExportDeclaration = function (node) {
|
||||
export function ExportDeclaration(node) {
|
||||
if (t.isTypeAlias(node.declaration)) this.remove();
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
var react = require("../../helpers/react");
|
||||
var t = require("../../../types");
|
||||
import react from "../../helpers/react";
|
||||
import t from "../../../types";
|
||||
|
||||
exports.manipulateOptions = function (opts) {
|
||||
export function manipulateOptions(opts) {
|
||||
opts.blacklist.push("react");
|
||||
};
|
||||
}
|
||||
|
||||
exports.optional = true;
|
||||
export var optional = true;
|
||||
|
||||
require("../../helpers/build-react-transformer")(exports, {
|
||||
pre(state) {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
var react = require("../../helpers/react");
|
||||
var t = require("../../../types");
|
||||
import react from "../../helpers/react";
|
||||
import t from "../../../types";
|
||||
|
||||
var JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/;
|
||||
|
||||
exports.Program = function (node, parent, scope, file) {
|
||||
export function Program(node, parent, scope, file) {
|
||||
var id = "React.createElement";
|
||||
|
||||
for (var i = 0; i < file.ast.comments.length; i++) {
|
||||
@ -22,7 +22,7 @@ exports.Program = function (node, parent, scope, file) {
|
||||
file.set("jsxIdentifier", id.split(".").map(t.identifier).reduce(function (object, property) {
|
||||
return t.memberExpression(object, property);
|
||||
}));
|
||||
};
|
||||
}
|
||||
|
||||
require("../../helpers/build-react-transformer")(exports, {
|
||||
pre(state) {
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
var regenerator = require("regenerator-babel");
|
||||
var t = require("../../../types");
|
||||
import regenerator from "regenerator-babel";
|
||||
import t from "../../../types";
|
||||
|
||||
exports.check = function (node) {
|
||||
export function check(node) {
|
||||
return t.isFunction(node) && (node.async || node.generator);
|
||||
};
|
||||
}
|
||||
|
||||
exports.Program = {
|
||||
export var Program = {
|
||||
enter(ast) {
|
||||
regenerator.transform(ast);
|
||||
this.stop();
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
var includes = require("lodash/collection/includes");
|
||||
var util = require("../../../util");
|
||||
var core = require("core-js/library");
|
||||
var has = require("lodash/object/has");
|
||||
var t = require("../../../types");
|
||||
import includes from "lodash/collection/includes";
|
||||
import * as util from "../../../util";
|
||||
import core from "core-js/library";
|
||||
import has from "lodash/object/has";
|
||||
import t from "../../../types";
|
||||
|
||||
var isSymboliterator = t.buildMatchMemberExpression("Symbol.iterator");
|
||||
|
||||
@ -69,17 +69,17 @@ var astVisitor = {
|
||||
}
|
||||
};
|
||||
|
||||
exports.optional = true;
|
||||
export var optional = true;
|
||||
|
||||
exports.manipulateOptions = function (opts) {
|
||||
export function manipulateOptions(opts) {
|
||||
if (opts.whitelist.length) opts.whitelist.push("es6.modules");
|
||||
};
|
||||
}
|
||||
|
||||
exports.Program = function (node, parent, scope, file) {
|
||||
export function Program(node, parent, scope, file) {
|
||||
scope.traverse(node, astVisitor, file);
|
||||
};
|
||||
}
|
||||
|
||||
exports.pre = function (file) {
|
||||
export function pre(file) {
|
||||
file.setDynamic("helpersNamespace", function () {
|
||||
return file.addImport("babel-runtime/helpers", "babelHelpers");
|
||||
});
|
||||
@ -91,10 +91,10 @@ exports.pre = function (file) {
|
||||
file.setDynamic("regeneratorIdentifier", function () {
|
||||
return file.addImport("babel-runtime/regenerator", "regeneratorRuntime");
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
exports.Identifier = function (node, parent, scope, file) {
|
||||
export function Identifier(node, parent, scope, file) {
|
||||
if (t.isReferencedIdentifier(node, parent, { name: "regeneratorRuntime" })) {
|
||||
return file.get("regeneratorIdentifier");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,24 +1,24 @@
|
||||
var messages = require("../../../messages");
|
||||
var t = require("../../../types");
|
||||
import * as messages from "../../../messages";
|
||||
import t from "../../../types";
|
||||
|
||||
exports.Program = function (program) {
|
||||
export function Program(program) {
|
||||
var first = program.body[0];
|
||||
if (t.isExpressionStatement(first) && t.isLiteral(first.expression, { value: "use strict" })) {
|
||||
program.body.shift();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.FunctionDeclaration =
|
||||
exports.FunctionExpression = function () {
|
||||
this.skip();
|
||||
};
|
||||
|
||||
exports.ThisExpression = function () {
|
||||
export function ThisExpression() {
|
||||
return t.identifier("undefined");
|
||||
};
|
||||
}
|
||||
|
||||
exports.CallExpression = function (node, parent, scope, file) {
|
||||
export function CallExpression(node, parent, scope, file) {
|
||||
if (t.isIdentifier(node.callee, { name: "eval" })) {
|
||||
throw file.errorWithNode(node, messages.get("evalInStrictMode"));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
var messages = require("../../../messages");
|
||||
var build = require("../../helpers/build-conditional-assignment-operator-transformer");
|
||||
var t = require("../../../types");
|
||||
import * as messages from "../../../messages";
|
||||
import build from "../../helpers/build-conditional-assignment-operator-transformer";
|
||||
import t from "../../../types";
|
||||
|
||||
exports.playground = true;
|
||||
export var playground = true;
|
||||
|
||||
build(exports, {
|
||||
is(node, file) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user