Compare commits

...

30 Commits

Author SHA1 Message Date
Sebastian McKenzie
06a31c419a v5.0.12 2015-04-08 08:55:02 -07:00
Sebastian McKenzie
da566110c0 add 5.0.12 changelog 2015-04-08 08:53:40 -07:00
Sebastian McKenzie
c12c4a5c39 don't touch function name containers when remapping modules - fixes #1160 2015-04-08 08:52:53 -07:00
Sebastian McKenzie
d114349890 5.0.11 2015-04-08 08:15:15 -07:00
Sebastian McKenzie
8d6ae0e1eb v5.0.11 2015-04-08 08:14:28 -07:00
Sebastian McKenzie
cb8b47ee2f add missing curly brace to regression test 2015-04-08 08:13:33 -07:00
Sebastian McKenzie
daf24c5c59 add 5.0.10 changelog 2015-04-08 08:12:33 -07:00
Sebastian McKenzie
cdb2784e75 add #1199 regression test 2015-04-08 08:11:01 -07:00
Sebastian McKenzie
93feabb82e fix forOf loop inheritance - fixes #1169 2015-04-08 08:10:53 -07:00
Sebastian McKenzie
982c142bf6 Merge branch 'master' of github.com:babel/babel 2015-04-08 07:47:52 -07:00
Sebastian McKenzie
de5520a94f disable scope caching 2015-04-08 07:42:04 -07:00
Sebastian McKenzie
c239d06f10 fix MetaProperty generation 2015-04-08 07:41:56 -07:00
Sebastian McKenzie
a5fed376d8 Merge pull request #1191 from zertosh/babelrc-comments
Strip out comments before parsing babelrc
2015-04-07 18:09:07 -07:00
Sebastian McKenzie
e99fd77d89 downgrade and fix mocha version - fixes #1196 2015-04-07 18:07:23 -07:00
Sebastian McKenzie
1374863b9c 5.0.10 2015-04-07 18:06:52 -07:00
Andres Suarez
e88c28f88b Strip out comments before parsing babelrc 2015-04-07 18:50:01 -04:00
Sebastian McKenzie
7a0fd26f56 v5.0.10 2015-04-07 13:04:25 -07:00
Sebastian McKenzie
17583e4807 fix decrators modules test 2015-04-07 13:03:41 -07:00
Sebastian McKenzie
37dd5137ff don't modules reassign _ignoreModulesRemap assignments 2015-04-07 13:02:28 -07:00
Sebastian McKenzie
24fced406e Merge branch 'master' of github.com:babel/babel 2015-04-07 09:55:11 -07:00
Sebastian McKenzie
0ab1362893 don't reassign decorated classes - fixes #1167 2015-04-07 09:54:14 -07:00
Sebastian McKenzie
96506f4249 5.0.9 2015-04-07 09:20:40 -07:00
Sebastian McKenzie
ed747f88bd Merge pull request #1185 from Dignifiedquire/class-decorators-scope
Take 2: Fix class decorator scoping.
2015-04-07 08:49:56 -07:00
dignifiedquire
3987545b4f Ensure correct scope for decorated classes. 2015-04-07 14:57:15 +02:00
dignifiedquire
148aa3f96d Use a functionExpression with class decorators. Fixes #1161. 2015-04-07 14:16:48 +02:00
Sebastian McKenzie
0cb5a7c91e Revert "Use a functionExpression with class decorators. Fixes #1161."
This reverts commit f8d56d9612.
2015-04-07 04:40:39 -07:00
Sebastian McKenzie
fc34d5a9b0 Merge pull request #1184 from Dignifiedquire/class-decorators
Use a functionExpression with class decorators. Fixes #1161.
2015-04-07 03:39:59 -07:00
dignifiedquire
f8d56d9612 Use a functionExpression with class decorators. Fixes #1161. 2015-04-07 12:11:49 +02:00
Brian Donovan
737be0e95e Merge pull request #1173 from alawatthe/patch-1
Fixed path for mocha tests in CONTRIBUTING.md
2015-04-06 09:56:31 -07:00
Alexander Zeilmann
26e2b392e8 Fixed path for mocha tests 2015-04-06 18:38:33 +02:00
28 changed files with 314 additions and 28 deletions

View File

@@ -13,6 +13,20 @@ _Note: Gaps between patch versions are faulty/broken releases._
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
## 5.0.12
* **Bug Fix**
* Fix incorrect remapping of module references inside of a function id redirection container.
## 5.0.11
* **Bug Fix**
* Fix new `for...of` loops not properly inheriting their original loop.
* **Internal**
* Disable scope instance cache.
* **Polish**
* Allow comments in `.babelrc` JSON.
## 5.0.9
* **Polish**

View File

@@ -35,13 +35,13 @@ This is mostly overkill and you can limit the tests to a select few by directly
running them with `mocha`:
```sh
$ mocha test/transformation.js
$ mocha test/core/transformation.js
```
Use mocha's `--grep` option to run a subset of tests by name:
```sh
$ mocha test/transformation.js --grep es7
$ mocha test/core/transformation.js --grep es7
```
#### Workflow

View File

@@ -1,7 +1,7 @@
{
"name": "babel-core",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "5.0.9",
"version": "5.0.12",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
"repository": "babel/babel",
@@ -53,6 +53,7 @@
"slash": "^1.0.0",
"source-map": "^0.4.0",
"source-map-support": "^0.2.9",
"strip-json-comments": "^1.0.2",
"to-fast-properties": "^1.0.0",
"trim-right": "^1.0.0"
},
@@ -65,7 +66,7 @@
"esvalid": "^1.1.0",
"istanbul": "^0.3.5",
"matcha": "^0.6.0",
"mocha": "^2.1.0",
"mocha": "2.1.0",
"rimraf": "^2.2.8",
"uglify-js": "^2.4.16"
}

View File

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

View File

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

View File

@@ -169,4 +169,8 @@ export function MemberExpression(node, print) {
}
}
export { MemberExpression as MetaProperty };
export function MetaProperty(node, print) {
print(node.meta);
this.push(".");
print(node.property);
}

View File

@@ -1,3 +1,4 @@
import stripJsonComments from "strip-json-comments";
import merge from "lodash/object/merge";
import path from "path";
import fs from "fs";
@@ -24,7 +25,7 @@ export default function (loc, opts = {}) {
var json;
try {
json = jsons[content] ||= JSON.parse(content);
json = jsons[content] ||= JSON.parse(stripJsonComments(content));
} catch (err) {
err.message = `${file}: ${err.message}`;
throw err;

View File

@@ -27,6 +27,7 @@ var wrap = function (state, method, id, scope) {
FUNCTION_ID: id,
FUNCTION_KEY: scope.generateUidIdentifier(id.name)
});
template.callee._skipModulesRemap = true;
// shim in dummy params to retain function arity, if you try to read the
// source then you'll get the original since it's proxied so it's all good

View File

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

View File

@@ -30,7 +30,7 @@ var collectPropertyReferencesVisitor = {
}
if (this.isReferenced() && scope.getBinding(node.name) === state.scope.getBinding(node.name)) {
state.references[node.name] = true;;
state.references[node.name] = true;
}
}
}
@@ -170,21 +170,36 @@ class ClassTransformer {
this.buildBody();
var decorators = this.node.decorators;
var classCheckRef = classRef;
if (decorators) {
classCheckRef = this.scope.generateUidIdentifier(classRef);
}
constructorBody.body.unshift(t.expressionStatement(t.callExpression(file.addHelper("class-call-check"), [
t.thisExpression(),
classRef
classCheckRef
])));
//
var decorators = this.node.decorators;
if (decorators) {
if (this.className) {
body.push(t.variableDeclaration("var", [
t.variableDeclarator(classCheckRef, classRef)
]));
}
for (var i = 0; i < decorators.length; i++) {
var decorator = decorators[i];
body.push(util.template("class-decorator", {
var decoratorNode = util.template("class-decorator", {
DECORATOR: decorator.expression,
CLASS_REF: classRef
}, true));
}, true);
decoratorNode.expression._ignoreModulesRemap = true;
body.push(decoratorNode);
}
}

View File

@@ -17,9 +17,6 @@ export function ForOfStatement(node, parent, scope, file) {
var loop = build.loop;
var block = loop.body;
// inherit comments from the original loop
t.inheritsComments(loop, node);
// ensure that it's a block so we can take all its statements
t.ensureBlock(node);
@@ -32,6 +29,7 @@ export function ForOfStatement(node, parent, scope, file) {
block.body = block.body.concat(node.body.body);
t.inherits(loop, node);
t.inherits(loop.body, node.body);
if (build.replaceParent) {
this.parentPath.replaceWithMultiple(build.node);

View File

@@ -80,7 +80,7 @@ export default class Scope {
if (cached && cached.parent === parent) {
return cached;
} else {
path.setData("scope", this);
//path.setData("scope", this);
}
this.parent = parent;

View File

@@ -11,8 +11,8 @@
"CallExpression": ["callee", "arguments"],
"CatchClause": ["param", "body"],
"ClassBody": ["body"],
"ClassDeclaration": ["id", "body", "superClass", "typeParameters", "superTypeParameters", "implements"],
"ClassExpression": ["id", "body", "superClass", "typeParameters", "superTypeParameters", "implements"],
"ClassDeclaration": ["id", "body", "superClass", "typeParameters", "superTypeParameters", "implements", "decorators"],
"ClassExpression": ["id", "body", "superClass", "typeParameters", "superTypeParameters", "implements", "decorators"],
"ComprehensionBlock": ["left", "right", "body"],
"ComprehensionExpression": ["filter", "blocks", "body"],
"ConditionalExpression": ["test", "consequent", "alternate"],
@@ -40,12 +40,12 @@
"LogicalExpression": ["left", "right"],
"MemberExpression": ["object", "property"],
"MetaProperty": ["meta", "property"],
"MethodDefinition": ["key", "value"],
"MethodDefinition": ["key", "value", "decorators"],
"NewExpression": ["callee", "arguments"],
"ObjectExpression": ["properties"],
"ObjectPattern": ["properties", "typeAnnotation"],
"Program": ["body"],
"Property": ["key", "value"],
"Property": ["key", "value", "decorators"],
"RestElement": ["argument", "typeAnnotation"],
"ReturnStatement": ["argument"],
"SequenceExpression": ["expressions"],

View File

@@ -0,0 +1,6 @@
import foo from "foo";
@foo
export default class Foo {
}

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _foo = require("foo");
var _foo2 = babelHelpers.interopRequireWildcard(_foo);
var Foo = (function () {
function Foo() {
babelHelpers.classCallCheck(this, _Foo);
}
var _Foo = Foo;
Foo = _foo2["default"](Foo) || Foo;
return Foo;
})();
exports["default"] = Foo;
module.exports = exports["default"];

View File

@@ -12,3 +12,10 @@ var Foo2 = @bar class Foo {
var Bar2 = @foo @bar class Bar {
};
@foo
class Baz{
constructor(baz) {
this.baz = baz;
}
}

View File

@@ -2,18 +2,20 @@
var Foo = (function () {
function Foo() {
babelHelpers.classCallCheck(this, Foo);
babelHelpers.classCallCheck(this, _Foo);
}
var _Foo = Foo;
Foo = foo(Foo) || Foo;
return Foo;
})();
var Bar = (function () {
function Bar() {
babelHelpers.classCallCheck(this, Bar);
babelHelpers.classCallCheck(this, _Bar);
}
var _Bar = Bar;
Bar = foo(Bar) || Bar;
Bar = bar(Bar) || Bar;
return Bar;
@@ -21,19 +23,33 @@ var Bar = (function () {
var Foo2 = (function () {
function Foo() {
babelHelpers.classCallCheck(this, Foo);
babelHelpers.classCallCheck(this, _Foo2);
}
var _Foo2 = Foo;
Foo = bar(Foo) || Foo;
return Foo;
})();
var Bar2 = (function () {
function Bar() {
babelHelpers.classCallCheck(this, Bar);
babelHelpers.classCallCheck(this, _Bar2);
}
var _Bar2 = Bar;
Bar = foo(Bar) || Bar;
Bar = bar(Bar) || Bar;
return Bar;
})();
})();
var Baz = (function () {
function Baz(baz) {
babelHelpers.classCallCheck(this, _Baz);
this.baz = baz;
}
var _Baz = Baz;
Baz = foo(Baz) || Baz;
return Baz;
})();

View File

@@ -0,0 +1,11 @@
function foo() {
let input = ['a', 'b', 'c']
let output = {}
for (let c of input) {
let name = c
output[name] = name
}
return output
}

View File

@@ -0,0 +1,34 @@
'use strict';
function foo() {
var input = ['a', 'b', 'c'];
var output = {};
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = input[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var c = _step.value;
var _name = c;
output[_name] = _name;
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator['return']) {
_iterator['return']();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return output;
}

View File

@@ -0,0 +1,8 @@
const bug = 1;
function foo() {}
function bar() {
var bug;
bug = 2;
}

View File

@@ -0,0 +1,10 @@
"use strict";
var bug = 1;
function foo() {}
function bar() {
var bug;
bug = 2;
}

View File

@@ -0,0 +1,8 @@
import last from "lodash/array/last"
export default class Container {
last(key) {
if (!this.has(key)) return
return last(this.tokens.get(key))
}
}

View File

@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _last2 = require("lodash/array/last");
var _last3 = babelHelpers.interopRequireWildcard(_last2);
var Container = (function () {
function Container() {
babelHelpers.classCallCheck(this, Container);
}
babelHelpers.createClass(Container, [{
key: "last",
value: (function (_last) {
function last(_x) {
return _last.apply(this, arguments);
}
last.toString = function () {
return _last.toString();
};
return last;
})(function (key) {
if (!this.has(key)) return;
return _last3["default"](this.tokens.get(key));
})
}]);
return Container;
})();
exports["default"] = Container;
module.exports = exports["default"];

View File

@@ -0,0 +1,7 @@
import {getForm} from "./store"
export default class Login extends React.Component {
getForm() {
return getForm().toJS()
}
}

View File

@@ -0,0 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _getForm2 = require("./store");
var Login = (function (_React$Component) {
function Login() {
babelHelpers.classCallCheck(this, Login);
if (_React$Component != null) {
_React$Component.apply(this, arguments);
}
}
babelHelpers.inherits(Login, _React$Component);
babelHelpers.createClass(Login, [{
key: "getForm",
value: (function (_getForm) {
function getForm() {
return _getForm.apply(this, arguments);
}
getForm.toString = function () {
return _getForm.toString();
};
return getForm;
})(function () {
return _getForm2.getForm().toJS();
})
}]);
return Login;
})(React.Component);
exports["default"] = Login;
module.exports = exports["default"];

View File

@@ -0,0 +1,9 @@
import events from "events";
class Template {
events() {
return events;
}
}
console.log(new Template().events());

View File

@@ -0,0 +1,31 @@
"use strict";
var _events2 = require("events");
var _events3 = babelHelpers.interopRequireWildcard(_events2);
var Template = (function () {
function Template() {
babelHelpers.classCallCheck(this, Template);
}
babelHelpers.createClass(Template, [{
key: "events",
value: (function (_events) {
function events() {
return _events.apply(this, arguments);
}
events.toString = function () {
return _events.toString();
};
return events;
})(function () {
return _events3["default"];
})
}]);
return Template;
})();
console.log(new Template().events());

View File

@@ -0,0 +1,3 @@
{
"externalHelpers": true
}