Compare commits
16 Commits
v5.0.0-bet
...
v5.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d7887cfe2 | ||
|
|
b8e9171aaa | ||
|
|
22118c0be0 | ||
|
|
3754f7615f | ||
|
|
b54901018b | ||
|
|
121b9ca063 | ||
|
|
4988a27b6c | ||
|
|
e0297e08b8 | ||
|
|
79005d2f03 | ||
|
|
5cce8c32a4 | ||
|
|
95b1accddc | ||
|
|
6149e6325f | ||
|
|
4c9d4d0378 | ||
|
|
2e599bef4f | ||
|
|
885da177f9 | ||
|
|
463112517f |
25
.npmignore
25
.npmignore
@@ -1,16 +1,15 @@
|
||||
node_modules
|
||||
*.log
|
||||
*.cache
|
||||
lib/babel/transformation/templates
|
||||
test
|
||||
benchmark
|
||||
Makefile
|
||||
.*
|
||||
dist
|
||||
tests.json
|
||||
CHANGELOG.md
|
||||
.package.json
|
||||
coverage
|
||||
vendor
|
||||
packages
|
||||
src
|
||||
/lib/babel/transformation/templates
|
||||
/test
|
||||
/benchmark
|
||||
/Makefile
|
||||
/dist
|
||||
/tests.json
|
||||
/CHANGELOG.md
|
||||
/.package.json
|
||||
/coverage
|
||||
/vendor
|
||||
/packages
|
||||
/src
|
||||
|
||||
@@ -4,10 +4,6 @@ node_js:
|
||||
- "0.12"
|
||||
- "iojs"
|
||||
|
||||
branches:
|
||||
except:
|
||||
- experimental
|
||||
|
||||
before_script: "npm install -g codeclimate-test-reporter"
|
||||
script: "make test-travis"
|
||||
|
||||
|
||||
10
CHANGELOG.md
10
CHANGELOG.md
@@ -13,6 +13,16 @@ _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.0
|
||||
|
||||
* **New Feature**
|
||||
* Decorators based on [@wycat's](https://github.com/wycats) [stage 1 proposal](https://github.com/wycats/javascript-decorators).
|
||||
* Class property initializers based on [@jeffmo's](https://github.com/jeffmo) [stage 0 proposal](https://gist.github.com/jeffmo/054df782c05639da2adb).
|
||||
* **Internal**
|
||||
* **Breaking Changes**
|
||||
* The Babel playground has been removed.
|
||||
* ES7 Abstract References have been removed.
|
||||
|
||||
## 4.7.16
|
||||
|
||||
* **Bug Fix**
|
||||
|
||||
3
Makefile
3
Makefile
@@ -1,3 +1,4 @@
|
||||
MAKEFLAGS = -j1
|
||||
BROWSERIFY_CMD = node_modules/browserify/bin/cmd.js
|
||||
ISTANBUL_CMD = node_modules/istanbul/lib/cli.js cover
|
||||
UGLIFY_CMD = node_modules/uglify-js/bin/uglifyjs
|
||||
@@ -37,7 +38,7 @@ build:
|
||||
rm -rf templates.json
|
||||
|
||||
clean:
|
||||
rm -rf coverage templates.json test/tmp dist
|
||||
rm -rf coverage templates.json test/tmp dist lib
|
||||
|
||||
test-clean:
|
||||
rm -rf test/tmp
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "babel",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "5.0.0-beta2",
|
||||
"version": "5.0.0-beta3",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
"repository": "babel/babel",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "babel-runtime",
|
||||
"description": "babel selfContained runtime",
|
||||
"version": "5.0.0-beta1",
|
||||
"version": "5.0.0-beta2",
|
||||
"repository": "babel/babel",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"dependencies": {
|
||||
|
||||
@@ -83,6 +83,13 @@
|
||||
"shorthand": "L"
|
||||
},
|
||||
|
||||
"jsxPragma": {
|
||||
"type": "string",
|
||||
"description": "Custom pragma to use with JSX (same functionality as @jsx comments)",
|
||||
"default": "React.createElement",
|
||||
"shorthand": "P"
|
||||
},
|
||||
|
||||
"ignore": {
|
||||
"type": "list"
|
||||
},
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as t from "../../../types";
|
||||
var JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/;
|
||||
|
||||
export function Program(node, parent, scope, file) {
|
||||
var id = "React.createElement";
|
||||
var id = file.opts.jsxPragma;
|
||||
|
||||
for (var i = 0; i < file.ast.comments.length; i++) {
|
||||
var comment = file.ast.comments[i];
|
||||
|
||||
@@ -87,7 +87,16 @@ export default class TraversalPath {
|
||||
insertBefore(nodes) {
|
||||
this.checkNodes(nodes);
|
||||
|
||||
if (this.isPreviousType("Expression")) {
|
||||
if (this.isPreviousType("Statement")) {
|
||||
if (Array.isArray(this.container)) {
|
||||
this._containerInsertBefore(nodes);
|
||||
} else if (this.isStatementOrBlock()) {
|
||||
if (this.node) nodes.push(this.node);
|
||||
this.container[this.key] = t.blockStatement(nodes);
|
||||
} else {
|
||||
throw new Error("no idea what to do with this");
|
||||
}
|
||||
} else if (this.isPreviousType("Expression")) {
|
||||
if (this.node) nodes.push(this.node);
|
||||
this.replaceExpressionWithStatements(nodes);
|
||||
} else {
|
||||
@@ -95,11 +104,12 @@ export default class TraversalPath {
|
||||
}
|
||||
}
|
||||
|
||||
_containerInsertAfter(nodes) {
|
||||
this.updateSiblingKeys(this.key + 1, nodes.length);
|
||||
|
||||
_containerInsert(from, nodes) {
|
||||
this.updateSiblingKeys(from, nodes.length);
|
||||
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
var to = this.key + 1 + i;
|
||||
var to = from + i;
|
||||
this.container.splice(to, 0, nodes[i]);
|
||||
|
||||
if (this.context) {
|
||||
@@ -108,13 +118,26 @@ export default class TraversalPath {
|
||||
}
|
||||
}
|
||||
|
||||
_containerInsertBefore(nodes) {
|
||||
this._containerInsert(this.key, nodes);
|
||||
}
|
||||
|
||||
_containerInsertAfter(nodes) {
|
||||
this._containerInsert(this.key + 1, nodes);
|
||||
}
|
||||
|
||||
isStatementOrBlock() {
|
||||
return includes(t.STATEMENT_OR_BLOCK_KEYS, this.key) && !t.isBlockStatement(this.container);
|
||||
}
|
||||
|
||||
insertAfter(nodes) {
|
||||
this.checkNodes(nodes);
|
||||
|
||||
if (this.isPreviousType("Statement")) {
|
||||
if (Array.isArray(this.container)) {
|
||||
this._containerInsertAfter(nodes);
|
||||
} else if (includes(t.STATEMENT_OR_BLOCK_KEYS, this.key) && !t.isBlockStatement(this.container)) {
|
||||
} else if (this.isStatementOrBlock()) {
|
||||
if (this.node) nodes.unshift(this.node);
|
||||
this.container[this.key] = t.blockStatement(nodes);
|
||||
} else {
|
||||
throw new Error("no idea what to do with this");
|
||||
@@ -293,6 +316,24 @@ export default class TraversalPath {
|
||||
}
|
||||
}
|
||||
|
||||
getStatementParent(): ?TraversalPath {
|
||||
var path = this;
|
||||
|
||||
do {
|
||||
if (!path.parentPath || (Array.isArray(path.container) && path.isStatement())) {
|
||||
break;
|
||||
} else {
|
||||
path = path.parentPath;
|
||||
}
|
||||
} while (path);
|
||||
|
||||
if (path && (path.isProgram() || path.isFile())) {
|
||||
throw new Error("File/Program node, we can't possibly find a statement parent to this");
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
getLastStatements(): Array<TraversalPath> {
|
||||
var paths = [];
|
||||
|
||||
|
||||
@@ -105,14 +105,14 @@
|
||||
"UnionTypeAnnotation": ["Flow"],
|
||||
"VoidTypeAnnotation": ["Flow"],
|
||||
|
||||
"JSXAttribute": ["JSX"],
|
||||
"JSXClosingElement": ["JSX"],
|
||||
"JSXElement": ["JSX", "Expression"],
|
||||
"JSXEmptyExpression": ["JSX"],
|
||||
"JSXExpressionContainer": ["JSX"],
|
||||
"JSXAttribute": ["JSX", "Immutable"],
|
||||
"JSXClosingElement": ["JSX", "Immutable"],
|
||||
"JSXElement": ["JSX", "Immutable", "Expression"],
|
||||
"JSXEmptyExpression": ["JSX", "Immutable"],
|
||||
"JSXExpressionContainer": ["JSX", "Immutable"],
|
||||
"JSXIdentifier": ["JSX"],
|
||||
"JSXMemberExpression": ["JSX"],
|
||||
"JSXNamespacedName": ["JSX"],
|
||||
"JSXOpeningElement": ["JSX"],
|
||||
"JSXOpeningElement": ["JSX", "Immutable"],
|
||||
"JSXSpreadAttribute": ["JSX"]
|
||||
}
|
||||
|
||||
@@ -173,6 +173,8 @@ export function isScope(node: Object, parent: Object): boolean {
|
||||
*/
|
||||
|
||||
export function isImmutable(node: Object): boolean {
|
||||
if (t.isType(node.type, "Immutable")) return true;
|
||||
|
||||
if (t.isLiteral(node)) {
|
||||
if (node.regex) {
|
||||
// regexes are mutable
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/** @jsx dom */
|
||||
|
||||
<Foo></Foo>;
|
||||
|
||||
var profile = <div>
|
||||
<img src="avatar.png" className="profile" />
|
||||
<h3>{[user.firstName, user.lastName].join(" ")}</h3>
|
||||
</div>;
|
||||
@@ -0,0 +1,14 @@
|
||||
/** @jsx dom */
|
||||
|
||||
dom(Foo, null);
|
||||
|
||||
var profile = dom(
|
||||
"div",
|
||||
null,
|
||||
dom("img", { src: "avatar.png", className: "profile" }),
|
||||
dom(
|
||||
"h3",
|
||||
null,
|
||||
[user.firstName, user.lastName].join(" ")
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"jsxPragma": "foo.bar"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<Foo></Foo>;
|
||||
|
||||
var profile = <div>
|
||||
<img src="avatar.png" className="profile" />
|
||||
<h3>{[user.firstName, user.lastName].join(" ")}</h3>
|
||||
</div>;
|
||||
@@ -0,0 +1,12 @@
|
||||
dom(Foo, null);
|
||||
|
||||
var profile = dom(
|
||||
"div",
|
||||
null,
|
||||
dom("img", { src: "avatar.png", className: "profile" }),
|
||||
dom(
|
||||
"h3",
|
||||
null,
|
||||
[user.firstName, user.lastName].join(" ")
|
||||
)
|
||||
);
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"jsxPragma": "dom"
|
||||
}
|
||||
Reference in New Issue
Block a user