Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3b1fcc79c | ||
|
|
491cb26c1f | ||
|
|
7c3d052714 | ||
|
|
4971d0c7f0 | ||
|
|
eb4922b1ec | ||
|
|
bb26183b44 | ||
|
|
4b066f7f1b | ||
|
|
3cd110a7c9 | ||
|
|
a7f9e035a4 | ||
|
|
146b9e6708 | ||
|
|
0953c48620 | ||
|
|
056b90831d | ||
|
|
8ba276b209 | ||
|
|
8eaa9d29e3 | ||
|
|
6212791356 | ||
|
|
d436d32d82 | ||
|
|
2a29f70bba | ||
|
|
6ccb8957bd | ||
|
|
dc45415ee0 | ||
|
|
98ca541fde | ||
|
|
8328f638c2 | ||
|
|
5586ce280f | ||
|
|
0ca71f5e15 | ||
|
|
212776e220 | ||
|
|
4a95a9ec8f | ||
|
|
45953ffc8a | ||
|
|
9c79290bb2 | ||
|
|
cfdf6b7385 | ||
|
|
907e0e0f86 | ||
|
|
f3bd9cbcb8 | ||
|
|
3bd14f9e07 | ||
|
|
102b4b3d1e | ||
|
|
6564f1ff76 | ||
|
|
58d7a5e069 | ||
|
|
f5db53cebe | ||
|
|
2da010fcae | ||
|
|
52b99bdf93 | ||
|
|
9d7e953451 |
@@ -4,7 +4,6 @@ root = true
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
end_of_line = lf
|
||||
|
||||
[*.{js,json}]
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -11,6 +11,7 @@ test/tmp
|
||||
coverage
|
||||
dist
|
||||
.package.json
|
||||
packages/babel-runtime/*.js
|
||||
packages/babel-runtime/helpers/*.js
|
||||
packages/babel-runtime/regenerator/*.js
|
||||
lib
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
sudo: false
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
- "0.12"
|
||||
- "iojs"
|
||||
|
||||
|
||||
36
CHANGELOG.md
36
CHANGELOG.md
@@ -13,6 +13,42 @@ _Note: Gaps between patch versions are faulty/broken releases._
|
||||
|
||||
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
|
||||
|
||||
## 4.7.9
|
||||
|
||||
* **Polish**
|
||||
* Allow `inputSourceMap` to be set to `false` to skip the source map inference.
|
||||
* Infer computed literal property names.
|
||||
* **Bug Fix**
|
||||
* Fix nested labeled for-ofs.
|
||||
* Fix block scoping `break` colliding with the parent switch case.
|
||||
* **Internal**
|
||||
* Upgrade `acorn-babel`.
|
||||
|
||||
## 4.7.8
|
||||
|
||||
* **Bug Fix**
|
||||
* Fix computed classes not properly setting symbols.
|
||||
|
||||
## 4.7.7
|
||||
|
||||
* **Bug Fix**
|
||||
* Fix `types` API exposure.
|
||||
|
||||
## 4.7.6
|
||||
|
||||
* **Bug Fix**
|
||||
* Fix non-Identifier/Literal computed class methods.
|
||||
* **Polish**
|
||||
* Add a fallback if `stack` on an error is unconfigurable.
|
||||
* Hoist `esModule` module declarations to the top of the file to handle circular dependencies better.
|
||||
|
||||
## 4.7.5
|
||||
|
||||
* **Bug Fix**
|
||||
* Don't remap` break`s to call the iterator return.
|
||||
* **Polish**
|
||||
* Use a different helper for computed classes for much nicer output. Also fixes a bug in symbols being non-enumerable so they wouldn't be set on the class.
|
||||
|
||||
## 4.7.4
|
||||
|
||||
* **Bug Fix**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
var commander = require("commander");
|
||||
var util = require("../lib/babel/util");
|
||||
var runtime = require("../lib/babel/build-external-helpers");
|
||||
var runtime = require("../lib/babel/tools/build-external-helpers");
|
||||
|
||||
commander.option("-l, --whitelist [whitelist]", "Whitelist of helpers to ONLY include", util.list);
|
||||
commander.option("-t, --output-type [type]", "Type of output (global|umd|var)", "global");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "babel",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "4.7.4",
|
||||
"version": "4.7.9",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
"repository": "babel/babel",
|
||||
@@ -36,7 +36,7 @@
|
||||
"test": "make test"
|
||||
},
|
||||
"dependencies": {
|
||||
"acorn-babel": "0.11.1-37",
|
||||
"acorn-babel": "0.11.1-38",
|
||||
"ast-types": "~0.7.0",
|
||||
"chalk": "^1.0.0",
|
||||
"chokidar": "^0.12.6",
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
module.exports = require("core-js/library");
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "babel-runtime",
|
||||
"description": "babel selfContained runtime",
|
||||
"version": "4.7.3",
|
||||
"version": "4.7.8",
|
||||
"repository": "babel/babel",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"dependencies": {
|
||||
"core-js": "^0.6.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,10 +9,12 @@ export { canCompile } from "../util";
|
||||
export { default as acorn } from "acorn-babel";
|
||||
export { default as transform } from "../transformation";
|
||||
export { default as traverse } from "../traversal";
|
||||
export { default as buildExternalHelpers } from "../build-external-helpers";
|
||||
export { default as types } from "../types";
|
||||
export { default as buildExternalHelpers } from "../tools/build-external-helpers";
|
||||
export { version } from "../../../package";
|
||||
|
||||
import * as t from "../types";
|
||||
export { t as types };
|
||||
|
||||
export function register(opts) {
|
||||
var callback = require("./register/node");
|
||||
if (opts != null) callback(opts);
|
||||
|
||||
@@ -46,7 +46,7 @@ var compile = function (filename) {
|
||||
var opts = extend({}, transformOpts);
|
||||
resolveRc(filename, opts);
|
||||
|
||||
var cacheKey = `${filename}:${JSON.stringify(opts)}`;
|
||||
var cacheKey = `${filename}:${JSON.stringify(opts)}:${babel.version}`;
|
||||
|
||||
if (cache) {
|
||||
var cached = cache[cacheKey];
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
import SYNTAX_KEYS from "./syntax-keys";
|
||||
import traverse from "../traversal";
|
||||
|
||||
var visitors = traverse.explode(require("./visitors"));
|
||||
|
||||
export default function (ast) {
|
||||
var stats = {
|
||||
syntax: {},
|
||||
builtins: {}
|
||||
};
|
||||
|
||||
var detectedSyntax = function (name) {
|
||||
stats.syntax[name] = true;
|
||||
};
|
||||
|
||||
traverse(ast, {
|
||||
enter(node, parent) {
|
||||
if (SYNTAX_KEYS[node.type]) {
|
||||
detectedSyntax(SYNTAX_KEYS[node.type]);
|
||||
}
|
||||
|
||||
var visitor = visitors[node.type];
|
||||
if (visitor) visitor(node, parent, detectedSyntax);
|
||||
}
|
||||
});
|
||||
|
||||
return stats;
|
||||
};
|
||||
@@ -1,84 +0,0 @@
|
||||
{
|
||||
"ArrowFunctionExpression": "es6.arrowFunctions",
|
||||
|
||||
"AwaitExpression": "es7.asyncFunctions",
|
||||
|
||||
"ClassBody": "es6.classes",
|
||||
"ClassDeclaration": "es6.classes",
|
||||
"ClassExpression": "es6.classes",
|
||||
"MethodDefinition": "es6.classes",
|
||||
|
||||
"ComprehensionBlock": "es7.comprehensions",
|
||||
"ComprehensionExpression": "es7.comprehensions",
|
||||
|
||||
"ForOfStatement": "es6.forOf",
|
||||
|
||||
"ExportBatchSpecifier": "es6.modules",
|
||||
"ExportDeclaration": "es6.modules",
|
||||
"ExportSpecifier": "es6.modules",
|
||||
"ImportBatchSpecifier": "es6.modules",
|
||||
"ImportDeclaration": "es6.modules",
|
||||
"ImportSpecifier": "es6.modules",
|
||||
|
||||
"ArrayPattern": "es6.destructuring",
|
||||
"AssignmentPattern": "es6.destructuring",
|
||||
"ObjectPattern": "es6.destructuring",
|
||||
|
||||
"RestElement": "es6.parameters.rest",
|
||||
|
||||
"SpreadElement": "es6.spread",
|
||||
|
||||
"SpreadProperty": "es7.objectSpread",
|
||||
|
||||
"TaggedTemplateExpression": "es6.templateLiterals",
|
||||
"TemplateElement": "es6.templateLiterals",
|
||||
"TemplateLiteral": "es6.templateLiterals",
|
||||
|
||||
"VirtualPropertyExpression": "es7.abstractReferences",
|
||||
"PrivateDeclaration": "es7.abstractReferences",
|
||||
|
||||
"YieldExpression": "es6.generators",
|
||||
|
||||
"AnyTypeAnnotation": "flow",
|
||||
"ArrayTypeAnnotation": "flow",
|
||||
"BooleanTypeAnnotation": "flow",
|
||||
"ClassProperty": "flow",
|
||||
"DeclareClass": "flow",
|
||||
"DeclareFunction": "flow",
|
||||
"DeclareModule": "flow",
|
||||
"DeclareVariable": "flow",
|
||||
"FunctionTypeAnnotation": "flow",
|
||||
"FunctionTypeParam": "flow",
|
||||
"GenericTypeAnnotation": "flow",
|
||||
"InterfaceExtends": "flow",
|
||||
"InterfaceDeclaration": "flow",
|
||||
"IntersectionTypeAnnotation": "flow",
|
||||
"NullableTypeAnnotation": "flow",
|
||||
"NumberTypeAnnotation": "flow",
|
||||
"StringLiteralTypeAnnotation": "flow",
|
||||
"StringTypeAnnotation": "flow",
|
||||
"TupleTypeAnnotation": "flow",
|
||||
"TypeofTypeAnnotation": "flow",
|
||||
"TypeAlias": "flow",
|
||||
"TypeAnnotation": "flow",
|
||||
"TypeParameterDeclaration": "flow",
|
||||
"TypeParameterInstantiation": "flow",
|
||||
"ObjectTypeAnnotation": "flow",
|
||||
"ObjectTypeCallProperty": "flow",
|
||||
"ObjectTypeIndexer": "flow",
|
||||
"ObjectTypeProperty": "flow",
|
||||
"QualifiedTypeIdentifier": "flow",
|
||||
"UnionTypeAnnotation": "flow",
|
||||
"VoidTypeAnnotation": "flow",
|
||||
|
||||
"JSXAttribute": "jsx",
|
||||
"JSXClosingElement": "jsx",
|
||||
"JSXElement": "jsx",
|
||||
"JSXEmptyExpression": "jsx",
|
||||
"JSXExpressionContainer": "jsx",
|
||||
"JSXIdentifier": "jsx",
|
||||
"JSXMemberExpression": "jsx",
|
||||
"JSXNamespacedName": "jsx",
|
||||
"JSXOpeningElement": "jsx",
|
||||
"JSXSpreadAttribute": "jsx"
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
import includes from "lodash/collection/includes";
|
||||
import t from "../types";
|
||||
|
||||
export function AssignmentExpression(node, parent, detected) {
|
||||
if (node.operator === "**=") {
|
||||
detected("es6.exponentation");
|
||||
}
|
||||
}
|
||||
|
||||
export function BinaryExpression(node, parent, detected) {
|
||||
if (node.operator === "**") {
|
||||
detected("es6.exponentation");
|
||||
}
|
||||
}
|
||||
|
||||
export function VariableDeclaration(node, parent, detected) {
|
||||
if (node.kind === "let" || node.kind === "const") {
|
||||
detected("es6.blockScoping");
|
||||
}
|
||||
|
||||
if (node.kind === "const") {
|
||||
detected("es6.constants");
|
||||
}
|
||||
}
|
||||
|
||||
export function Property(node, parent, detected) {
|
||||
if (node.shorthand || node.method) {
|
||||
detected("es6.properties.shorthand");
|
||||
}
|
||||
|
||||
if (node.kind === "set" || node.kind === "get") {
|
||||
detected("es5.properties.mutators");
|
||||
}
|
||||
|
||||
if (node.computed) {
|
||||
detected("es6.properties.computed");
|
||||
}
|
||||
}
|
||||
|
||||
export function AssignmentPattern(node, parent, detected) {
|
||||
if (t.isFunction(parent) && includes(parent.params, node)) {
|
||||
detected("es6.parameters.default");
|
||||
}
|
||||
}
|
||||
|
||||
exports.Function = function (node, parent, detected) {
|
||||
if (node.generator) {
|
||||
detected("es6.generators");
|
||||
}
|
||||
|
||||
if (node.async) {
|
||||
detected("es7.asyncFunctions");
|
||||
}
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
import isInteger from "is-integer";
|
||||
import isNumber from "lodash/lang/isNumber";
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
export function UnaryExpression(node, print) {
|
||||
var hasSpace = /[a-z]$/.test(node.operator);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
export function AnyTypeAnnotation() {
|
||||
this.push("any");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import each from "lodash/collection/each";
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
export function JSXAttribute(node, print) {
|
||||
print(node.name);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
export function _params(node, print) {
|
||||
print(node.typeParameters);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import each from "lodash/collection/each";
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
export function ImportSpecifier(node, print) {
|
||||
if (t.isSpecifierDefault(node)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import repeating from "repeating";
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
export function WithStatement(node, print) {
|
||||
this.keyword("with");
|
||||
|
||||
@@ -8,7 +8,7 @@ import Buffer from "./buffer";
|
||||
import extend from "lodash/object/extend";
|
||||
import each from "lodash/collection/each";
|
||||
import n from "./node";
|
||||
import t from "../types";
|
||||
import * as t from "../types";
|
||||
|
||||
class CodeGenerator {
|
||||
constructor(ast, opts, code) {
|
||||
|
||||
@@ -2,7 +2,7 @@ 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";
|
||||
import * as t from "../../types";
|
||||
|
||||
var find = function (obj, node, parent) {
|
||||
if (!obj) return;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import each from "lodash/collection/each";
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
var PRECEDENCE = {};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import isBoolean from "lodash/lang/isBoolean";
|
||||
import each from "lodash/collection/each";
|
||||
import map from "lodash/collection/map";
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
function crawl(node, state = {}) {
|
||||
if (t.isMemberExpression(node)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import sourceMap from "source-map";
|
||||
import t from "../types";
|
||||
import * as t from "../types";
|
||||
|
||||
export default class SourceMap {
|
||||
constructor(position, opts, code) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../types";
|
||||
import * as t from "../types";
|
||||
|
||||
export default function (ast, comments, tokens) {
|
||||
if (ast && ast.type === "Program") {
|
||||
|
||||
@@ -40,7 +40,15 @@ export default function (opts, code, callback) {
|
||||
message += frame;
|
||||
}
|
||||
|
||||
if (err.stack) err.stack = err.stack.replace(err.message, message);
|
||||
if (err.stack) {
|
||||
var newStack = err.stack.replace(err.message, message);
|
||||
try {
|
||||
err.stack = newStack;
|
||||
} catch (e) {
|
||||
// `err.stack` may be a readonly property in some environments
|
||||
}
|
||||
}
|
||||
|
||||
err.message = message;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import estraverse from "estraverse";
|
||||
import extend from "lodash/object/extend";
|
||||
import types from "ast-types";
|
||||
import t from "./types";
|
||||
import * as t from "./types";
|
||||
|
||||
// estraverse
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import generator from "./generation";
|
||||
import * as messages from "./messages";
|
||||
import * as util from "./util";
|
||||
import File from "./transformation/file";
|
||||
import generator from "../generation";
|
||||
import * as messages from "../messages";
|
||||
import * as util from "../util";
|
||||
import File from "../transformation/file";
|
||||
import each from "lodash/collection/each";
|
||||
import t from "./types";
|
||||
import * as t from "../types";
|
||||
|
||||
function buildGlobal(namespace, builder) {
|
||||
var body = [];
|
||||
@@ -7,13 +7,14 @@ import generate from "../generation";
|
||||
import defaults from "lodash/object/defaults";
|
||||
import includes from "lodash/collection/includes";
|
||||
import assign from "lodash/object/assign";
|
||||
import Logger from "./logger";
|
||||
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";
|
||||
import * as t from "../types";
|
||||
|
||||
var checkTransformerVisitor = {
|
||||
enter(node, parent, scope, state) {
|
||||
@@ -23,7 +24,7 @@ var checkTransformerVisitor = {
|
||||
|
||||
function checkNode(stack, node, scope) {
|
||||
each(stack, function (pass) {
|
||||
if (pass.shouldRun) return;
|
||||
if (pass.shouldRun || pass.ran) return;
|
||||
pass.checkNode(node, scope);
|
||||
});
|
||||
}
|
||||
@@ -41,6 +42,7 @@ export default class File {
|
||||
|
||||
this.lastStatements = [];
|
||||
this.opts = this.normalizeOptions(opts);
|
||||
this.log = new Logger(this);
|
||||
this.ast = {};
|
||||
|
||||
this.buildTransformers();
|
||||
@@ -50,6 +52,7 @@ export default class File {
|
||||
"inherits",
|
||||
"defaults",
|
||||
"create-class",
|
||||
"create-computed-class",
|
||||
"apply-constructor",
|
||||
"tagged-template-literal",
|
||||
"tagged-template-literal-loose",
|
||||
@@ -136,7 +139,7 @@ export default class File {
|
||||
returnUsedHelpers: false,
|
||||
externalHelpers: false,
|
||||
auxilaryComment: "",
|
||||
inputSourceMap: false,
|
||||
inputSourceMap: null,
|
||||
experimental: false,
|
||||
reactCompat: false,
|
||||
playground: false,
|
||||
@@ -259,12 +262,6 @@ export default class File {
|
||||
this.transformers = transformers;
|
||||
}
|
||||
|
||||
debug(msg?: string) {
|
||||
var parts = this.opts.filename;
|
||||
if (msg) parts += `: ${msg}`;
|
||||
util.debug(parts);
|
||||
}
|
||||
|
||||
getModuleFormatter(type: string) {
|
||||
var ModuleFormatter = isFunction(type) ? type : transform.moduleFormatters[type];
|
||||
|
||||
@@ -283,10 +280,12 @@ export default class File {
|
||||
parseInputSourceMap(code: string) {
|
||||
var opts = this.opts;
|
||||
|
||||
var inputMap = convertSourceMap.fromSource(code);
|
||||
if (inputMap) {
|
||||
opts.inputSourceMap = inputMap.toObject();
|
||||
code = convertSourceMap.removeComments(code);
|
||||
if (opts.inputSourceMap === false) {
|
||||
var inputMap = convertSourceMap.fromSource(code);
|
||||
if (inputMap) {
|
||||
opts.inputSourceMap = inputMap.toObject();
|
||||
code = convertSourceMap.removeComments(code);
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
@@ -397,10 +396,6 @@ export default class File {
|
||||
}
|
||||
}
|
||||
|
||||
logDeopt() {
|
||||
// todo, (node, msg)
|
||||
}
|
||||
|
||||
errorWithNode(node, msg, Error = SyntaxError) {
|
||||
var loc = node.loc.start;
|
||||
var err = new Error(`Line ${loc.line}: ${msg}`);
|
||||
@@ -430,7 +425,7 @@ export default class File {
|
||||
}
|
||||
|
||||
transform(ast) {
|
||||
this.debug();
|
||||
this.log.debug();
|
||||
|
||||
this.ast = ast;
|
||||
this.lastStatements = t.getLastStatements(ast.program);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import explode from "./explode-assignable-expression";
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
export default function (exports, opts) {
|
||||
var isAssignment = function (node) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
export default function build(node, buildBody) {
|
||||
var self = node.blocks.shift();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import explode from "./explode-assignable-expression";
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
export default function (exports, opts) {
|
||||
var buildAssignment = function (left, right) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import isString from "lodash/lang/isString";
|
||||
import * as messages from "../../messages";
|
||||
import esutils from "esutils";
|
||||
import * as react from "./react";
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
export default function (exports, opts) {
|
||||
exports.check = function (node) {
|
||||
|
||||
@@ -2,36 +2,43 @@ import cloneDeep from "lodash/lang/cloneDeep";
|
||||
import traverse from "../../traversal";
|
||||
import each from "lodash/collection/each";
|
||||
import has from "lodash/object/has";
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
export function push(mutatorMap, key, kind, computed, value) {
|
||||
var alias;
|
||||
var alias = t.toKeyAlias({ computed }, key);
|
||||
|
||||
if (t.isIdentifier(key)) {
|
||||
alias = key.name;
|
||||
if (computed) alias = `computed:${alias}`;
|
||||
} else if (t.isLiteral(key)) {
|
||||
alias = String(key.value);
|
||||
} else {
|
||||
alias = JSON.stringify(traverse.removeProperties(t.cloneDeep(key)));
|
||||
}
|
||||
|
||||
var map;
|
||||
if (has(mutatorMap, alias)) {
|
||||
map = mutatorMap[alias];
|
||||
} else {
|
||||
map = {};
|
||||
}
|
||||
var map = {};
|
||||
if (has(mutatorMap, alias)) map = mutatorMap[alias];
|
||||
mutatorMap[alias] = map;
|
||||
|
||||
map._key = key;
|
||||
if (computed) {
|
||||
map._computed = true;
|
||||
}
|
||||
if (computed) map._computed = true;
|
||||
|
||||
map[kind] = value;
|
||||
}
|
||||
|
||||
export function hasComputed(mutatorMap) {
|
||||
for (var key in mutatorMap) {
|
||||
if (mutatorMap[key]._computed) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function toComputedObjectFromClass(obj) {
|
||||
var objExpr = t.arrayExpression([]);
|
||||
|
||||
for (var i = 0; i < obj.properties.length; i++) {
|
||||
var prop = obj.properties[i];
|
||||
var val = prop.value;
|
||||
val.properties.unshift(t.property("init", t.identifier("key"), t.toComputedKey(prop)));
|
||||
objExpr.elements.push(val);
|
||||
}
|
||||
|
||||
return objExpr;
|
||||
}
|
||||
|
||||
export function toClassObject(mutatorMap) {
|
||||
var objExpr = t.objectExpression([]);
|
||||
|
||||
@@ -49,6 +56,7 @@ export function toClassObject(mutatorMap) {
|
||||
var prop = t.property("init", t.identifier(key), node);
|
||||
t.inheritsComments(prop, inheritNode);
|
||||
t.removeComments(inheritNode);
|
||||
|
||||
mapNode.properties.push(prop);
|
||||
});
|
||||
|
||||
@@ -59,35 +67,11 @@ export function toClassObject(mutatorMap) {
|
||||
}
|
||||
|
||||
export function toDefineObject(mutatorMap) {
|
||||
var objExpr = t.objectExpression([]);
|
||||
|
||||
each(mutatorMap, function (map) {
|
||||
var mapNode = t.objectExpression([]);
|
||||
|
||||
var propNode = t.property("init", map._key, mapNode, map._computed);
|
||||
|
||||
if (map.value) {
|
||||
map.writable = t.literal(true);
|
||||
}
|
||||
|
||||
if (map.value) map.writable = t.literal(true);
|
||||
map.configurable = t.literal(true);
|
||||
map.enumerable = t.literal(true);
|
||||
|
||||
each(map, function (node, key) {
|
||||
if (key[0] === "_") return;
|
||||
|
||||
node = t.clone(node);
|
||||
var inheritNode = node;
|
||||
if (t.isMethodDefinition(node)) node = node.value;
|
||||
|
||||
var prop = t.property("init", t.identifier(key), node);
|
||||
t.inheritsComments(prop, inheritNode);
|
||||
t.removeComments(inheritNode);
|
||||
mapNode.properties.push(prop);
|
||||
});
|
||||
|
||||
objExpr.properties.push(propNode);
|
||||
});
|
||||
|
||||
return objExpr;
|
||||
return toClassObject(mutatorMap);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
var getObjRef = function (node, nodes, file, scope) {
|
||||
var ref;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
export default function (node) {
|
||||
var lastNonDefault = 0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import getFunctionArity from "./get-function-arity";
|
||||
import * as util from "../../util";
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
var visitor = {
|
||||
enter(node, parent, scope, state) {
|
||||
@@ -111,7 +111,7 @@ export function bare(node, parent, scope) {
|
||||
if (node.id) return node;
|
||||
|
||||
var id;
|
||||
if (t.isProperty(parent) && parent.kind === "init" && !parent.computed) {
|
||||
if (t.isProperty(parent) && parent.kind === "init" && (!parent.computed || t.isLiteral(parent.key))) {
|
||||
// { foo() {} };
|
||||
id = parent.key;
|
||||
} else if (t.isVariableDeclarator(parent)) {
|
||||
@@ -121,9 +121,16 @@ export function bare(node, parent, scope) {
|
||||
return node;
|
||||
}
|
||||
|
||||
if (!t.isIdentifier(id)) return node;
|
||||
var name;
|
||||
if (t.isLiteral(id)) {
|
||||
name = id.value;
|
||||
} else if (t.isIdentifier(id)) {
|
||||
name = id.name;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
var name = t.toIdentifier(id.name);
|
||||
name = t.toIdentifier(name);
|
||||
id = t.identifier(name);
|
||||
|
||||
var state = visit(node, name, scope);
|
||||
|
||||
2
src/babel/transformation/helpers/react.js
vendored
2
src/babel/transformation/helpers/react.js
vendored
@@ -1,4 +1,4 @@
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
var isCreateClassCallExpression = t.buildMatchMemberExpression("React.createClass");
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import pull from "lodash/array/pull";
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
export function is(node, flag) {
|
||||
return t.isLiteral(node) && node.regex && node.regex.flags.indexOf(flag) >= 0;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
var awaitVisitor = {
|
||||
enter(node, parent, scope, state) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module.exports = ReplaceSupers;
|
||||
|
||||
import * as messages from "../../messages";
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
|
||||
function isIllegalBareSuper(node, parent) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
export function has(node) {
|
||||
var first = node.body[0];
|
||||
|
||||
22
src/babel/transformation/logger.js
Normal file
22
src/babel/transformation/logger.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import * as util from "../util";
|
||||
|
||||
export default class Logger {
|
||||
constructor(file: File) {
|
||||
this.filename = file.opts.filename;
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
_buildMessage(msg: string): string {
|
||||
var parts = this.filename;
|
||||
if (msg) parts += `: ${msg}`;
|
||||
return parts;
|
||||
}
|
||||
|
||||
debug(msg: string) {
|
||||
util.debug(this._buildMessage(msg));
|
||||
}
|
||||
|
||||
deopt(node: Object, msg: string) {
|
||||
util.debug(this._buildMessage(msg));
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ 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";
|
||||
import * as t from "../../types";
|
||||
|
||||
var remapVisitor = {
|
||||
enter(node, parent, scope, formatter) {
|
||||
|
||||
@@ -3,7 +3,7 @@ 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";
|
||||
import * as t from "../../types";
|
||||
|
||||
export default class AMDFormatter extends DefaultFormatter {
|
||||
init = CommonFormatter.prototype.init;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import DefaultFormatter from "./_default";
|
||||
import includes from "lodash/collection/includes";
|
||||
import * as util from "../../util";
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
export default class CommonJSFormatter extends DefaultFormatter {
|
||||
init() {
|
||||
@@ -13,7 +13,7 @@ export default class CommonJSFormatter extends DefaultFormatter {
|
||||
if (!this.noInteropRequireImport && this.hasNonDefaultExports) {
|
||||
var templateName = "exports-module-declaration";
|
||||
if (this.file.isLoose("es6.modules")) templateName += "-loose";
|
||||
file.ast.program.body.push(util.template(templateName, true));
|
||||
file.ast.program.body.unshift(util.template(templateName, true));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
export default class IgnoreFormatter {
|
||||
exportDeclaration(node, nodes) {
|
||||
|
||||
@@ -4,7 +4,7 @@ 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";
|
||||
import * as t from "../../types";
|
||||
|
||||
var hoistVariablesVisitor = {
|
||||
enter(node, parent, scope, hoistDeclarators) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import AMDFormatter from "./amd";
|
||||
import values from "lodash/object/values";
|
||||
import * as util from "../../util";
|
||||
import t from "../../types";
|
||||
import * as t from "../../types";
|
||||
|
||||
export default class UMDFormatter extends AMDFormatter {
|
||||
transform(program) {
|
||||
|
||||
16
src/babel/transformation/templates/create-computed-class.js
Normal file
16
src/babel/transformation/templates/create-computed-class.js
Normal file
@@ -0,0 +1,16 @@
|
||||
(function() {
|
||||
function defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i ++) {
|
||||
var prop = props[i];
|
||||
prop.configurable = true;
|
||||
if (prop.value) prop.writable = true;
|
||||
Object.defineProperty(target, prop.key, prop);
|
||||
}
|
||||
}
|
||||
|
||||
return function (Constructor, protoProps, staticProps) {
|
||||
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
};
|
||||
})()
|
||||
@@ -11,6 +11,7 @@ export default class TransformerPass {
|
||||
this.shouldRun = !transformer.check;
|
||||
this.handlers = transformer.handlers;
|
||||
this.file = file;
|
||||
this.ran = false;
|
||||
}
|
||||
|
||||
canRun(): boolean {
|
||||
@@ -56,8 +57,10 @@ export default class TransformerPass {
|
||||
|
||||
var file = this.file;
|
||||
|
||||
file.debug(`Running transformer ${this.transformer.key}`);
|
||||
file.log.debug(`Running transformer ${this.transformer.key}`);
|
||||
|
||||
file.scope.traverse(file.ast, this.handlers, file);
|
||||
|
||||
this.ran = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export function MemberExpression(node) {
|
||||
var prop = node.property;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export function Property(node) {
|
||||
var key = node.key;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as defineMap from "../../helpers/define-map";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export function check(node) {
|
||||
return t.isProperty(node) && (node.kind === "get" || node.kind === "set");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var check = t.isArrowFunctionExpression;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
var visitor = {
|
||||
enter(node, parent, scope, state) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import traverse from "../../../traversal";
|
||||
import object from "../../../helpers/object";
|
||||
import * as util from "../../../util";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
import values from "lodash/object/values";
|
||||
import extend from "lodash/object/extend";
|
||||
|
||||
@@ -69,8 +69,9 @@ export function Loop(node, parent, scope, file) {
|
||||
t.ensureBlock(node);
|
||||
node.body._letDeclarators = [init];
|
||||
}
|
||||
var blockScoping = new BlockScoping(node, node.body, parent, scope, file);
|
||||
blockScoping.run();
|
||||
|
||||
var blockScoping = new BlockScoping(this, node.body, parent, scope, file);
|
||||
return blockScoping.run();
|
||||
}
|
||||
|
||||
export function BlockStatement(block, parent, scope, file) {
|
||||
@@ -224,17 +225,22 @@ class BlockScoping {
|
||||
* Description
|
||||
*/
|
||||
|
||||
constructor(loopParent?: Object, block: Object, parent: Object, scope: Scope, file: File) {
|
||||
this.loopParent = loopParent;
|
||||
this.parent = parent;
|
||||
this.scope = scope;
|
||||
this.block = block;
|
||||
this.file = file;
|
||||
constructor(loopPath?: TraversalPath, block: Object, parent: Object, scope: Scope, file: File) {
|
||||
this.parent = parent;
|
||||
this.scope = scope;
|
||||
this.block = block;
|
||||
this.file = file;
|
||||
|
||||
this.outsideLetReferences = object();
|
||||
this.hasLetReferences = false;
|
||||
this.letReferences = block._letReferences = object();
|
||||
this.body = [];
|
||||
|
||||
if (loopPath) {
|
||||
this.loopParent = loopPath.parent;
|
||||
this.loopLabel = t.isLabeledStatement(this.loopParent) && this.loopParent.label;
|
||||
this.loop = loopPath.node;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,6 +265,10 @@ class BlockScoping {
|
||||
} else {
|
||||
this.remap();
|
||||
}
|
||||
|
||||
if (this.loopLabel && !t.isLabeledStatement(this.loopParent)) {
|
||||
return t.labeledStatement(this.loopLabel, this.loop);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -297,11 +307,11 @@ class BlockScoping {
|
||||
|
||||
//
|
||||
|
||||
var loopParent = this.loopParent;
|
||||
if (loopParent) {
|
||||
traverseReplace(loopParent.right, loopParent, scope, remaps);
|
||||
traverseReplace(loopParent.test, loopParent, scope, remaps);
|
||||
traverseReplace(loopParent.update, loopParent, scope, remaps);
|
||||
var loop = this.loop;
|
||||
if (loop) {
|
||||
traverseReplace(loop.right, loop, scope, remaps);
|
||||
traverseReplace(loop.test, loop, scope, remaps);
|
||||
traverseReplace(loop.update, loop, scope, remaps);
|
||||
}
|
||||
|
||||
scope.traverse(this.block, replaceVisitor, remaps);
|
||||
@@ -317,7 +327,7 @@ class BlockScoping {
|
||||
var outsideRefs = this.outsideLetReferences;
|
||||
|
||||
// remap loop heads with colliding variables
|
||||
if (this.loopParent) {
|
||||
if (this.loop) {
|
||||
for (var name in outsideRefs) {
|
||||
var id = outsideRefs[name];
|
||||
|
||||
@@ -438,7 +448,7 @@ class BlockScoping {
|
||||
ignoreLabeless: false,
|
||||
innerLabels: [],
|
||||
hasReturn: false,
|
||||
isLoop: !!this.loopParent,
|
||||
isLoop: !!this.loop,
|
||||
map: {}
|
||||
};
|
||||
|
||||
@@ -504,7 +514,7 @@ class BlockScoping {
|
||||
t.variableDeclarator(ret, call)
|
||||
]));
|
||||
|
||||
var loopParent = this.loopParent;
|
||||
var loop = this.loop;
|
||||
var retCheck;
|
||||
var has = this.has;
|
||||
var cases = [];
|
||||
@@ -517,9 +527,8 @@ class BlockScoping {
|
||||
}
|
||||
|
||||
if (has.hasBreakContinue) {
|
||||
if (!loopParent) {
|
||||
throw new Error("Has no loop parent but we're trying to reassign breaks " +
|
||||
"and continues, something is going wrong here.");
|
||||
if (!loop) {
|
||||
throw new Error("Aren't in a loop and we're trying to reassign breaks and continues, something is going wrong here.");
|
||||
}
|
||||
|
||||
for (var key in has.map) {
|
||||
@@ -537,6 +546,14 @@ class BlockScoping {
|
||||
single.consequent[0]
|
||||
)));
|
||||
} else {
|
||||
// #998
|
||||
for (var i = 0; i < cases.length; i++) {
|
||||
var caseConsequent = cases[i].consequent[0];
|
||||
if (t.isBreakStatement(caseConsequent) && !caseConsequent.label) {
|
||||
caseConsequent.label = this.loopLabel ||= this.file.scope.generateUidIdentifier("loop");
|
||||
}
|
||||
}
|
||||
|
||||
body.push(this.file.attachAuxiliaryComment(t.switchStatement(ret, cases)));
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as defineMap from "../../helpers/define-map";
|
||||
import * as messages from "../../../messages";
|
||||
import * as util from "../../../util";
|
||||
import traverse from "../../../traversal";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var check = t.isClass;
|
||||
|
||||
@@ -217,6 +217,7 @@ class ClassTransformer {
|
||||
|
||||
var instanceProps;
|
||||
var staticProps;
|
||||
var classHelper = "create-class";
|
||||
|
||||
if (this.hasInstanceMutators) {
|
||||
instanceProps = defineMap.toClassObject(this.instanceMutatorMap);
|
||||
@@ -227,13 +228,19 @@ class ClassTransformer {
|
||||
}
|
||||
|
||||
if (instanceProps || staticProps) {
|
||||
if (defineMap.hasComputed(this.instanceMutatorMap) || defineMap.hasComputed(this.staticMutatorMap)) {
|
||||
if (instanceProps) instanceProps = defineMap.toComputedObjectFromClass(instanceProps);
|
||||
if (staticProps) staticProps = defineMap.toComputedObjectFromClass(staticProps);
|
||||
classHelper = "create-computed-class";
|
||||
}
|
||||
|
||||
instanceProps ||= t.literal(null);
|
||||
|
||||
var args = [this.classRef, instanceProps];
|
||||
if (staticProps) args.push(staticProps);
|
||||
|
||||
body.push(t.expressionStatement(
|
||||
t.callExpression(this.file.addHelper("create-class"), args)
|
||||
t.callExpression(this.file.addHelper(classHelper), args)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as messages from "../../../messages";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export function check(node) {
|
||||
return t.isVariableDeclaration(node, { kind: "const" });
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as messages from "../../../messages";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var check = t.isPattern;
|
||||
|
||||
@@ -135,10 +135,7 @@ export function AssignmentExpression(node, parent, scope, file) {
|
||||
if (!t.isPattern(node.left)) return;
|
||||
|
||||
var ref = scope.generateUidIdentifier("temp");
|
||||
scope.push({
|
||||
key: ref.name,
|
||||
id: ref
|
||||
});
|
||||
scope.push({ id: ref });
|
||||
|
||||
var nodes = [];
|
||||
nodes.push(t.assignmentExpression("=", ref, node.right));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as messages from "../../../messages";
|
||||
import * as util from "../../../util";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var check = t.isForOfStatement;
|
||||
|
||||
@@ -32,40 +32,10 @@ export function ForOfStatement(node, parent, scope, file) {
|
||||
// todo: find out why this is necessary? #538
|
||||
loop._scopeInfo = node._scopeInfo;
|
||||
|
||||
if (build.replaceParent) {
|
||||
this.parentPath.node = build.node;
|
||||
} else {
|
||||
return build.node;
|
||||
}
|
||||
if (build.replaceParent) this.parentPath.node = build.node;
|
||||
return build.node;
|
||||
}
|
||||
|
||||
var breakVisitor = {
|
||||
enter(node, parent, scope, state) {
|
||||
if (this.isLoop()) {
|
||||
state.ignoreLabeless = true;
|
||||
scope.traverse(node, breakVisitor, state);
|
||||
state.ignoreLabeless = false;
|
||||
return this.skip();
|
||||
}
|
||||
|
||||
if (this.isBreakStatement()) {
|
||||
if (!node.label && state.ignoreLabeless) return;
|
||||
if (node.label && node.label.name !== state.label) return;
|
||||
|
||||
// break statements mean something different in this context
|
||||
if (t.isSwitchCase(parent)) return;
|
||||
|
||||
var ret = t.expressionStatement(
|
||||
t.callExpression(t.memberExpression(state.iteratorKey, t.identifier("return")), [])
|
||||
);
|
||||
ret = state.wrapReturn(ret);
|
||||
|
||||
this.skip();
|
||||
return [ret, node];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var loose = function (node, parent, scope, file) {
|
||||
var left = node.left;
|
||||
var declar, id;
|
||||
@@ -102,23 +72,6 @@ var loose = function (node, parent, scope, file) {
|
||||
|
||||
//
|
||||
|
||||
scope.traverse(node, breakVisitor, {
|
||||
iteratorKey: iteratorKey,
|
||||
label: t.isLabeledStatement(parent) && parent.label.name,
|
||||
|
||||
wrapReturn(node) {
|
||||
return t.ifStatement(
|
||||
t.logicalExpression(
|
||||
"&&",
|
||||
t.unaryExpression("!", isArrayKey, true),
|
||||
t.memberExpression(iteratorKey, t.identifier("return")
|
||||
)
|
||||
), node);
|
||||
}
|
||||
});
|
||||
|
||||
//
|
||||
|
||||
return {
|
||||
declar: declar,
|
||||
node: loop,
|
||||
@@ -170,17 +123,6 @@ var spec = function (node, parent, scope, file) {
|
||||
|
||||
//
|
||||
|
||||
scope.traverse(node, breakVisitor, {
|
||||
iteratorKey: iteratorKey,
|
||||
label: isLabeledParent && parent.label.name,
|
||||
|
||||
wrapReturn(node) {
|
||||
return t.ifStatement(t.memberExpression(iteratorKey, t.identifier("return")), node);
|
||||
}
|
||||
});
|
||||
|
||||
//
|
||||
|
||||
return {
|
||||
replaceParent: isLabeledParent,
|
||||
declar: declar,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export { check } from "../internal/modules";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import ReplaceSupers from "../../helpers/replace-supers";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export function check(node) {
|
||||
return t.isIdentifier(node, { name: "super" });
|
||||
@@ -40,10 +40,7 @@ export function ObjectExpression(node, parent, scope, file) {
|
||||
}
|
||||
|
||||
if (objectRef) {
|
||||
scope.push({
|
||||
id: objectRef
|
||||
});
|
||||
|
||||
scope.push({ id: objectRef });
|
||||
return t.assignmentExpression("=", objectRef, node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as util from "../../../util";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export function check(node) {
|
||||
return t.isFunction(node) && hasDefaults(node);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import isNumber from "lodash/lang/isNumber";
|
||||
import * as util from "../../../util";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var check = t.isRestElement;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
function loose(node, body, objId) {
|
||||
for (var i = 0; i < node.properties.length; i++) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export function check(node) {
|
||||
return t.isProperty(node) && (node.method || node.shorthand);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as regex from "../../helpers/regex";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export function check(node) {
|
||||
return regex.is(node, "y");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import includes from "lodash/collection/includes";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
function getSpreadLiteral(spread, scope) {
|
||||
return scope.toArray(spread.argument, true);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var optional = true;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ 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";
|
||||
import * as t from "../../../types";
|
||||
|
||||
exports.Function = function (node, parent, scope, file) {
|
||||
var tailCall = new TailCallTransformer(node, scope, file);
|
||||
@@ -161,7 +161,7 @@ class TailCallTransformer {
|
||||
if (!this.hasTailRecursion) return;
|
||||
|
||||
if (this.hasDeopt()) {
|
||||
this.file.logDeopt(node, messages.get("tailCallReassignmentDeopt"));
|
||||
this.file.log.deopt(node, messages.get("tailCallReassignmentDeopt"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
var buildBinaryExpression = function (left, right) {
|
||||
return t.binaryExpression("+", left, right);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// https://github.com/zenparsing/es-abstract-refs
|
||||
|
||||
import * as util from "../../../util";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var experimental = true;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import buildComprehension from "../../helpers/build-comprehension";
|
||||
import traverse from "../../../traversal";
|
||||
import * as util from "../../../util";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var experimental = true;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// https://github.com/rwaldron/exponentiation-operator
|
||||
|
||||
import build from "../../helpers/build-binary-assignment-operator-transformer";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var experimental = true;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// https://github.com/sebmarkbage/ecmascript-rest-spread
|
||||
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var experimental = true;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
var functionChildrenVisitor = {
|
||||
enter(node, parent, scope, state) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as strict from "../../helpers/strict";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var secondPass = true;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// a generator function as a default then regenerator will destroy the export
|
||||
// declaration and leave a variable declaration in it's place... yeah, handy.
|
||||
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export function check(node) {
|
||||
return t.isImportDeclaration(node) || t.isExportDeclaration(node);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export function Program(program, parent, scope, file) {
|
||||
if (file.transformers.strict.canRun()) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as messages from "../../../messages";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export function ForOfStatement(node, parent, scope, file) {
|
||||
var left = node.left;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import remapAsyncToGenerator from "../../helpers/remap-async-to-generator";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export function manipulateOptions(opts) {
|
||||
opts.experimental = true;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export function Flow(node) {
|
||||
this.remove();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as react from "../../helpers/react";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export function manipulateOptions(opts) {
|
||||
opts.blacklist.push("react");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as react from "../../helpers/react";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
var JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import regenerator from "regenerator-babel";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export function check(node) {
|
||||
return t.isFunction(node) && (node.async || node.generator);
|
||||
|
||||
@@ -2,7 +2,7 @@ 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";
|
||||
import * as t from "../../../types";
|
||||
|
||||
var isSymboliterator = t.buildMatchMemberExpression("Symbol.iterator");
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as messages from "../../../messages";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export function Program(program) {
|
||||
var first = program.body[0];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as messages from "../../../messages";
|
||||
import build from "../../helpers/build-conditional-assignment-operator-transformer";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var playground = true;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import build from "../../helpers/build-conditional-assignment-operator-transformer";
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var playground = true;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var playground = true;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var playground = true;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export function BlockStatement(node, parent, scope, file) {
|
||||
if ((t.isFunction(parent) && parent.body === node) || t.isExportDeclaration(parent)) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
import pull from "lodash/array/pull";
|
||||
|
||||
function isProtoKey(node) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var optional = true;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
function toStatements(node) {
|
||||
if (t.isBlockStatement(node)) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var optional = true;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var optional = true;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
var isConsole = t.buildMatchMemberExpression("console", true);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import t from "../../../types";
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var optional = true;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user