Compare commits

...

14 Commits

Author SHA1 Message Date
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
11 changed files with 87 additions and 21 deletions

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.10",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
"repository": "babel/babel",

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.9",
"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.9",
"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.9",
"repository": "babel/babel",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"dependencies": {

View File

@@ -46,7 +46,7 @@ var remapVisitor = {
}
}
if (t.isAssignmentExpression(node)) {
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

@@ -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;
})();