Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a45d6960da | ||
|
|
b13aa41a75 | ||
|
|
20a4ed6140 | ||
|
|
c256e060b3 | ||
|
|
bef315efd6 | ||
|
|
2ec5390b63 | ||
|
|
f4c9dd8768 | ||
|
|
510c7a3e60 | ||
|
|
3ce9508a1c | ||
|
|
717ef280f7 | ||
|
|
8c5e7cf272 | ||
|
|
811a843be9 | ||
|
|
b7c297bb89 | ||
|
|
b7342ef4ea | ||
|
|
1a899f5e77 | ||
|
|
f2eb1643c0 | ||
|
|
9621d1bbeb | ||
|
|
3cf7b2b761 | ||
|
|
ae8b1e242b | ||
|
|
eea48f866d | ||
|
|
84d2d7b7d4 | ||
|
|
ea30a619dd | ||
|
|
87a201db22 |
17
CHANGELOG.md
17
CHANGELOG.md
@@ -13,6 +13,23 @@ _Note: Gaps between patch versions are faulty/broken releases._
|
||||
|
||||
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
|
||||
|
||||
## 4.4.6
|
||||
|
||||
* **Bug Fix**
|
||||
* Fix extending a class expression with no methods/only constructor. Thanks [@neVERberleRfellerER](https://github.com/neVERberleRfellerER)!
|
||||
* Allow `MemberExpression` as a valid `left` of `ForOfStatement`.
|
||||
* **Polish**
|
||||
* Throw an error when people try and transpile code with the `@jsx React.DOM` pragma as it conflicts with the custom jsx constructo method detection.
|
||||
* Crawl all comments for `@jsx` pragma.
|
||||
* **Internal**
|
||||
* Upgrade `chalk`.
|
||||
* Upgrade `core-js`.
|
||||
|
||||
## 4.4.5
|
||||
|
||||
* **Internal**
|
||||
* Remove function self reference optimisation.
|
||||
|
||||
## 4.4.4
|
||||
|
||||
* **Bug Fix**
|
||||
|
||||
@@ -44,16 +44,19 @@ module.exports = function (exports, opts) {
|
||||
};
|
||||
|
||||
exports.JSXAttribute = {
|
||||
exit: function (node) {
|
||||
var value = node.value || t.literal(true);
|
||||
|
||||
enter: function (node) {
|
||||
var value = node.value;
|
||||
if (t.isLiteral(value) && isString(value.value)) {
|
||||
value.value = value.value.replace(/\n\s+/g, " ");
|
||||
}
|
||||
},
|
||||
|
||||
exit: function (node) {
|
||||
var value = node.value || t.literal(true);
|
||||
return t.inherits(t.property("init", node.name, value), node);
|
||||
}
|
||||
};
|
||||
|
||||
exports.JSXOpeningElement = {
|
||||
exit: function (node, parent, scope, file) {
|
||||
var tagExpr = node.name;
|
||||
|
||||
@@ -65,6 +65,7 @@ function ClassTransformer(node, file, scope, isStatement) {
|
||||
ClassTransformer.prototype.run = function () {
|
||||
var superName = this.superName;
|
||||
var className = this.className;
|
||||
var classBody = this.node.body.body;
|
||||
var file = this.file;
|
||||
|
||||
//
|
||||
@@ -77,13 +78,21 @@ ClassTransformer.prototype.run = function () {
|
||||
className
|
||||
]))
|
||||
]);
|
||||
var constructor;
|
||||
|
||||
var constructor;
|
||||
if (this.node.id) {
|
||||
constructor = t.functionDeclaration(className, [], constructorBody);
|
||||
body.push(constructor);
|
||||
} else {
|
||||
constructor = t.functionExpression(null, [], constructorBody);
|
||||
var constructorName = null;
|
||||
// when a class has no parent and there is only a constructor or no body
|
||||
// then the constructor is not wrapped in a closure and needs to be named
|
||||
var containsOnlyConstructor = classBody.length === 1 && classBody[0].key.name === "constructor";
|
||||
if (!this.hasSuper && (classBody.length === 0 || containsOnlyConstructor)) {
|
||||
constructorName = className;
|
||||
}
|
||||
|
||||
constructor = t.functionExpression(constructorName, [], constructorBody);
|
||||
body.push(t.variableDeclaration("var", [
|
||||
t.variableDeclarator(className, constructor)
|
||||
]));
|
||||
|
||||
@@ -65,7 +65,7 @@ var loose = function (node, parent, scope, file) {
|
||||
var left = node.left;
|
||||
var declar, id;
|
||||
|
||||
if (t.isIdentifier(left) || t.isPattern(left)) {
|
||||
if (t.isIdentifier(left) || t.isPattern(left) || t.isMemberExpression(left)) {
|
||||
// for (i of test), for ({ i } of test)
|
||||
id = left;
|
||||
} else if (t.isVariableDeclaration(left)) {
|
||||
@@ -126,7 +126,7 @@ var spec = function (node, parent, scope, file) {
|
||||
var stepKey = scope.generateUidIdentifier("step");
|
||||
var stepValue = t.memberExpression(stepKey, t.identifier("value"));
|
||||
|
||||
if (t.isIdentifier(left) || t.isPattern(left)) {
|
||||
if (t.isIdentifier(left) || t.isPattern(left) || t.isMemberExpression(left)) {
|
||||
// for (i of test), for ({ i } of test)
|
||||
declar = t.expressionStatement(t.assignmentExpression("=", left, stepValue));
|
||||
} else if (t.isVariableDeclaration(left)) {
|
||||
|
||||
@@ -10,6 +10,9 @@ module.exports = {
|
||||
"validation.react": require("./validation/react"),
|
||||
"spec.blockScopedFunctions": require("./spec/block-scoped-functions"),
|
||||
|
||||
// needs to be before `_aliasFunction`
|
||||
"es6.arrowFunctions": require("./es6/arrow-functions"),
|
||||
|
||||
"playground.malletOperator": require("./playground/mallet-operator"),
|
||||
"playground.methodBinding": require("./playground/method-binding"),
|
||||
"playground.memoizationOperator": require("./playground/memoization-operator"),
|
||||
@@ -25,9 +28,6 @@ module.exports = {
|
||||
// needs to be before `_aliasFunction`
|
||||
"es7.comprehensions": require("./es7/comprehensions"),
|
||||
|
||||
// needs to be before `_aliasFunction`
|
||||
"es6.arrowFunctions": require("./es6/arrow-functions"),
|
||||
|
||||
"es6.classes": require("./es6/classes"),
|
||||
|
||||
asyncToGenerator: require("./other/async-to-generator"),
|
||||
|
||||
@@ -8,10 +8,17 @@ var JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/;
|
||||
exports.Program = function (node, parent, scope, file) {
|
||||
var id = "React.createElement";
|
||||
|
||||
var comment = file.ast.comments[0];
|
||||
if (comment) {
|
||||
for (var i = 0; i < file.ast.comments.length; i++) {
|
||||
var comment = file.ast.comments[i];
|
||||
var matches = JSX_ANNOTATION_REGEX.exec(comment.value);
|
||||
if (matches) id = matches[1];
|
||||
if (matches) {
|
||||
id = matches[1];
|
||||
if (id === "React.DOM") {
|
||||
throw file.errorWithNode(comment, "The @jsx React.DOM pragma has been deprecated as of React 0.12");
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
file.set("jsxIdentifier", id.split(".").map(t.identifier).reduce(function (object, property) {
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
"AssignmentPattern": ["Pattern"],
|
||||
|
||||
"Property": ["UserWhitespacable"],
|
||||
"JSXElement": ["UserWhitespacable", "Expression"],
|
||||
|
||||
"ArrayExpression": ["Expression"],
|
||||
"AssignmentExpression": ["Expression"],
|
||||
@@ -74,7 +73,7 @@
|
||||
|
||||
"JSXAttribute": ["JSX"],
|
||||
"JSXClosingElement": ["JSX"],
|
||||
"JSXElement": ["JSX"],
|
||||
"JSXElement": ["JSX", "Expression"],
|
||||
"JSXEmptyExpression": ["JSX"],
|
||||
"JSXExpressionContainer": ["JSX"],
|
||||
"JSXIdentifier": ["JSX"],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "babel",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "4.4.5",
|
||||
"version": "4.4.6",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
"repository": "babel/babel",
|
||||
@@ -38,10 +38,10 @@
|
||||
"dependencies": {
|
||||
"acorn-babel": "0.11.1-34",
|
||||
"ast-types": "~0.6.1",
|
||||
"chalk": "^0.5.1",
|
||||
"chalk": "^1.0.0",
|
||||
"chokidar": "^0.12.6",
|
||||
"commander": "^2.6.0",
|
||||
"core-js": "^0.5.4",
|
||||
"core-js": "^0.6.1",
|
||||
"debug": "^2.1.1",
|
||||
"detect-indent": "^3.0.0",
|
||||
"estraverse": "^1.9.1",
|
||||
@@ -56,7 +56,7 @@
|
||||
"output-file-sync": "^1.1.0",
|
||||
"path-is-absolute": "^1.0.0",
|
||||
"private": "^0.1.6",
|
||||
"regenerator-babel": "0.8.10-2",
|
||||
"regenerator-babel": "0.8.13-1",
|
||||
"regexpu": "^1.1.1",
|
||||
"repeating": "^1.1.2",
|
||||
"shebang-regex": "^1.0.0",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "babel-runtime",
|
||||
"description": "babel selfContained runtime",
|
||||
"version": "4.4.4",
|
||||
"version": "4.4.5",
|
||||
"repository": "babel/babel",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>"
|
||||
}
|
||||
20
test/fixtures/transformation/es6-classes/super-class-anonymous/actual.js
vendored
Normal file
20
test/fixtures/transformation/es6-classes/super-class-anonymous/actual.js
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
class TestEmpty extends (class {}) {
|
||||
}
|
||||
|
||||
class TestConstructorOnly extends (class { constructor() {} }) {
|
||||
}
|
||||
|
||||
class TestMethodOnly extends (class { method() {} }) {
|
||||
}
|
||||
|
||||
class TestConstructorAndMethod extends (class {
|
||||
constructor() {}
|
||||
method() {}
|
||||
}) {
|
||||
}
|
||||
|
||||
class TestMultipleMethods extends (class {
|
||||
m1() {}
|
||||
m2() {}
|
||||
}) {
|
||||
}
|
||||
129
test/fixtures/transformation/es6-classes/super-class-anonymous/expected.js
vendored
Normal file
129
test/fixtures/transformation/es6-classes/super-class-anonymous/expected.js
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
"use strict";
|
||||
|
||||
var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
|
||||
|
||||
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
||||
|
||||
var TestEmpty = (function (_ref) {
|
||||
function TestEmpty() {
|
||||
_classCallCheck(this, TestEmpty);
|
||||
|
||||
if (_ref != null) {
|
||||
_ref.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
_inherits(TestEmpty, _ref);
|
||||
|
||||
return TestEmpty;
|
||||
})(function _class() {
|
||||
_classCallCheck(this, _class);
|
||||
});
|
||||
|
||||
var TestConstructorOnly = (function (_ref2) {
|
||||
function TestConstructorOnly() {
|
||||
_classCallCheck(this, TestConstructorOnly);
|
||||
|
||||
if (_ref2 != null) {
|
||||
_ref2.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
_inherits(TestConstructorOnly, _ref2);
|
||||
|
||||
return TestConstructorOnly;
|
||||
})(function _class2() {
|
||||
_classCallCheck(this, _class2);
|
||||
});
|
||||
|
||||
var TestMethodOnly = (function (_ref3) {
|
||||
function TestMethodOnly() {
|
||||
_classCallCheck(this, TestMethodOnly);
|
||||
|
||||
if (_ref3 != null) {
|
||||
_ref3.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
_inherits(TestMethodOnly, _ref3);
|
||||
|
||||
return TestMethodOnly;
|
||||
})((function () {
|
||||
var _class3 = function () {
|
||||
_classCallCheck(this, _class3);
|
||||
};
|
||||
|
||||
_prototypeProperties(_class3, null, {
|
||||
method: {
|
||||
value: function method() {},
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
|
||||
return _class3;
|
||||
})());
|
||||
|
||||
var TestConstructorAndMethod = (function (_ref4) {
|
||||
function TestConstructorAndMethod() {
|
||||
_classCallCheck(this, TestConstructorAndMethod);
|
||||
|
||||
if (_ref4 != null) {
|
||||
_ref4.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
_inherits(TestConstructorAndMethod, _ref4);
|
||||
|
||||
return TestConstructorAndMethod;
|
||||
})((function () {
|
||||
var _class4 = function () {
|
||||
_classCallCheck(this, _class4);
|
||||
};
|
||||
|
||||
_prototypeProperties(_class4, null, {
|
||||
method: {
|
||||
value: function method() {},
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
|
||||
return _class4;
|
||||
})());
|
||||
|
||||
var TestMultipleMethods = (function (_ref5) {
|
||||
function TestMultipleMethods() {
|
||||
_classCallCheck(this, TestMultipleMethods);
|
||||
|
||||
if (_ref5 != null) {
|
||||
_ref5.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
_inherits(TestMultipleMethods, _ref5);
|
||||
|
||||
return TestMultipleMethods;
|
||||
})((function () {
|
||||
var _class5 = function () {
|
||||
_classCallCheck(this, _class5);
|
||||
};
|
||||
|
||||
_prototypeProperties(_class5, null, {
|
||||
m1: {
|
||||
value: function m1() {},
|
||||
writable: true,
|
||||
configurable: true
|
||||
},
|
||||
m2: {
|
||||
value: function m2() {},
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
|
||||
return _class5;
|
||||
})());
|
||||
|
||||
3
test/fixtures/transformation/es6-for-of-loose/member-expression/actual.js
vendored
Normal file
3
test/fixtures/transformation/es6-for-of-loose/member-expression/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
for (obj.prop of arr) {
|
||||
|
||||
}
|
||||
12
test/fixtures/transformation/es6-for-of-loose/member-expression/expected.js
vendored
Normal file
12
test/fixtures/transformation/es6-for-of-loose/member-expression/expected.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
for (var _iterator = arr, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
||||
if (_isArray) {
|
||||
if (_i >= _iterator.length) break;
|
||||
obj.prop = _iterator[_i++];
|
||||
} else {
|
||||
_i = _iterator.next();
|
||||
if (_i.done) break;
|
||||
obj.prop = _i.value;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
for (foo.bar of test) {
|
||||
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "Unknown node type \"MemberExpression\" in ForStatement"
|
||||
}
|
||||
3
test/fixtures/transformation/es6-for-of/member-expression/actual.js
vendored
Normal file
3
test/fixtures/transformation/es6-for-of/member-expression/actual.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
for (obj.prop of arr) {
|
||||
|
||||
}
|
||||
5
test/fixtures/transformation/es6-for-of/member-expression/expected.js
vendored
Normal file
5
test/fixtures/transformation/es6-for-of/member-expression/expected.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
|
||||
obj.prop = _step.value;
|
||||
}
|
||||
Reference in New Issue
Block a user