Compare commits

...

16 Commits

Author SHA1 Message Date
Sebastian McKenzie
6d7887cfe2 v5.0.0-beta3 2015-03-29 01:52:30 +11:00
Sebastian McKenzie
b8e9171aaa start on changelog 2015-03-29 01:50:54 +11:00
Sebastian McKenzie
22118c0be0 add Immutable alias keys 2015-03-29 01:50:45 +11:00
Sebastian McKenzie
3754f7615f make insertBefore functionality the same as insertBefore in traversal path and add getStatementParent method 2015-03-29 01:50:36 +11:00
Sebastian McKenzie
b54901018b Merge pull request #1108 from ArrestedDevelopment/jsxpragma-option
JSX Transformer: Add 'jsxPragma' option
2015-03-28 22:17:18 +11:00
ArrestedDevelopment
121b9ca063 Add tests for JSX Pragma option 2015-03-28 02:20:01 -06:00
ArrestedDevelopment
4988a27b6c JSX Transformer: Add 'jsxPragma' option 2015-03-28 01:41:16 -06:00
Sebastian McKenzie
e0297e08b8 Merge pull request #1103 from joliss/makefile
Disable parallelism in Makefile
2015-03-28 08:39:08 +11:00
Sebastian McKenzie
79005d2f03 Merge pull request #1102 from joliss/npmignore
Prefix all npmignored files with "/"
2015-03-28 08:38:56 +11:00
Sebastian McKenzie
5cce8c32a4 Merge pull request #1101 from joliss/make-clean
Delete lib directory on `make clean`
2015-03-28 08:38:37 +11:00
Sebastian McKenzie
95b1accddc Merge pull request #1104 from joliss/travis
Re-enable experimental branch on Travis
2015-03-28 08:38:26 +11:00
Jo Liss
6149e6325f Re-enable experimental branch on Travis 2015-03-27 21:34:38 +00:00
Jo Liss
4c9d4d0378 Disable parallelism in Makefile
When MAKEFLAGS=-j2 is set in the environment, `make test-travis` can fail
surprisingly, because targets are executed in parallel.
2015-03-27 21:28:07 +00:00
Jo Liss
2e599bef4f Prefix all npmignored files with "/"
This in particular stops lib/acorn/src from being incorrectly matched by "src".
2015-03-27 21:02:28 +00:00
Jo Liss
885da177f9 Delete lib directory on make clean 2015-03-27 20:52:00 +00:00
Sebastian McKenzie
463112517f 5.0.0-beta2 2015-03-28 05:48:27 +11:00
17 changed files with 134 additions and 32 deletions

View File

@@ -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

View File

@@ -4,10 +4,6 @@ node_js:
- "0.12"
- "iojs"
branches:
except:
- experimental
before_script: "npm install -g codeclimate-test-reporter"
script: "make test-travis"

View File

@@ -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**

View File

@@ -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

View File

@@ -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",

View File

@@ -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": {

View File

@@ -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"
},

View File

@@ -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];

View File

@@ -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 = [];

View File

@@ -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"]
}

View File

@@ -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

View File

@@ -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>;

View File

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

View File

@@ -0,0 +1,3 @@
{
"jsxPragma": "foo.bar"
}

View File

@@ -0,0 +1,6 @@
<Foo></Foo>;
var profile = <div>
<img src="avatar.png" className="profile" />
<h3>{[user.firstName, user.lastName].join(" ")}</h3>
</div>;

View File

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

View File

@@ -0,0 +1,3 @@
{
"jsxPragma": "dom"
}