Compare commits

...

50 Commits

Author SHA1 Message Date
Sebastian McKenzie
4e969d3d92 v5.1.9 2015-04-14 08:30:54 -07:00
Sebastian McKenzie
0bca1de285 add 5.1.9 changelog 2015-04-14 08:29:31 -07:00
Sebastian McKenzie
3a5bd06a7e fix proeprty method assignment wrapper generator template 2015-04-14 08:28:02 -07:00
Sebastian McKenzie
66a908aaa7 Mark function token as able to start an expression 2015-04-14 08:18:06 -07:00
Sebastian McKenzie
cd0ed08237 Revert "delegate to babel-cli/babel-core if it's available #1244"
This reverts commit dd84b554e6.
2015-04-14 08:02:02 -07:00
Sebastian McKenzie
dd84b554e6 delegate to babel-cli/babel-core if it's available #1244 2015-04-14 07:53:29 -07:00
Sebastian McKenzie
b51411f090 Merge branch 'master' of github.com:babel/babel 2015-04-14 07:39:52 -07:00
Sebastian McKenzie
4cc843ded3 set hoisted to true for react constant elements optimisation 2015-04-14 07:39:44 -07:00
Sebastian McKenzie
47d253c732 set passModuleArg when handling default export specifiers in amd module formatter - fixes #1260 2015-04-14 07:39:34 -07:00
Sebastian McKenzie
09901274ab Merge pull request #1257 from zloirock/master
Update NATIVE_TYPE_NAMES
2015-04-14 07:28:00 -07:00
rock
35196e20c7 Update NATIVE_TYPE_NAMES 2015-04-14 18:24:13 +06:00
Sebastian McKenzie
35af771a29 Merge branch 'master' of github.com:babel/babel 2015-04-13 21:57:04 -07:00
Sebastian McKenzie
dee80caa09 move export reassignment to exit handler - fixes #1255 2015-04-13 21:56:55 -07:00
Sebastian McKenzie
46b7cc0a72 assorted minor cleanup of variables 2015-04-13 21:56:37 -07:00
Sebastian McKenzie
3b189e22b7 Merge pull request #1256 from jayphelps/fix-writable
class properties with an undefined value are now correctly writable
2015-04-13 21:52:46 -07:00
Jay Phelps
6ca565d7fb class properties with an undefined value are now correctly writable 2015-04-13 20:53:05 -07:00
Sebastian McKenzie
64f5480f96 fix pattern LHS error messages 2015-04-13 16:45:30 -07:00
Sebastian McKenzie
828fdc8769 make illegal LHS pattern error messages more user friendly 2015-04-13 16:40:13 -07:00
Sebastian McKenzie
6763c4415e make parenthesized array patterns illegal - cc @michaelficarra 2015-04-13 16:16:57 -07:00
Sebastian McKenzie
fb30e79e03 5.1.8 2015-04-13 15:46:45 -07:00
Sebastian McKenzie
85fb4304b0 v5.1.8 2015-04-13 15:45:46 -07:00
Sebastian McKenzie
c2da77d7ec only make parenthesized object patterns illegal - fixes #1254, ref jshint/jshint#2269 2015-04-13 15:44:54 -07:00
Sebastian McKenzie
c54c3d3c15 5.1.7 2015-04-13 15:44:02 -07:00
Sebastian McKenzie
2a7c954155 v5.1.7 2015-04-13 14:59:56 -07:00
Sebastian McKenzie
3fb7f7c7cc add 5.1.6-5.1.7 changelog 2015-04-13 14:56:33 -07:00
Sebastian McKenzie
c4b2818336 remove useless kind on import declarations 2015-04-13 14:55:46 -07:00
Sebastian McKenzie
061561bfd8 add proper ecmaVersion and sourceType to parse api 2015-04-13 14:55:37 -07:00
Sebastian McKenzie
d4944d606b 5.1.6 2015-04-13 14:29:21 -07:00
Sebastian McKenzie
736b689c3b v5.1.6 2015-04-13 14:27:09 -07:00
Sebastian McKenzie
e12b377014 don't fall back to runtime catch all on locally declared variables 2015-04-13 14:26:06 -07:00
Sebastian McKenzie
5fd5b815ab fix whitespace in resolveRc 2015-04-13 14:25:47 -07:00
Sebastian McKenzie
92db8312f6 add parse api 2015-04-13 14:25:37 -07:00
Sebastian McKenzie
e080fe547d 5.1.5 2015-04-13 11:59:47 -07:00
Sebastian McKenzie
b967ecf063 v5.1.5 2015-04-13 11:58:58 -07:00
Sebastian McKenzie
365b7285d2 bump core-js version 2015-04-13 11:58:09 -07:00
Sebastian McKenzie
a40d532b0e 5.1.4 2015-04-13 09:38:21 -07:00
Sebastian McKenzie
0487bf911d v5.1.4 2015-04-13 09:36:21 -07:00
Sebastian McKenzie
57c72d1cd0 fix syntax error in runtime definitions 2015-04-13 09:35:35 -07:00
Sebastian McKenzie
335bdffec2 add missing Reflect methods to runtime transformer #1248 2015-04-13 09:34:45 -07:00
Sebastian McKenzie
e1d76a1dfe 5.1.3 2015-04-13 09:25:37 -07:00
Sebastian McKenzie
a4845323a2 v5.1.3 2015-04-13 09:24:00 -07:00
Sebastian McKenzie
792951b489 add 5.1.3 changelog 2015-04-13 09:23:12 -07:00
Sebastian McKenzie
5adda836af don't do TCO on generators and async functions - fixes #1251 2015-04-13 09:21:59 -07:00
Sebastian McKenzie
4c2c3098c3 Merge branch 'master' of github.com:babel/babel 2015-04-13 09:20:36 -07:00
Sebastian McKenzie
087c714098 simplify runtime transformer traversal and add a catch-all - fixes #1248 2015-04-13 09:20:28 -07:00
Sebastian McKenzie
5a33e4fe05 Merge pull request #1245 from deepsweet/travis-cache
let Travis cache node_modules
2015-04-13 08:29:59 -07:00
Sebastian McKenzie
5f8667eaa7 make parsing of decorators stateless - fixes shuhei/babel-angular2-app#4 2015-04-13 08:26:51 -07:00
Sebastian McKenzie
31b4468514 switch to vanilla regenerator - closes #1247, closes #1123 2015-04-13 08:08:00 -07:00
Kir Belevich
2be9678bbe let Travis cache node_modules 2015-04-13 17:54:50 +07:00
Sebastian McKenzie
b5210877cf 5.1.2 2015-04-13 00:54:00 -07:00
32 changed files with 456 additions and 66 deletions

View File

@@ -1,5 +1,8 @@
sudo: false
language: node_js
cache:
directories:
- node_modules
node_js:
- "0.12"
- "iojs"

View File

@@ -13,6 +13,50 @@ _Note: Gaps between patch versions are faulty/broken releases._
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
## 5.1.9
* **Bug Fix**
* Fix class property initializers with `undefined` values not being correctly writable.
* Fix self inferring generators incorrectly causing a stack error.
* **Internal**
* Upgrade to latest `acorn`.
* **Polish**
* Make invalid LHS pattern error messages nicer.
## 5.1.8
* **Bug Fix**
* Only make parenthesized object pattern LHS illegal.
## 5.1.7
* **Internal**
* Add `parse` node API.
## 5.1.6
* **Bug Fix**
* Fix `runtime` built-in catchall not properly checking for local variables.
## 5.1.5
* **Internal**
* Bump `core-js` version.
## 5.1.4
* **Polish**
* Add missing `Reflect` methods to runtime transformer.
## 5.1.3
* **Internal**
* Switch entirely to vanilla regenerator.
* Clean up and make the parsing of decorators stateless.
* **Bug Fix**
* Don't do TCO on generators and async functions.
* Add missing `core-js` runtime definitions.
## 5.1.2
* **Bug Fix**

View File

@@ -1,7 +1,7 @@
{
"name": "babel-core",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "5.1.2",
"version": "5.1.9",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
"repository": "babel/babel",
@@ -30,7 +30,7 @@
"ast-types": "~0.7.0",
"chalk": "^1.0.0",
"convert-source-map": "^1.0.0",
"core-js": "^0.8.1",
"core-js": "^0.8.3",
"debug": "^2.1.1",
"detect-indent": "^3.0.0",
"estraverse": "^3.0.0",
@@ -46,7 +46,7 @@
"output-file-sync": "^1.1.0",
"path-is-absolute": "^1.0.0",
"private": "^0.1.6",
"regenerator": "https://github.com/sebmck/regenerator/archive/block-hoist.tar.gz",
"regenerator": "^0.8.20",
"regexpu": "^1.1.2",
"repeating": "^1.1.2",
"shebang-regex": "^1.0.0",

View File

@@ -1,13 +1,13 @@
{
"name": "babel",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "5.1.1",
"version": "5.1.8",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
"repository": "babel/babel",
"preferGlobal": true,
"dependencies": {
"babel-core": "^5.1.1",
"babel-core": "^5.1.8",
"chokidar": "^1.0.0",
"commander": "^2.6.0",
"fs-readdir-recursive": "^0.1.0",

View File

@@ -1,7 +1,7 @@
{
"name": "babel-runtime",
"description": "babel selfContained runtime",
"version": "5.1.1",
"version": "5.1.8",
"repository": "babel/babel",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"dependencies": {

View File

@@ -104,10 +104,14 @@ pp.parseMaybeAssign = function(noIn, refShorthandDefaultPos, afterLeftParse) {
refShorthandDefaultPos.start = 0 // reset because shorthand default was used correctly
this.checkLVal(left)
if (left.parenthesizedExpression) {
let errorMsg
if (left.type === "ObjectPattern") {
this.raise(left.start, "You're trying to assign to a parenthesized expression, instead of `({ foo }) = {}` use `({ foo } = {})`");
} else {
this.raise(left.start, "Parenthesized left hand expressions are illegal");
errorMsg = "`({a}) = 0` use `({a} = 0)`"
} else if (left.type === "ArrayPattern") {
errorMsg = "`([a]) = 0` use `([a] = 0)`"
}
if (errorMsg) {
this.raise(left.start, `You're trying to assign to a parenthesized expression, eg. instead of ${errorMsg}`)
}
}
this.next()
@@ -509,22 +513,24 @@ pp.parseTemplate = function() {
pp.parseObj = function(isPattern, refShorthandDefaultPos) {
let node = this.startNode(), first = true, propHash = {}
node.properties = []
let decorators = []
this.next()
while (!this.eat(tt.braceR)) {
if (!first) {
this.expect(tt.comma)
if (this.afterTrailingComma(tt.braceR)) break
} else first = false
while (this.type === tt.at) {
this.decorators.push(this.parseDecorator())
decorators.push(this.parseDecorator())
}
let prop = this.startNode(), isGenerator = false, isAsync = false, start
if (decorators.length) {
prop.decorators = decorators
decorators = []
}
if (this.options.features["es7.objectRestSpread"] && this.type === tt.ellipsis) {
prop = this.parseSpread()
prop.type = "SpreadProperty"
this.takeDecorators(prop)
node.properties.push(prop)
continue
}
@@ -550,10 +556,9 @@ pp.parseObj = function(isPattern, refShorthandDefaultPos) {
}
this.parseObjPropValue(prop, start, isGenerator, isAsync, isPattern, refShorthandDefaultPos);
this.checkPropClash(prop, propHash)
this.takeDecorators(prop)
node.properties.push(this.finishNode(prop, "Property"))
}
if (this.decorators.length) {
if (decorators.length) {
this.raise(this.start, "You have trailing decorators with no property");
}
return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression")

View File

@@ -471,14 +471,18 @@ pp.parseClass = function(node, isStatement) {
var classBody = this.startNode()
classBody.body = []
this.expect(tt.braceL)
let decorators = []
while (!this.eat(tt.braceR)) {
if (this.eat(tt.semi)) continue
if (this.type === tt.at) {
this.decorators.push(this.parseDecorator())
decorators.push(this.parseDecorator())
continue
}
var method = this.startNode()
this.takeDecorators(method)
if (decorators.length) {
method.decorators = decorators
decorators = []
}
var isGenerator = this.eat(tt.star), isAsync = false
this.parsePropertyName(method)
if (this.type !== tt.parenL && !method.computed && method.key.type === "Identifier" &&
@@ -517,7 +521,7 @@ pp.parseClass = function(node, isStatement) {
}
this.parseClassMethod(classBody, method, isGenerator, isAsync)
}
if (this.decorators.length) {
if (decorators.length) {
this.raise(this.start, "You have trailing decorators with no method");
}
node.body = this.finishNode(classBody, "ClassBody")
@@ -687,7 +691,6 @@ pp.parseImport = function(node) {
if (this.type === tt.string) {
node.specifiers = empty
node.source = this.parseExprAtom()
node.kind = ""
} else {
node.specifiers = []
this.parseImportSpecifiers(node)

View File

@@ -116,7 +116,7 @@ kw("do", {isLoop: true})
kw("else", beforeExpr)
kw("finally")
kw("for", {isLoop: true})
kw("function")
kw("function", startsExpr)
kw("if")
kw("return", beforeExpr)
kw("switch")

View File

@@ -4,12 +4,11 @@ import * as acorn from "../../acorn";
import * as util from "../util";
import fs from "fs";
export { util, acorn };
export { util, acorn, transform };
export { canCompile } from "../util";
export { default as options } from "../transformation/file/options";
export { default as Transformer } from "../transformation/transformer";
export { default as transform } from "../transformation";
export { default as traverse } from "../traversal";
export { default as buildExternalHelpers } from "../tools/build-external-helpers";
export { version } from "../../../package";
@@ -54,3 +53,19 @@ export function transformFileSync(filename: string, opts?: Object = {}) {
opts.filename = filename;
return transform(fs.readFileSync(filename), opts);
}
export function parse(code, opts = {}) {
opts.sourceType = "module";
opts.ecmaVersion = Infinity;
opts.plugins = {
flow: true,
jsx: true
};
opts.features = {};
for (var key in transform.transformers) {
opts.features[key] = true;
}
return acorn.parse(code, opts);
}

View File

@@ -44,11 +44,10 @@ export default function (loc, opts = {}) {
find(up, rel);
}
}
if (opts.breakConfig !== true) {
find(loc, rel);
}
return opts;
};

View File

@@ -49,11 +49,12 @@ var remapVisitor = {
if (node._skipModulesRemap) {
return this.skip();
}
},
exit(node, parent, scope, formatter) {
if (t.isAssignmentExpression(node) && !node._ignoreModulesRemap) {
var exported = formatter.getExport(node.left, scope);
if (exported) {
this.skip();
return formatter.remapExportAssignment(node, exported);
}
}

View File

@@ -105,6 +105,7 @@ export default class AMDFormatter extends DefaultFormatter {
exportSpecifier(specifier, node, nodes) {
if (this.doDefaultExportInterop(specifier)) {
this.passModuleArg = true;
nodes.push(util.template("exports-default-assign", {
VALUE: specifier.local
}, true));

View File

@@ -1,6 +1,6 @@
(function (FUNCTION_KEY) {
function* FUNCTION_ID() {
return yield* FUNCTION_ID.apply(this, arguments);
return yield* FUNCTION_KEY.apply(this, arguments);
}
FUNCTION_ID.toString = function () {

View File

@@ -465,14 +465,14 @@ class BlockScoping {
var declar;
//
for (var i = 0; i < declarators.length; i++) {
for (let i = 0; i < declarators.length; i++) {
declar = declarators[i];
extend(this.outsideLetReferences, t.getBindingIdentifiers(declar));
}
//
if (block.body) {
for (i = 0; i < block.body.length; i++) {
for (let i = 0; i < block.body.length; i++) {
declar = block.body[i];
if (isLet(declar, block)) {
declarators = declarators.concat(declar.declarations);
@@ -481,7 +481,7 @@ class BlockScoping {
}
//
for (i = 0; i < declarators.length; i++) {
for (let i = 0; i < declarators.length; i++) {
declar = declarators[i];
var keys = t.getBindingIdentifiers(declar);
extend(this.letReferences, keys);

View File

@@ -552,6 +552,11 @@ class ClassTransformer {
this.instancePropBody.push(t.expressionStatement(
t.assignmentExpression("=", t.memberExpression(t.thisExpression(), node.key), node.value)
));
node.value = null;
}
if (!node.value) {
node.value = t.identifier("undefined");
}

View File

@@ -6,6 +6,7 @@ import map from "lodash/collection/map";
import * as t from "../../../types";
exports.Function = function (node, parent, scope, file) {
if (node.generator || node.async) return;
var tailCall = new TailCallTransformer(this, scope, file);
tailCall.run();
};

View File

@@ -29,14 +29,13 @@ var immutabilityVisitor = {
};
export function JSXElement(node, parent, scope, file) {
if (node._ignoreConstant) return;
if (node._hoisted) return;
var state = { isImmutable: true };
this.traverse(immutabilityVisitor, state);
this.skip();
if (state.isImmutable) {
this.hoist();
node._ignoreConstant = true;
}
if (state.isImmutable) this.hoist();
node._hoisted = true;
}

View File

@@ -41,6 +41,7 @@
"unshift": "array/unshift",
"values": "array/values"
},
"Object": {
"assign": "object/assign",
"classof": "object/classof",
@@ -65,13 +66,16 @@
"setPrototypeOf": "object/set-prototype-of",
"values": "object/values"
},
"RegExp": {
"escape": "regexp/escape"
},
"Function": {
"only": "function/only",
"part": "function/part"
},
"Math": {
"acosh": "math/acosh",
"asinh": "math/asinh",
@@ -81,6 +85,7 @@
"cosh": "math/cosh",
"expm1": "math/expm1",
"fround": "math/fround",
"hypot": "math/hypot",
"pot": "math/pot",
"imul": "math/imul",
"log10": "math/log10",
@@ -91,11 +96,13 @@
"tanh": "math/tanh",
"trunc": "math/trunc"
},
"Date": {
"addLocale": "date/add-locale",
"formatUTC": "date/format-utc",
"format": "date/format"
},
"Symbol": {
"for": "symbol/for",
"hasInstance": "symbol/for-instance",
@@ -110,6 +117,49 @@
"toPrimitive": "symbol/to-primitive",
"toStringTag": "symbol/to-string-tag",
"unscopables": "symbol/unscopables"
},
"String": {
"at": "string/at",
"codePointAt": "string/code-point-at",
"endsWith": "string/ends-with",
"escapeHTML": "string/escape-html",
"fromCodePoint": "string/from-code-point",
"includes": "string/includes",
"raw": "string/raw",
"repeat": "string/repeat",
"startsWith": "string/starts-with",
"unescapeHTML": "string/unescape-html"
},
"Number": {
"EPSILON": "number/epsilon",
"isFinite": "number/is-finite",
"isInteger": "number/is-integer",
"isNaN": "number/is-nan",
"isSafeInteger": "number/is-safe-integer",
"MAX_SAFE_INTEGER": "number/max-safe-integer",
"MIN_SAFE_INTEGER": "number/min-safe-integer",
"parseFloat": "number/parse-float",
"parseInt": "number/parse-int",
"random": "number/random"
},
"Reflect": {
"apply": "reflect/apply",
"construct": "reflect/construct",
"defineProperty": "reflect/define-property",
"deleteProperty": "reflect/delete-property",
"enumerate": "reflect/enumerate",
"getOwnPropertyDescriptor": "reflect/get-own-property-descriptor",
"getPrototypeOf": "reflect/get-prototype-of",
"get": "reflect/get",
"has": "reflect/has",
"isExtensible": "reflect/is-extensible",
"ownKeys": "reflect/own-keys",
"preventExtensions": "reflect/prevent-extensions",
"setPrototypeOf": "reflect/set-prototype-of",
"set": "reflect/set"
}
}
}

View File

@@ -1,4 +1,5 @@
import includes from "lodash/collection/includes";
import traverse from "../../../../traversal";
import * as util from "../../../../util";
import has from "lodash/object/has";
import * as t from "../../../../types";
@@ -8,53 +9,88 @@ var isSymbolIterator = t.buildMatchMemberExpression("Symbol.iterator");
const RUNTIME_MODULE_NAME = "babel-runtime";
var astVisitor = {
enter(node, parent, scope, file) {
var prop;
var astVisitor = traverse.explode({
Identifier(node, parent, scope, file) {
if (!this.isReferenced()) return;
if (t.isMemberExpression(parent)) return;
if (!has(definitions.builtins, node.name)) return;
if (scope.getBindingIdentifier(node.name)) return;
if (this.isMemberExpression() && this.isReferenced()) {
// Symbol() -> _core.Symbol(); new Promise -> new _core.Promise
var modulePath = definitions.builtins[node.name];
return file.addImport(`${RUNTIME_MODULE_NAME}/core-js/${modulePath}`, node.name, true);
},
CallExpression(node, parent, scope, file) {
// arr[Symbol.iterator]() -> _core.$for.getIterator(arr)
var callee = node.callee;
if (node.arguments.length) return;
if (!t.isMemberExpression(callee)) return;
if (!callee.computed) return;
var prop = callee.property;
if (!isSymbolIterator(prop)) return;
return t.callExpression(file.addImport(`${RUNTIME_MODULE_NAME}/core-js/get-iterator`, "getIterator", true), [callee.object]);
},
BinaryExpression(node, parent, scope, file) {
// Symbol.iterator in arr -> core.$for.isIterable(arr)
if (node.operator !== "in") return;
var left = node.left;
if (!isSymbolIterator(left)) return;
return t.callExpression(
file.addImport(`${RUNTIME_MODULE_NAME}/core-js/is-iterable`, "isIterable", true),
[node.right]
);
},
MemberExpression: {
enter(node, parent, scope, file) {
// Array.from -> _core.Array.from
if (!this.isReferenced()) return;
var obj = node.object;
prop = node.property;
var prop = node.property;
if (!t.isReferenced(obj, node)) return;
if (node.computed) return;
if (!has(definitions.methods, obj.name)) return;
if (!has(definitions.methods[obj.name], prop.name)) return;
var methods = definitions.methods[obj.name];
if (!has(methods, prop.name)) return;
if (scope.getBindingIdentifier(obj.name)) return;
var modulePath = definitions.methods[obj.name][prop.name];
var modulePath = methods[prop.name];
return file.addImport(`${RUNTIME_MODULE_NAME}/core-js/${modulePath}`, `${obj.name}$${prop.name}`, true);
} else if (this.isReferencedIdentifier() && !t.isMemberExpression(parent) && has(definitions.builtins, node.name) && !scope.getBindingIdentifier(node.name)) {
// Symbol() -> _core.Symbol(); new Promise -> new _core.Promise
var modulePath = definitions.builtins[node.name];
return file.addImport(`${RUNTIME_MODULE_NAME}/core-js/${modulePath}`, node.name, true);
} else if (this.isCallExpression()) {
// arr[Symbol.iterator]() -> _core.$for.getIterator(arr)
},
var callee = node.callee;
if (node.arguments.length) return false;
exit(node, parent, scope, file) {
if (!this.isReferenced()) return;
if (!t.isMemberExpression(callee)) return false;
if (!callee.computed) return false;
var prop = node.property;
var obj = node.object;
prop = callee.property;
if (!isSymbolIterator(prop)) return false;
if (!has(definitions.builtins, obj.name)) return;
if (scope.getBindingIdentifier(obj.name)) return;
return t.callExpression(file.addImport(`${RUNTIME_MODULE_NAME}/core-js/get-iterator`, "getIterator", true), [callee.object]);
} else if (this.isBinaryExpression()) {
// Symbol.iterator in arr -> core.$for.isIterable(arr)
if (node.operator !== "in") return;
var left = node.left;
if (!isSymbolIterator(left)) return;
return t.callExpression(file.addImport(`${RUNTIME_MODULE_NAME}/core-js/is-iterable`, "isIterable", true), [node.right]);
var modulePath = definitions.builtins[obj.name];
return t.memberExpression(
file.addImport(`${RUNTIME_MODULE_NAME}/core-js/${modulePath}`, `${obj.name}`, true),
prop
);
}
}
};
});
exports.metadata = {
optional: true

View File

@@ -78,6 +78,9 @@ traverse.removeProperties = function (tree) {
traverse.explode = function (obj) {
for (var type in obj) {
var fns = obj[type];
if (typeof fns === "function") {
obj[type] = fns = { enter: fns };
}
var aliases = t.FLIPPED_ALIAS_KEYS[type];
if (aliases) {

View File

@@ -19,7 +19,6 @@ var referenceVisitor = {
if (bindingInfo && bindingInfo.constant) {
state.bindings[node.name] = bindingInfo;
} else {
scope.dump();
state.foundIncompatible = true;
this.stop();
}
@@ -90,6 +89,10 @@ export default class PathHoister {
}
run() {
var node = this.path.node;
if (node._hoisted) return;
this.path._hoisted = true;
this.path.traverse(referenceVisitor, this);
if (this.foundIncompatible) return;

View File

@@ -25,7 +25,7 @@ function registerType(type: string, skipAliasCheck?: boolean) {
}
export var STATEMENT_OR_BLOCK_KEYS = ["consequent", "body", "alternate"];
export var NATIVE_TYPE_NAMES = ["Array", "Object", "Number", "Boolean", "Date", "Array", "String", "Promise", "Set", "Map", "WeakMap", "WeakSet", "Uint16Array", "ArrayBuffer", "DataView", "Int8Array", "Uint8Array", "Uint8ClampedArray", "Uint32Array", "Int32Array", "Float32Array", "Int16Array", "Float64Array"];
export var NATIVE_TYPE_NAMES = ["Array", "ArrayBuffer", "Boolean", "DataView", "Date", "Error", "EvalError", "Float32Array", "Float64Array", "Function", "Int8Array", "Int16Array", "Int32Array", "Map", "Number", "Object", "Proxy", "Promise", "RangeError", "ReferenceError", "RegExp", "Set", "String", "Symbol", "SyntaxError", "TypeError", "Uint8Array", "Uint8ClampedArray", "Uint16Array", "Uint32Array", "URIError", "WeakMap", "WeakSet"];
export var FLATTENABLE_KEYS = ["body", "expressions"];
export var FOR_INIT_KEYS = ["left", "init"];
export var COMMENT_KEYS = ["leadingComments", "trailingComments"];

View File

@@ -2,6 +2,14 @@ var test = require("./driver.js").test;
var testFail = require("./driver.js").testFail;
var testAssert = require("./driver.js").testAssert;
testFail("({a}) = 2;", "You're trying to assign to a parenthesized expression, eg. instead of `({a}) = 0` use `({a} = 0)` (1:1)", {
ecmaVersion: 6
});
testFail("([a]) = 2;", "You're trying to assign to a parenthesized expression, eg. instead of `([a]) = 0` use `([a] = 0)` (1:1)", {
ecmaVersion: 6
});
// ES7: Exponentiation Operator
test('a **= 2;', {
@@ -2461,6 +2469,166 @@ test("class Foo { @foo @bar bar() {} }", {
features: { "es7.decorators": true }
});
test('@foo({ @bar foo: "bar" }) @bar class Foo {}', {
"start": 0,
"body": [{
"start": 31,
"decorators": [{
"start": 0,
"expression": {
"start": 1,
"callee": {
"start": 1,
"name": "foo",
"type": "Identifier",
"end": 4
},
"arguments": [{
"start": 5,
"properties": [{
"start": 12,
"decorators": [{
"start": 7,
"expression": {
"start": 8,
"name": "bar",
"type": "Identifier",
"end": 11
},
"type": "Decorator",
"end": 11
}],
"method": false,
"shorthand": false,
"computed": false,
"key": {
"start": 12,
"name": "foo",
"type": "Identifier",
"end": 15
},
"value": {
"start": 17,
"value": "bar",
"raw": "\"bar\"",
"type": "Literal",
"end": 22
},
"kind": "init",
"type": "Property",
"end": 22
}],
"type": "ObjectExpression",
"end": 24
}],
"type": "CallExpression",
"end": 25
},
"type": "Decorator",
"end": 25
},
{
"start": 26,
"expression": {
"start": 27,
"name": "bar",
"type": "Identifier",
"end": 30
},
"type": "Decorator",
"end": 30
}],
"id": {
"start": 37,
"name": "Foo",
"type": "Identifier",
"end": 40
},
"superClass": null,
"body": {
"start": 41,
"body": [],
"type": "ClassBody",
"end": 43
},
"type": "ClassDeclaration",
"end": 43
}],
"sourceType": "script",
"type": "Program",
"end": 43
}, {
ecmaVersion: 6,
features: { "es7.decorators": true }
});
test('@bar class Foo extends @foo class Bar {} {}', {
"start": 0,
"body": [{
"start": 5,
"decorators": [{
"start": 0,
"expression": {
"start": 1,
"name": "bar",
"type": "Identifier",
"end": 4
},
"type": "Decorator",
"end": 4
}],
"id": {
"start": 11,
"name": "Foo",
"type": "Identifier",
"end": 14
},
"superClass": {
"start": 28,
"decorators": [{
"start": 23,
"expression": {
"start": 24,
"name": "foo",
"type": "Identifier",
"end": 27
},
"type": "Decorator",
"end": 27
}],
"id": {
"start": 34,
"name": "Bar",
"type": "Identifier",
"end": 37
},
"superClass": null,
"body": {
"start": 38,
"body": [],
"type": "ClassBody",
"end": 40
},
"type": "ClassExpression",
"end": 40
},
"body": {
"start": 41,
"body": [],
"type": "ClassBody",
"end": 43
},
"type": "ClassDeclaration",
"end": 43
}],
"sourceType": "script",
"type": "Program",
"end": 43
}, {
ecmaVersion: 6,
features: { "es7.decorators": true }
});
testFail("@foo function bar() {}", "Leading decorators must be attached to a class declaration (1:5)", {
ecmaVersion: 6,
features: { "es7.decorators": true }

View File

@@ -0,0 +1,2 @@
var a = 1;
export { a as default };

View File

@@ -0,0 +1,6 @@
define(["exports", "module"], function (exports, module) {
"use strict";
var a = 1;
module.exports = a;
});

View File

@@ -0,0 +1,3 @@
class Foo {
bar;
}

View File

@@ -0,0 +1,14 @@
"use strict";
var Foo = (function () {
function Foo() {
babelHelpers.classCallCheck(this, Foo);
}
babelHelpers.createClass(Foo, [{
key: "bar",
value: undefined,
enumerable: true
}]);
return Foo;
})();

View File

@@ -0,0 +1,3 @@
class Foo {
static bar;
}

View File

@@ -0,0 +1,6 @@
class Foo {
static num;
}
assert.equal("num" in Foo, true);
assert.equal(Foo.num, undefined);

View File

@@ -0,0 +1,14 @@
"use strict";
var Foo = (function () {
function Foo() {
babelHelpers.classCallCheck(this, Foo);
}
babelHelpers.createClass(Foo, null, [{
key: "bar",
value: undefined,
enumerable: true
}]);
return Foo;
})();

View File

@@ -0,0 +1 @@
Promise.resolve;

View File

@@ -0,0 +1,5 @@
"use strict";
var _Promise = require("babel-runtime/core-js/promise")["default"];
_Promise.resolve;