Compare commits

...

10 Commits

Author SHA1 Message Date
Sebastian McKenzie
81019ec76d v5.6.17 2015-07-09 19:04:26 +01:00
Sebastian McKenzie
b0d0adda9b add 5.6.17 changelog 2015-07-09 19:03:32 +01:00
Sebastian McKenzie
d335535f04 Revert "Move into for block"
This reverts commit 1945f849c3.

# Conflicts:
#	src/babel/generation/index.js
2015-07-09 19:01:37 +01:00
Sebastian McKenzie
f738c95c8d Merge branch 'master' into development 2015-07-09 18:22:22 +01:00
Sebastian McKenzie
7fec1c98e5 Merge pull request #1962 from benjamn/development
Update regenerator to v0.8.34, and remove recast and ast-types from package.json.
2015-07-09 18:21:17 +01:00
Sebastian McKenzie
33ae022e4d add ClassProperty handling to t.isReferenced - fixes #1961 2015-07-09 18:19:20 +01:00
Ben Newman
eac9e9b372 Update regenerator to v0.8.34, and remove recast and ast-types.
This version of Regenerator pegs recast to v0.10.18, which pegs ast-types
to v0.8.2, which contains special support for all Babel AST types:
https://github.com/benjamn/ast-types/blob/master/def/babel.js

This version of Regenerator also exports the ast-types module object that
it uses (as regenerator.types), so that consumers like Babel can refer to
the exact same copy of ast-types when necessary, rather than requiring
ast-types themselves. Why that was risky: #1958.
2015-07-09 13:12:58 -04:00
Sebastian McKenzie
eb6b38d3a8 add 5.6.13-5.6.16 changelogs 2015-07-09 16:30:45 +01:00
Brian Donovan
86095d9dac Merge pull request #1951 from zbraniecki/traverse-in-plugins-typo
Fix a typo in plugin-manager import of traverse
2015-07-08 13:13:19 -07:00
Zibi Braniecki
02dd785d02 Fix a typo in plugin-manager import of traverse 2015-07-08 13:06:59 -07:00
7 changed files with 68 additions and 90 deletions

View File

@@ -13,6 +13,35 @@ _Note: Gaps between patch versions are faulty, broken or test releases._
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
## 5.6.17
* **Bug Fix**
* Fix `CodeGenerator.findCommonStringDelimiter` causing a stack overflow.
## 5.6.16
* **Internal**
* Fix `recast` version to avoid pulling in a newer version.
* **New Feature**
* Add support for functions in `util.shouldIgnore`.
* **Polish**
* Strip flow directives in flow transformer.
* Add a check for out of bounds default parameters, drastically improving performance and removes engine deoptimisations.
* Various performance optimisations by [@samccone](https://github.com/samccone) 💅✨
* Delay `this` assignment when referencing this inside an arrow function pre-bare super in derived class constructors.
* Split up class body pushing if the constructor is in the wrong order.
* **Bug Fix**
* Fix hoisting of `ForInStatement` `init` variables in `system` module formatter.
* `PathHoister`: Don't hoist to the same function as their original paths function parent.
* `PathHoister`: Push each violation paths ancestry to the breakOnScopePaths collection to avoid constant hoisting to nested paths.fix tail call recursion on functions with less arguments than parameters.
* Disallow `super.*` before `super()` in derived class constructors.
* Properly regenerate scope for replaced nodes. Thanks [@loganfsmyth](https://github.com/loganfsmyth)!
* Move up template literal simplification logic to avoid breaking on single elements.
## 5.6.13-5.6.15
* Setting up automatic Travis releases.
## 5.6.12
* **Bug Fix**

View File

@@ -1,7 +1,7 @@
{
"name": "babel-core",
"description": "A compiler for writing next generation JavaScript",
"version": "5.6.16",
"version": "5.6.17",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
"license": "MIT",
@@ -28,7 +28,6 @@
},
"dependencies": {
"acorn-jsx": "^1.0.0",
"ast-types": "~0.7.0",
"babel-plugin-constant-folding": "^1.0.1",
"babel-plugin-dead-code-elimination": "^1.0.2",
"babel-plugin-eval": "^1.0.1",
@@ -63,8 +62,7 @@
"path-exists": "^1.0.0",
"path-is-absolute": "^1.0.0",
"private": "^0.1.6",
"recast": "0.10.16",
"regenerator": "0.8.32",
"regenerator": "0.8.34",
"regexpu": "^1.1.2",
"repeating": "^1.1.2",
"resolve": "^1.1.6",

View File

@@ -57,16 +57,33 @@ class CodeGenerator {
return format;
}
static findCommonStringDelimiter(code, tokens, occurences = {"'": 0, "\"": 0}) {
if (tokens.length === 0 || occurences["'"] + occurences["\""] >= 3) {
return occurences["'"] > occurences["\""] ? "single" : "double";
}
static findCommonStringDelimiter(code, tokens) {
var occurences = {
single: 0,
double: 0
};
if (tokens[0].type.label === "string") {
occurences[code[tokens[0].start]]++;
}
var checked = 0;
return this.findCommonStringDelimiter(code, tokens.slice(1), occurences);
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i];
if (token.type.label !== "string") continue;
var raw = code.slice(token.start, token.end);
if (raw[0] === "'") {
occurences.single++;
} else {
occurences.double++;
}
checked++;
if (checked >= 3) break;
}
if (occurences.single > occurences.double) {
return "single";
} else {
return "double";
}
}
static generators = {

View File

@@ -1,83 +1,7 @@
import estraverse from "estraverse";
import extend from "lodash/object/extend";
import types from "ast-types";
import * as t from "./types";
// estraverse
extend(estraverse.VisitorKeys, t.VISITOR_KEYS);
// regenerator/ast-types
var def = types.Type.def;
var or = types.Type.or;
//def("File")
// .bases("Node")
// .build("program")
// .field("program", def("Program"));
def("Noop");
def("AssignmentPattern")
.bases("Pattern")
.build("left", "right")
.field("left", def("Pattern"))
.field("right", def("Expression"));
def("RestElement")
.bases("Pattern")
.build("argument")
.field("argument", def("expression"));
def("DoExpression")
.bases("Expression")
.build("body")
.field("body", [def("Statement")]);
def("Super")
.bases("Expression");
def("ExportDefaultDeclaration")
.bases("Declaration")
.build("declaration")
.field("declaration", or(
def("Declaration"),
def("Expression"),
null
));
def("ExportNamedDeclaration")
.bases("Declaration")
.build("declaration")
.field("declaration", or(
def("Declaration"),
def("Expression"),
null
))
.field("specifiers", [or(
def("ExportSpecifier")
)])
.field("source", or(def("ModuleSpecifier"), null));
def("ExportNamespaceSpecifier")
.bases("Specifier")
.field("exported", def("Identifier"));
def("ExportDefaultSpecifier")
.bases("Specifier")
.field("exported", def("Identifier"));
def("ExportAllDeclaration")
.bases("Declaration")
.build("exported", "source")
.field("exported", def("Identifier"))
.field("source", def("Literal"));
def("BindExpression")
.bases("Expression")
.build("object", "callee")
.field("object", or(def("Expression"), null))
.field("callee", def("Expression"));
types.finalize();

View File

@@ -2,7 +2,7 @@ import Transformer from "../transformer";
import Plugin from "../plugin";
import * as types from "../../types";
import * as messages from "../../messages";
import traverse from "../../types";
import traverse from "../../traversal";
import parse from "../../helpers/parse";
var context = {

View File

@@ -1,6 +1,11 @@
import regenerator from "regenerator";
import * as t from "../../../types";
import { NodePath } from "ast-types";
// It's important to use the exact same NodePath constructor that
// Regenerator uses, rather than require("ast-types").NodePath, because
// the version of ast-types that Babel knows about might be different from
// the version that Regenerator depends on. See for example #1958.
const NodePath = regenerator.types.NodePath;
export var metadata = {
group: "builtin-advanced"

View File

@@ -77,6 +77,11 @@ export function isReferenced(node: Object, parent: Object): boolean {
case "JSXAttribute":
return parent.name !== node;
// no: class { NODE = value; }
// yes: class { key = NODE; }
case "ClassProperty":
return parent.value === node;
// no: import NODE from "foo";
// no: import * as NODE from "foo";
// no: import { NODE as foo } from "foo";