From 7745698b94f4729b70992e168ae98e3880a7c27b Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Fri, 21 Aug 2015 22:17:50 +0530 Subject: [PATCH 01/26] Document ensureCallbackArrays method from visitors.js --- packages/babel/src/traversal/visitors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/babel/src/traversal/visitors.js b/packages/babel/src/traversal/visitors.js index 5e60c32976..3545500089 100644 --- a/packages/babel/src/traversal/visitors.js +++ b/packages/babel/src/traversal/visitors.js @@ -165,7 +165,7 @@ function ensureEntranceObjects(obj) { } /** - * [Please add a description.] + * Makes sure that enter and exit callbacks are arrays. */ function ensureCallbackArrays(obj){ From 05be0678a7866abef561cdde3f054e899b961876 Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Sat, 22 Aug 2015 10:06:30 +0530 Subject: [PATCH 02/26] Document some methods from path/context.js --- packages/babel/src/traversal/path/context.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/babel/src/traversal/path/context.js b/packages/babel/src/traversal/path/context.js index 66af435037..151b6c7e3c 100644 --- a/packages/babel/src/traversal/path/context.js +++ b/packages/babel/src/traversal/path/context.js @@ -48,7 +48,8 @@ export function isBlacklisted(): boolean { } /** - * [Please add a description.] + * Visits a node and calls appropriate enter and exit callbacks + * as required. */ export function visit(): boolean { @@ -81,7 +82,7 @@ export function visit(): boolean { } /** - * [Please add a description.] + * Sets shouldSkip flag true so that this node will be skipped while visiting. */ export function skip() { @@ -89,7 +90,7 @@ export function skip() { } /** - * [Please add a description.] + * Adds given key to the list of keys to be skipped. */ export function skipKey(key) { From 5bb42ed10d2dd3309862bc37f3c00491b2b00069 Mon Sep 17 00:00:00 2001 From: Henry Zhu Date: Tue, 1 Sep 2015 10:14:38 -0400 Subject: [PATCH 03/26] evaluation: add more binary operators --- packages/babel/src/traversal/path/evaluation.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/babel/src/traversal/path/evaluation.js b/packages/babel/src/traversal/path/evaluation.js index 36c6f159f6..f4c1828c9d 100644 --- a/packages/babel/src/traversal/path/evaluation.js +++ b/packages/babel/src/traversal/path/evaluation.js @@ -162,6 +162,14 @@ export function evaluate(): { confident: boolean; value: any } { case "!=": return left != right; case "===": return left === right; case "!==": return left !== right; + case "|": return left | right; + case "&": return left & right; + case "^": return left ^ right; + case "<<": return left << right; + case ">>": return left >> right; + case ">>>": return left >>> right; + case "in": return left in right; + case "instanceof": return left instanceof right; } } From ab1dd2c0907a369fad2cc46d08b3db2cd6ace266 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Tue, 1 Sep 2015 16:28:29 +0200 Subject: [PATCH 04/26] Fix typo in code --- packages/babel/src/transformation/plugin.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/babel/src/transformation/plugin.js b/packages/babel/src/transformation/plugin.js index 0b0182848c..c61222ca43 100644 --- a/packages/babel/src/transformation/plugin.js +++ b/packages/babel/src/transformation/plugin.js @@ -12,7 +12,7 @@ const VALID_PLUGIN_PROPERTIES = [ "post", "pre" ]; -const VALID_METADATA_PROPERTES = [ +const VALID_METADATA_PROPERTIES = [ "dependencies", "optional", "stage", @@ -70,7 +70,7 @@ export default class Plugin { } for (let key in plugin.metadata) { - if (VALID_METADATA_PROPERTES.indexOf(key) >= 0) continue; + if (VALID_METADATA_PROPERTIES.indexOf(key) >= 0) continue; throw new Error(messages.get("pluginInvalidProperty", name, `metadata.${key}`)); } From 5c58b52d40eb9aef0056a586505fbff51984682d Mon Sep 17 00:00:00 2001 From: Henry Zhu Date: Tue, 1 Sep 2015 23:29:04 -0400 Subject: [PATCH 05/26] evaluation: evaluate typeof UnaryExpression --- packages/babel/src/traversal/path/evaluation.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/babel/src/traversal/path/evaluation.js b/packages/babel/src/traversal/path/evaluation.js index f4c1828c9d..a27e4e24e5 100644 --- a/packages/babel/src/traversal/path/evaluation.js +++ b/packages/babel/src/traversal/path/evaluation.js @@ -119,13 +119,20 @@ export function evaluate(): { confident: boolean; value: any } { } if (path.isUnaryExpression({ prefix: true })) { - var arg = evaluate(path.get("argument")); + var argument = path.get("argument"); + var arg = evaluate(argument); switch (node.operator) { case "void": return undefined; case "!": return !arg; case "+": return +arg; case "-": return -arg; case "~": return ~arg; + case "typeof": + if (argument.isFunction()) { + return "function"; + } else { + return typeof arg; + } } } From a6e0ec83716685882af4328e5f622523d3df237f Mon Sep 17 00:00:00 2001 From: Andrew Imm Date: Mon, 31 Aug 2015 17:38:38 -0700 Subject: [PATCH 06/26] Allow more certainty when evaluating Logical Expressions --- .../babel/src/traversal/path/evaluation.js | 20 ++- packages/babel/test/evaluation.js | 164 ++++++++++++++++++ 2 files changed, 182 insertions(+), 2 deletions(-) create mode 100644 packages/babel/test/evaluation.js diff --git a/packages/babel/src/traversal/path/evaluation.js b/packages/babel/src/traversal/path/evaluation.js index 36c6f159f6..50ab6ce623 100644 --- a/packages/babel/src/traversal/path/evaluation.js +++ b/packages/babel/src/traversal/path/evaluation.js @@ -134,12 +134,28 @@ export function evaluate(): { confident: boolean; value: any } { } if (path.isLogicalExpression()) { + // If we are confident that one side of an && is false, or one side of + // an || is true, we can be confident about the entire expression + let wasConfident = confident; let left = evaluate(path.get("left")); + let leftConfident = confident; + confident = wasConfident; let right = evaluate(path.get("right")); + let rightConfident = confident; + let uncertain = leftConfident !== rightConfident; + confident = leftConfident && rightConfident; switch (node.operator) { - case "||": return left || right; - case "&&": return left && right; + case "||": + if ((left || right) && uncertain) { + confident = true; + } + return left || right; + case "&&": + if ((!left && leftConfident) || (!right && rightConfident)) { + confident = true; + } + return left && right; } } diff --git a/packages/babel/test/evaluation.js b/packages/babel/test/evaluation.js new file mode 100644 index 0000000000..632691bb0d --- /dev/null +++ b/packages/babel/test/evaluation.js @@ -0,0 +1,164 @@ +var evaluation = require("../lib/traversal/path/evaluation"); +var traverse = require('../lib/traversal'); +var parse = require("../lib/helpers/parse"); +var assert = require("assert"); + +suite("evaluation", function () { + test("binary expression", function () { + traverse(parse("5 + 5"), { + enter: function (node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: 10 }); + } + } + }); + + traverse(parse("'str' === 'str'"), { + enter: function(node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: true }); + } + } + }); + + traverse(parse("'four' === 4"), { + enter: function(node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: false }); + } + } + }); + }); + + test("logical expression", function () { + traverse(parse("'abc' === 'abc' && 1 === 1"), { + enter: function(node) { + if (this.isLogicalExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: true }); + } + } + }); + + traverse(parse("'abc' === 'abc' && 1 === 10"), { + enter: function(node) { + if (this.isLogicalExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: false }); + } + } + }); + + traverse(parse("'abc' === 'xyz' && 1 === 1"), { + enter: function(node) { + if (this.isLogicalExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: false }); + } + } + }); + + traverse(parse("'abc' === 'xyz' && 1 === 10"), { + enter: function(node) { + if (this.isLogicalExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: false }); + } + } + }); + + traverse(parse("'abc' === 'abc' || 1 === 1"), { + enter: function(node) { + if (this.isLogicalExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: true }); + } + } + }); + + traverse(parse("'abc' === 'abc' || 1 === 10"), { + enter: function(node) { + if (this.isLogicalExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: true }); + } + } + }); + + traverse(parse("'abc' === 'xyz' || 1 === 1"), { + enter: function(node) { + if (this.isLogicalExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: true }); + } + } + }); + + traverse(parse("'abc' === 'xyz' || 1 === 10"), { + enter: function(node) { + if (this.isLogicalExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: false }); + } + } + }); + }); + + test("logical expression without certainty", function () { + traverse(parse("'abc' === 'abc' || config.flag === 1"), { + enter: function(node) { + if (this.isLogicalExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: true }); + } + } + }); + + traverse(parse("obj.a === 'abc' || config.flag === 1"), { + enter: function(node) { + if (this.isLogicalExpression()) { + assert.deepEqual(this.evaluate(), { confident: false, value: undefined }); + } + } + }); + + traverse(parse("'abc' !== 'abc' && config.flag === 1"), { + enter: function(node) { + if (this.isLogicalExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: false }); + } + } + }); + + traverse(parse("obj.a === 'abc' && 1 === 1"), { + enter: function(node) { + if (this.isLogicalExpression()) { + assert.deepEqual(this.evaluate(), { confident: false, value: undefined }); + } + } + }); + + traverse(parse("'abc' === 'abc' && (1 === 1 || config.flag)"), { + enter: function(node) { + if (this.isLogicalExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: true }); + } + } + }); + + traverse(parse("'abc' === 'xyz' || (1 === 1 && config.flag)"), { + enter: function(node) { + if (this.isLogicalExpression()) { + assert.deepEqual(this.evaluate(), { confident: false, value: undefined }); + } + } + }); + + traverse(parse("'abc' === 'xyz' || (1 === 1 && 'four' === 'four')"), { + enter: function(node) { + if (this.isLogicalExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: true }); + } + } + }); + + traverse(parse("'abc' === 'abc' && (1 === 1 && 'four' === 'four')"), { + enter: function(node) { + if (this.isLogicalExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: true }); + } + } + }); + }); +}); From 1d0e68f5a19d721fe8799b1ea331041d8bf9120e Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Wed, 9 Sep 2015 23:53:17 -0700 Subject: [PATCH 07/26] Include $$typeof on inlined React elements See https://github.com/facebook/react/pull/4832. --- packages/babel/src/transformation/file/index.js | 1 + .../transformation/templates/helper-typeof-react-element.js | 1 + .../transformers/optimisation/react.inline-elements.js | 1 + .../inline-elements/expected.js | 6 +++++- .../component-with-props/expected.js | 3 ++- .../component/expected.js | 3 ++- .../html-element-with-props/expected.js | 3 ++- .../html-element/expected.js | 3 ++- .../optimisation.react.inline-elements/key/expected.js | 1 + .../nested-components/expected.js | 4 +++- .../nested-html-elements/expected.js | 3 ++- .../optimisation.react.inline-elements/nested/expected.js | 4 +++- .../self-closing-component-with-props/expected.js | 1 + .../self-closing-component/expected.js | 1 + .../self-closing-html-element-with-props/expected.js | 1 + .../self-closing-html-element/expected.js | 1 + .../shorthand-attributes/expected.js | 3 ++- 17 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 packages/babel/src/transformation/templates/helper-typeof-react-element.js diff --git a/packages/babel/src/transformation/file/index.js b/packages/babel/src/transformation/file/index.js index e16aacb978..aefe11e40b 100644 --- a/packages/babel/src/transformation/file/index.js +++ b/packages/babel/src/transformation/file/index.js @@ -92,6 +92,7 @@ export default class File { "temporal-undefined", "temporal-assert-defined", "self-global", + "typeof-react-element", "default-props", "instanceof", diff --git a/packages/babel/src/transformation/templates/helper-typeof-react-element.js b/packages/babel/src/transformation/templates/helper-typeof-react-element.js new file mode 100644 index 0000000000..144051982f --- /dev/null +++ b/packages/babel/src/transformation/templates/helper-typeof-react-element.js @@ -0,0 +1 @@ +(typeof Symbol === "function" && Symbol.for && Symbol.for("react.element")) || 0xeac7 diff --git a/packages/babel/src/transformation/transformers/optimisation/react.inline-elements.js b/packages/babel/src/transformation/transformers/optimisation/react.inline-elements.js index 8c7c182ed4..5e3554262c 100644 --- a/packages/babel/src/transformation/transformers/optimisation/react.inline-elements.js +++ b/packages/babel/src/transformation/transformers/optimisation/react.inline-elements.js @@ -61,6 +61,7 @@ export var visitor = { } // metadata + pushElemProp("$$typeof", file.addHelper("typeof-react-element")); pushElemProp("type", type); pushElemProp("ref", t.literal(null)); diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.constant-elements/inline-elements/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.constant-elements/inline-elements/expected.js index 338bdb7ee9..eaa34b3340 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.constant-elements/inline-elements/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.constant-elements/inline-elements/expected.js @@ -1,6 +1,9 @@ "use strict"; +var _typeofReactElement = typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element") || 60103; + var _ref = { + $$typeof: _typeofReactElement, type: "foo", ref: null, props: {}, @@ -13,6 +16,7 @@ function render() { function render() { var text = getText(); var _ref2 = { + $$typeof: _typeofReactElement, type: "foo", ref: null, props: { @@ -23,4 +27,4 @@ function render() { return function () { return _ref2; }; -} +} \ No newline at end of file diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/component-with-props/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/component-with-props/expected.js index f12d308ad4..83e97ffb7c 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/component-with-props/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/component-with-props/expected.js @@ -1,10 +1,11 @@ "use strict"; ({ + $$typeof: babelHelpers.typeofReactElement, type: Baz, ref: null, props: babelHelpers.defaultProps(Baz.defaultProps, { foo: "bar" }), key: null -}); +}); \ No newline at end of file diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/component/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/component/expected.js index ce0544da35..78504409d1 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/component/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/component/expected.js @@ -1,8 +1,9 @@ "use strict"; ({ + $$typeof: babelHelpers.typeofReactElement, type: Baz, ref: null, props: babelHelpers.defaultProps(Baz.defaultProps, {}), key: null -}); +}); \ No newline at end of file diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/html-element-with-props/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/html-element-with-props/expected.js index dfddc6e5be..093fab0776 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/html-element-with-props/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/html-element-with-props/expected.js @@ -1,10 +1,11 @@ "use strict"; ({ + $$typeof: babelHelpers.typeofReactElement, type: "foo", ref: null, props: { bar: "foo" }, key: null -}); +}); \ No newline at end of file diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/html-element/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/html-element/expected.js index bd6cead480..4b16b457e3 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/html-element/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/html-element/expected.js @@ -1,8 +1,9 @@ "use strict"; ({ + $$typeof: babelHelpers.typeofReactElement, type: "foo", ref: null, props: {}, key: null -}); +}); \ No newline at end of file diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/key/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/key/expected.js index f3ceb79ca1..3834cf1d12 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/key/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/key/expected.js @@ -1,6 +1,7 @@ "use strict"; ({ + $$typeof: babelHelpers.typeofReactElement, type: Foo, ref: null, props: babelHelpers.defaultProps(Foo.defaultProps, {}), diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested-components/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested-components/expected.js index cdb8f0053a..d61f6f2de3 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested-components/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested-components/expected.js @@ -1,10 +1,12 @@ "use strict"; ({ + $$typeof: babelHelpers.typeofReactElement, type: Foo, ref: null, props: babelHelpers.defaultProps(Foo.defaultProps, { children: [bar, { + $$typeof: babelHelpers.typeofReactElement, type: Baz, ref: null, props: babelHelpers.defaultProps(Baz.defaultProps, {}), @@ -13,4 +15,4 @@ className: "foo" }), key: null -}); +}); \ No newline at end of file diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested-html-elements/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested-html-elements/expected.js index 90b1ad9b93..f9518ba2b7 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested-html-elements/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested-html-elements/expected.js @@ -1,6 +1,7 @@ "use strict"; ({ + $$typeof: babelHelpers.typeofReactElement, type: "div", ref: null, props: { @@ -8,4 +9,4 @@ className: "foo" }, key: null -}); +}); \ No newline at end of file diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested/expected.js index 6d9b9a1f1c..1f152abd02 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested/expected.js @@ -1,10 +1,12 @@ "use strict"; ({ + $$typeof: babelHelpers.typeofReactElement, type: "div", ref: null, props: { children: [bar, { + $$typeof: babelHelpers.typeofReactElement, type: Baz, ref: null, props: babelHelpers.defaultProps(Baz.defaultProps, {}), @@ -13,4 +15,4 @@ className: "foo" }, key: null -}); +}); \ No newline at end of file diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-component-with-props/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-component-with-props/expected.js index 05d9b4afde..83e97ffb7c 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-component-with-props/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-component-with-props/expected.js @@ -1,6 +1,7 @@ "use strict"; ({ + $$typeof: babelHelpers.typeofReactElement, type: Baz, ref: null, props: babelHelpers.defaultProps(Baz.defaultProps, { diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-component/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-component/expected.js index eebbcef988..78504409d1 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-component/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-component/expected.js @@ -1,6 +1,7 @@ "use strict"; ({ + $$typeof: babelHelpers.typeofReactElement, type: Baz, ref: null, props: babelHelpers.defaultProps(Baz.defaultProps, {}), diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-html-element-with-props/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-html-element-with-props/expected.js index 6e5aec9eec..093fab0776 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-html-element-with-props/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-html-element-with-props/expected.js @@ -1,6 +1,7 @@ "use strict"; ({ + $$typeof: babelHelpers.typeofReactElement, type: "foo", ref: null, props: { diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-html-element/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-html-element/expected.js index 87d6fdbd33..4b16b457e3 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-html-element/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-html-element/expected.js @@ -1,6 +1,7 @@ "use strict"; ({ + $$typeof: babelHelpers.typeofReactElement, type: "foo", ref: null, props: {}, diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/shorthand-attributes/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/shorthand-attributes/expected.js index 452322c2de..0239a2fe42 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/shorthand-attributes/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/shorthand-attributes/expected.js @@ -1,10 +1,11 @@ "use strict"; ({ + $$typeof: babelHelpers.typeofReactElement, type: Foo, ref: null, props: babelHelpers.defaultProps(Foo.defaultProps, { bar: true }), key: null -}); +}); \ No newline at end of file From 52fb99a341e1da96c4754caef66bab53036dfeef Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Thu, 10 Sep 2015 01:22:06 -0700 Subject: [PATCH 08/26] Reorder React element properties for consistent hidden class --- .../optimisation/react.inline-elements.js | 15 +++++++-------- .../inline-elements/expected.js | 6 ++++-- .../component-with-props/expected.js | 3 ++- .../component/expected.js | 3 ++- .../html-element-with-props/expected.js | 3 ++- .../html-element/expected.js | 3 ++- .../key/expected.js | 3 ++- .../nested-components/expected.js | 6 ++++-- .../nested-html-elements/expected.js | 3 ++- .../nested/expected.js | 6 ++++-- .../self-closing-component-with-props/expected.js | 3 ++- .../self-closing-component/expected.js | 3 ++- .../expected.js | 3 ++- .../self-closing-html-element/expected.js | 3 ++- .../shorthand-attributes/expected.js | 3 ++- 15 files changed, 41 insertions(+), 25 deletions(-) diff --git a/packages/babel/src/transformation/transformers/optimisation/react.inline-elements.js b/packages/babel/src/transformation/transformers/optimisation/react.inline-elements.js index 5e3554262c..5d43d59cf1 100644 --- a/packages/babel/src/transformation/transformers/optimisation/react.inline-elements.js +++ b/packages/babel/src/transformation/transformers/optimisation/react.inline-elements.js @@ -60,11 +60,6 @@ export var visitor = { objProps.push(t.property("init", key, value)); } - // metadata - pushElemProp("$$typeof", file.addHelper("typeof-react-element")); - pushElemProp("type", type); - pushElemProp("ref", t.literal(null)); - if (node.children.length) { var children = react.buildChildren(node); children = children.length === 1 ? children[0] : t.arrayExpression(children); @@ -85,10 +80,14 @@ export var visitor = { props = t.callExpression(file.addHelper("default-props"), [t.memberExpression(type, t.identifier("defaultProps")), props]); } - pushElemProp("props", props); - - // key + // metadata + pushElemProp("$$typeof", file.addHelper("typeof-react-element")); + pushElemProp("type", type); pushElemProp("key", key); + pushElemProp("ref", t.literal(null)); + + pushElemProp("props", props); + pushElemProp("_owner", t.literal(null)); return obj; } diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.constant-elements/inline-elements/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.constant-elements/inline-elements/expected.js index eaa34b3340..486db2f496 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.constant-elements/inline-elements/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.constant-elements/inline-elements/expected.js @@ -5,9 +5,10 @@ var _typeofReactElement = typeof Symbol === "function" && Symbol["for"] && Symbo var _ref = { $$typeof: _typeofReactElement, type: "foo", + key: null, ref: null, props: {}, - key: null + _owner: null }; function render() { return _ref; @@ -18,11 +19,12 @@ function render() { var _ref2 = { $$typeof: _typeofReactElement, type: "foo", + key: null, ref: null, props: { children: text }, - key: null + _owner: null }; return function () { return _ref2; diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/component-with-props/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/component-with-props/expected.js index 83e97ffb7c..53d45c8c49 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/component-with-props/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/component-with-props/expected.js @@ -3,9 +3,10 @@ ({ $$typeof: babelHelpers.typeofReactElement, type: Baz, + key: null, ref: null, props: babelHelpers.defaultProps(Baz.defaultProps, { foo: "bar" }), - key: null + _owner: null }); \ No newline at end of file diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/component/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/component/expected.js index 78504409d1..0f7be9b542 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/component/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/component/expected.js @@ -3,7 +3,8 @@ ({ $$typeof: babelHelpers.typeofReactElement, type: Baz, + key: null, ref: null, props: babelHelpers.defaultProps(Baz.defaultProps, {}), - key: null + _owner: null }); \ No newline at end of file diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/html-element-with-props/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/html-element-with-props/expected.js index 093fab0776..adac374b6f 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/html-element-with-props/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/html-element-with-props/expected.js @@ -3,9 +3,10 @@ ({ $$typeof: babelHelpers.typeofReactElement, type: "foo", + key: null, ref: null, props: { bar: "foo" }, - key: null + _owner: null }); \ No newline at end of file diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/html-element/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/html-element/expected.js index 4b16b457e3..88fb7293c7 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/html-element/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/html-element/expected.js @@ -3,7 +3,8 @@ ({ $$typeof: babelHelpers.typeofReactElement, type: "foo", + key: null, ref: null, props: {}, - key: null + _owner: null }); \ No newline at end of file diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/key/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/key/expected.js index 3834cf1d12..d103b14c73 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/key/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/key/expected.js @@ -3,7 +3,8 @@ ({ $$typeof: babelHelpers.typeofReactElement, type: Foo, + key: "foo", ref: null, props: babelHelpers.defaultProps(Foo.defaultProps, {}), - key: "foo" + _owner: null }); \ No newline at end of file diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested-components/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested-components/expected.js index d61f6f2de3..ca5c4af20b 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested-components/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested-components/expected.js @@ -3,16 +3,18 @@ ({ $$typeof: babelHelpers.typeofReactElement, type: Foo, + key: null, ref: null, props: babelHelpers.defaultProps(Foo.defaultProps, { children: [bar, { $$typeof: babelHelpers.typeofReactElement, type: Baz, + key: "baz", ref: null, props: babelHelpers.defaultProps(Baz.defaultProps, {}), - key: "baz" + _owner: null }], className: "foo" }), - key: null + _owner: null }); \ No newline at end of file diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested-html-elements/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested-html-elements/expected.js index f9518ba2b7..7c59ecd0ba 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested-html-elements/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested-html-elements/expected.js @@ -3,10 +3,11 @@ ({ $$typeof: babelHelpers.typeofReactElement, type: "div", + key: null, ref: null, props: { children: bar, className: "foo" }, - key: null + _owner: null }); \ No newline at end of file diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested/expected.js index 1f152abd02..d4cf94ca81 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/nested/expected.js @@ -3,16 +3,18 @@ ({ $$typeof: babelHelpers.typeofReactElement, type: "div", + key: null, ref: null, props: { children: [bar, { $$typeof: babelHelpers.typeofReactElement, type: Baz, + key: "baz", ref: null, props: babelHelpers.defaultProps(Baz.defaultProps, {}), - key: "baz" + _owner: null }], className: "foo" }, - key: null + _owner: null }); \ No newline at end of file diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-component-with-props/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-component-with-props/expected.js index 83e97ffb7c..53d45c8c49 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-component-with-props/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-component-with-props/expected.js @@ -3,9 +3,10 @@ ({ $$typeof: babelHelpers.typeofReactElement, type: Baz, + key: null, ref: null, props: babelHelpers.defaultProps(Baz.defaultProps, { foo: "bar" }), - key: null + _owner: null }); \ No newline at end of file diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-component/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-component/expected.js index 78504409d1..0f7be9b542 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-component/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-component/expected.js @@ -3,7 +3,8 @@ ({ $$typeof: babelHelpers.typeofReactElement, type: Baz, + key: null, ref: null, props: babelHelpers.defaultProps(Baz.defaultProps, {}), - key: null + _owner: null }); \ No newline at end of file diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-html-element-with-props/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-html-element-with-props/expected.js index 093fab0776..adac374b6f 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-html-element-with-props/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-html-element-with-props/expected.js @@ -3,9 +3,10 @@ ({ $$typeof: babelHelpers.typeofReactElement, type: "foo", + key: null, ref: null, props: { bar: "foo" }, - key: null + _owner: null }); \ No newline at end of file diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-html-element/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-html-element/expected.js index 4b16b457e3..88fb7293c7 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-html-element/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/self-closing-html-element/expected.js @@ -3,7 +3,8 @@ ({ $$typeof: babelHelpers.typeofReactElement, type: "foo", + key: null, ref: null, props: {}, - key: null + _owner: null }); \ No newline at end of file diff --git a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/shorthand-attributes/expected.js b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/shorthand-attributes/expected.js index 0239a2fe42..0aed56de13 100644 --- a/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/shorthand-attributes/expected.js +++ b/packages/babel/test/fixtures/transformation/optimisation.react.inline-elements/shorthand-attributes/expected.js @@ -3,9 +3,10 @@ ({ $$typeof: babelHelpers.typeofReactElement, type: Foo, + key: null, ref: null, props: babelHelpers.defaultProps(Foo.defaultProps, { bar: true }), - key: null + _owner: null }); \ No newline at end of file From 8d422bb69c1a00c0ccffc051ef7cac74185f2f3b Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Thu, 10 Sep 2015 20:13:20 +0100 Subject: [PATCH 09/26] v5.8.24 --- VERSION | 2 +- packages/babel/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index aaeac54d59..cbfa2cc121 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.8.23 \ No newline at end of file +5.8.24 \ No newline at end of file diff --git a/packages/babel/package.json b/packages/babel/package.json index 6999cd2b77..516cd9e9db 100644 --- a/packages/babel/package.json +++ b/packages/babel/package.json @@ -1,6 +1,6 @@ { "name": "babel-core", - "version": "5.8.23", + "version": "5.8.24", "description": "A compiler for writing next generation JavaScript", "author": "Sebastian McKenzie ", "homepage": "https://babeljs.io/", From 554fda00c179eea72121cafe4b90fac85c1bb244 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Thu, 10 Sep 2015 20:18:02 +0100 Subject: [PATCH 10/26] add 5.8.23-24 changelog --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33452f9e98..fc66a9271a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,18 @@ _Note: Gaps between patch versions are faulty, broken or test releases._ See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog. +## 5.8.24 + + * **Spec Compliancy** + * Updated `optimisation.react.inlineElements` transformer to React 0.14 output. Thanks [@spicyj](https://github.com/spicyj)! + * **Polish** + * Add support for evaluating more static nodes. Thanks [@hzoo](https://github.com/hzoo)! + +## 5.8.23 + + * **Bug Fix** + * Fix a bug where pushed scope bindings weren't properly being registered. + ## 5.8.22 * **Bug Fix** From 95e63fd9c9d3fea600a88e60485db29d34859d78 Mon Sep 17 00:00:00 2001 From: Henry Zhu Date: Fri, 11 Sep 2015 00:40:51 -0400 Subject: [PATCH 11/26] evaluation: don't evaluate `in` and `instanceof` binary exp - fixes #2355 --- packages/babel/src/traversal/path/evaluation.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/babel/src/traversal/path/evaluation.js b/packages/babel/src/traversal/path/evaluation.js index a27e4e24e5..6349dfa3b8 100644 --- a/packages/babel/src/traversal/path/evaluation.js +++ b/packages/babel/src/traversal/path/evaluation.js @@ -175,8 +175,6 @@ export function evaluate(): { confident: boolean; value: any } { case "<<": return left << right; case ">>": return left >> right; case ">>>": return left >>> right; - case "in": return left in right; - case "instanceof": return left instanceof right; } } From f74280697843399950c8cc67a930133841bd982c Mon Sep 17 00:00:00 2001 From: Henry Zhu Date: Sat, 12 Sep 2015 20:11:33 -0400 Subject: [PATCH 12/26] evaluation: tests for UnaryExpression and BinaryExpression --- packages/babel/test/evaluation.js | 254 +++++++++++++++++++++++++++++- 1 file changed, 251 insertions(+), 3 deletions(-) diff --git a/packages/babel/test/evaluation.js b/packages/babel/test/evaluation.js index 632691bb0d..999373933d 100644 --- a/packages/babel/test/evaluation.js +++ b/packages/babel/test/evaluation.js @@ -4,7 +4,67 @@ var parse = require("../lib/helpers/parse"); var assert = require("assert"); suite("evaluation", function () { - test("binary expression", function () { + test("UnaryExpression: void a", function () { + traverse(parse("void 0"), { + enter: function (node) { + if (this.isUnaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: undefined }); + } + } + }); + }); + + test("UnaryExpression: !a", function () { + traverse(parse("!true"), { + enter: function (node) { + if (this.isUnaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: false }); + } + } + }); + }); + + test("UnaryExpression +a", function () { + traverse(parse("+'2'"), { + enter: function (node) { + if (this.isUnaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: 2 }); + } + } + }); + }); + + test("UnaryExpression -a", function () { + traverse(parse("-'2'"), { + enter: function (node) { + if (this.isUnaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: -2 }); + } + } + }); + }); + + test("UnaryExpression: ~a", function () { + traverse(parse("~1"), { + enter: function (node) { + if (this.isUnaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: -2 }); + } + } + }); + }); + + test("BinaryExpression: a - b", function () { + traverse(parse("3 - 1"), { + enter: function (node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: 2 }); + } + } + }); + }); + + test("BinaryExpression: a + b", function () { traverse(parse("5 + 5"), { enter: function (node) { if (this.isBinaryExpression()) { @@ -12,7 +72,109 @@ suite("evaluation", function () { } } }); + }); + test("BinaryExpression: a / b", function () { + traverse(parse("10 / 2"), { + enter: function (node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: 5 }); + } + } + }); + }); + + test("BinaryExpression: a * b", function () { + traverse(parse("2 * 3"), { + enter: function (node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: 6 }); + } + } + }); + }); + + test("BinaryExpression: a % b", function () { + traverse(parse("4 % 2"), { + enter: function (node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: 0 }); + } + } + }); + }); + + test("BinaryExpression: a ** b", function () { + traverse(parse("2 ** 3", { features: { "es7.exponentiationOperator": true } }), { + enter: function (node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: 8 }); + } + } + }); + }); + + test("BinaryExpression: a < b", function () { + traverse(parse("1 < 2"), { + enter: function (node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: true }); + } + } + }); + }); + + test("BinaryExpression: a > b", function () { + traverse(parse("1 > 2"), { + enter: function (node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: false }); + } + } + }); + }); + + test("BinaryExpression: a <= b", function () { + traverse(parse("1 <= 2"), { + enter: function (node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: true }); + } + } + }); + }); + + test("BinaryExpression: a >= b", function () { + traverse(parse("1 >= 2"), { + enter: function (node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: false }); + } + } + }); + }); + + test("BinaryExpression: a == b", function () { + traverse(parse("1 == '1'"), { + enter: function (node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: true }); + } + } + }); + }); + + test("BinaryExpression: a != b", function () { + traverse(parse("1 != 2"), { + enter: function (node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: true }); + } + } + }); + }); + + test("BinaryExpression: a === b", function () { traverse(parse("'str' === 'str'"), { enter: function(node) { if (this.isBinaryExpression()) { @@ -20,7 +182,6 @@ suite("evaluation", function () { } } }); - traverse(parse("'four' === 4"), { enter: function(node) { if (this.isBinaryExpression()) { @@ -30,7 +191,94 @@ suite("evaluation", function () { }); }); - test("logical expression", function () { + test("BinaryExpression: a !== b", function () { + traverse(parse("'four' !== '4'"), { + enter: function(node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: true }); + } + } + }); + traverse(parse("'str' !== 'str'"), { + enter: function(node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: false }); + } + } + }); + }); + + test("BinaryExpression: a | b", function () { + traverse(parse("1 | 0"), { + enter: function(node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: 1 }); + } + } + }); + }); + + test("BinaryExpression: a & b", function () { + traverse(parse("1 & 1"), { + enter: function (node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: 1 }); + } + } + }); + }); + + test("BinaryExpression: a ^ b", function () { + traverse(parse("1 ^ 0"), { + enter: function (node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: 1 }); + } + } + }); + }); + + test("BinaryExpression: a << b", function () { + traverse(parse("1 << 2"), { + enter: function (node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: 4 }); + } + } + }); + }); + + test("BinaryExpression: a >> b", function () { + traverse(parse("1 >> 2"), { + enter: function (node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: true, value: 0 }); + } + } + }); + }); + + test("BinaryExpression: a in b (not evaluated)", function () { + traverse(parse("1 in [1]"), { + enter: function (node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: false, value: undefined }); + } + } + }); + }); + + test("BinaryExpression: a instanceof b (not evaluated)", function () { + traverse(parse("A instanceof B"), { + enter: function (node) { + if (this.isBinaryExpression()) { + assert.deepEqual(this.evaluate(), { confident: false, value: undefined }); + } + } + }); + }); + + test("LogicalExpression", function () { traverse(parse("'abc' === 'abc' && 1 === 1"), { enter: function(node) { if (this.isLogicalExpression()) { From 9780858722de2e6576853437430a19c015d32115 Mon Sep 17 00:00:00 2001 From: Braden Anderson Date: Mon, 14 Sep 2015 17:25:23 +0700 Subject: [PATCH 13/26] RHS of AssignmentPattern can be a reference to a bound variable --- packages/babel/src/types/validators.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/babel/src/types/validators.js b/packages/babel/src/types/validators.js index 23fed2f132..01f59a6de4 100644 --- a/packages/babel/src/types/validators.js +++ b/packages/babel/src/types/validators.js @@ -119,9 +119,9 @@ export function isReferenced(node: Object, parent: Object): boolean { return parent.right === node; // no: [NODE = foo] = []; - // no: [foo = NODE] = []; + // yes: [foo = NODE] = []; case "AssignmentPattern": - return false; + return parent.right === node; // no: [NODE] = []; // no: ({ NODE }) = []; From b2021277b309e37e0d39a27abd0a923f785f88b6 Mon Sep 17 00:00:00 2001 From: Julien CROUZET Date: Mon, 14 Sep 2015 16:08:49 +0200 Subject: [PATCH 14/26] Test build on Node4.0 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index faa6c0e55d..be2b7d5c0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ cache: - node_modules node_js: + - "4.0" - iojs # - "0.10" - "0.12" From c28007c0447609145fb7407dbe2642356ab3afec Mon Sep 17 00:00:00 2001 From: Steven Luscher Date: Wed, 16 Sep 2015 17:17:11 -0700 Subject: [PATCH 15/26] =?UTF-8?q?Rename=20the=20define=20method=20to=20def?= =?UTF-8?q?ineType=20to=20disambiguate=20from=20AMD's=20=E2=80=9Cdefine?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/babel/src/types/definitions/core.js | 86 +++++++++---------- .../babel/src/types/definitions/es2015.js | 54 ++++++------ .../src/types/definitions/experimental.js | 16 ++-- packages/babel/src/types/definitions/flow.js | 74 ++++++++-------- packages/babel/src/types/definitions/index.js | 2 +- packages/babel/src/types/definitions/jsx.js | 22 ++--- packages/babel/src/types/definitions/misc.js | 6 +- 7 files changed, 130 insertions(+), 130 deletions(-) diff --git a/packages/babel/src/types/definitions/core.js b/packages/babel/src/types/definitions/core.js index 512f791073..622f062ce1 100644 --- a/packages/babel/src/types/definitions/core.js +++ b/packages/babel/src/types/definitions/core.js @@ -1,86 +1,86 @@ -import define from "./index"; +import defineType from "./index"; -define("ArrayExpression", { +defineType("ArrayExpression", { visitor: ["elements"], aliases: ["Expression"] }); -define("AssignmentExpression", { + defineType("AssignmentExpression", { builder: ["operator", "left", "right"], visitor: ["left", "right"], aliases: ["Expression"] }); -define("BinaryExpression", { +defineType("BinaryExpression", { builder: ["operator", "left", "right"], visitor: ["left", "right"], aliases: ["Binary", "Expression"] }); -define("BlockStatement", { +defineType("BlockStatement", { visitor: ["body"], aliases: ["Scopable", "BlockParent", "Block", "Statement"] }); -define("BreakStatement", { +defineType("BreakStatement", { visitor: ["label"], aliases: ["Statement", "Terminatorless", "CompletionStatement"] }); -define("CallExpression", { +defineType("CallExpression", { visitor: ["callee", "arguments"], aliases: ["Expression"] }); -define("CatchClause", { +defineType("CatchClause", { visitor: ["param", "body"], aliases: ["Scopable"] }); -define("ConditionalExpression", { +defineType("ConditionalExpression", { visitor: ["test", "consequent", "alternate"], aliases: ["Expression"] }); -define("ContinueStatement", { +defineType("ContinueStatement", { visitor: ["label"], aliases: ["Statement", "Terminatorless", "CompletionStatement"] }); -define("DebuggerStatement", { +defineType("DebuggerStatement", { aliases: ["Statement"] }); -define("DoWhileStatement", { +defineType("DoWhileStatement", { visitor: ["body", "test"], aliases: ["Statement", "BlockParent", "Loop", "While", "Scopable"] }); -define("EmptyStatement", { +defineType("EmptyStatement", { aliases: ["Statement"] }); -define("ExpressionStatement", { +defineType("ExpressionStatement", { visitor: ["expression"], aliases: ["Statement"] }); -define("File", { +defineType("File", { builder: ["program", "comments", "tokens"], visitor: ["program"] }); -define("ForInStatement", { +defineType("ForInStatement", { visitor: ["left", "right", "body"], aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"] }); -define("ForStatement", { +defineType("ForStatement", { visitor: ["init", "test", "update", "body"], aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop"] }); -define("FunctionDeclaration", { +defineType("FunctionDeclaration", { builder: { id: null, params: null, @@ -92,7 +92,7 @@ define("FunctionDeclaration", { aliases: ["Scopable", "Function", "Func", "BlockParent", "FunctionParent", "Statement", "Pure", "Declaration"] }); -define("FunctionExpression", { +defineType("FunctionExpression", { builder: { id: null, params: null, @@ -104,34 +104,34 @@ define("FunctionExpression", { aliases: ["Scopable", "Function", "Func", "BlockParent", "FunctionParent", "Expression", "Pure"] }); -define("Identifier", { +defineType("Identifier", { builder: ["name"], visitor: ["typeAnnotation"], aliases: ["Expression"] }); -define("IfStatement", { +defineType("IfStatement", { visitor: ["test", "consequent", "alternate"], aliases: ["Statement"] }); -define("LabeledStatement", { +defineType("LabeledStatement", { visitor: ["label", "body"], aliases: ["Statement"] }); -define("Literal", { +defineType("Literal", { builder: ["value"], aliases: ["Expression", "Pure"] }); -define("LogicalExpression", { +defineType("LogicalExpression", { builder: ["operator", "left", "right"], visitor: ["left", "right"], aliases: ["Binary", "Expression"] }); -define("MemberExpression", { +defineType("MemberExpression", { builder: { object: null, property: null, @@ -141,22 +141,22 @@ define("MemberExpression", { aliases: ["Expression"] }); -define("NewExpression", { +defineType("NewExpression", { visitor: ["callee", "arguments"], aliases: ["Expression"] }); -define("ObjectExpression", { +defineType("ObjectExpression", { visitor: ["properties"], aliases: ["Expression"] }); -define("Program", { +defineType("Program", { visitor: ["body"], aliases: ["Scopable", "BlockParent", "Block", "FunctionParent"] }); -define("Property", { +defineType("Property", { builder: { kind: "init", key: null, @@ -167,45 +167,45 @@ define("Property", { aliases: ["UserWhitespacable"] }); -define("RestElement", { +defineType("RestElement", { visitor: ["argument", "typeAnnotation"] }); -define("ReturnStatement", { +defineType("ReturnStatement", { visitor: ["argument"], aliases: ["Statement", "Terminatorless", "CompletionStatement"] }); -define("SequenceExpression", { +defineType("SequenceExpression", { visitor: ["expressions"], aliases: ["Expression"] }); -define("SwitchCase", { +defineType("SwitchCase", { visitor: ["test", "consequent"] }); -define("SwitchStatement", { +defineType("SwitchStatement", { visitor: ["discriminant", "cases"], aliases: ["Statement", "BlockParent", "Scopable"] }); -define("ThisExpression", { +defineType("ThisExpression", { aliases: ["Expression"] }); -define("ThrowStatement", { +defineType("ThrowStatement", { visitor: ["argument"], aliases: ["Statement", "Terminatorless", "CompletionStatement"] }); -define("TryStatement", { +defineType("TryStatement", { builder: ["block", "handler", "finalizer"], visitor: ["block", "handlers", "handler", "guardedHandlers", "finalizer"], aliases: ["Statement"] }); -define("UnaryExpression", { +defineType("UnaryExpression", { builder: { operator: null, argument: null, @@ -215,7 +215,7 @@ define("UnaryExpression", { aliases: ["UnaryLike", "Expression"] }); -define("UpdateExpression", { +defineType("UpdateExpression", { builder: { operator: null, argument: null, @@ -225,22 +225,22 @@ define("UpdateExpression", { aliases: ["Expression"] }); -define("VariableDeclaration", { +defineType("VariableDeclaration", { builder: ["kind", "declarations"], visitor: ["declarations"], aliases: ["Statement", "Declaration"] }); -define("VariableDeclarator", { +defineType("VariableDeclarator", { visitor: ["id", "init"] }); -define("WhileStatement", { +defineType("WhileStatement", { visitor: ["test", "body"], aliases: ["Statement", "BlockParent", "Loop", "While", "Scopable"] }); -define("WithStatement", { +defineType("WithStatement", { visitor: ["object", "body"], aliases: ["Statement"] }); diff --git a/packages/babel/src/types/definitions/es2015.js b/packages/babel/src/types/definitions/es2015.js index dc1f6c866f..94a586ff6f 100644 --- a/packages/babel/src/types/definitions/es2015.js +++ b/packages/babel/src/types/definitions/es2015.js @@ -1,96 +1,96 @@ -import define from "./index"; +import defineType from "./index"; -define("AssignmentPattern", { +defineType("AssignmentPattern", { visitor: ["left", "right"], aliases: ["Pattern"] }); -define("ArrayPattern", { +defineType("ArrayPattern", { visitor: ["elements", "typeAnnotation"], aliases: ["Pattern"] }); -define("ArrowFunctionExpression", { +defineType("ArrowFunctionExpression", { builder: ["params", "body", "async"], visitor: ["params", "body", "returnType"], aliases: ["Scopable", "Function", "Func", "BlockParent", "FunctionParent", "Expression", "Pure"] }); -define("ClassBody", { +defineType("ClassBody", { visitor: ["body"] }); -define("ClassDeclaration", { +defineType("ClassDeclaration", { visitor: ["id", "body", "superClass", "typeParameters", "superTypeParameters", "implements", "decorators"], aliases: ["Scopable", "Class", "Statement", "Declaration"] }); -define("ClassExpression", { +defineType("ClassExpression", { visitor: ["id", "body", "superClass", "typeParameters", "superTypeParameters", "implements", "decorators"], aliases: ["Scopable", "Class", "Expression"] }); -define("ExportAllDeclaration", { +defineType("ExportAllDeclaration", { visitor: ["source", "exported"], aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"] }); -define("ExportDefaultDeclaration", { +defineType("ExportDefaultDeclaration", { visitor: ["declaration"], aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"] }); -define("ExportNamedDeclaration", { +defineType("ExportNamedDeclaration", { visitor: ["declaration", "specifiers", "source"], aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"] }); -define("ExportDefaultSpecifier", { +defineType("ExportDefaultSpecifier", { visitor: ["exported"], aliases: ["ModuleSpecifier"] }); -define("ExportNamespaceSpecifier", { +defineType("ExportNamespaceSpecifier", { visitor: ["exported"], aliases: ["ModuleSpecifier"] }); -define("ExportSpecifier", { +defineType("ExportSpecifier", { visitor: ["local", "exported"], aliases: ["ModuleSpecifier"] }); -define("ForOfStatement", { +defineType("ForOfStatement", { visitor: ["left", "right", "body"], aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"] }); -define("ImportDeclaration", { +defineType("ImportDeclaration", { visitor: ["specifiers", "source"], aliases: ["Statement", "Declaration", "ModuleDeclaration"] }); -define("ImportDefaultSpecifier", { +defineType("ImportDefaultSpecifier", { visitor: ["local"], aliases: ["ModuleSpecifier"] }); -define("ImportNamespaceSpecifier", { +defineType("ImportNamespaceSpecifier", { visitor: ["local"], aliases: ["ModuleSpecifier"] }); -define("ImportSpecifier", { +defineType("ImportSpecifier", { visitor: ["local", "imported"], aliases: ["ModuleSpecifier"] }); -define("MetaProperty", { +defineType("MetaProperty", { visitor: ["meta", "property"], aliases: ["Expression"] }); -define("MethodDefinition", { +defineType("MethodDefinition", { builder: { key: null, value: null, @@ -101,33 +101,33 @@ define("MethodDefinition", { visitor: ["key", "value", "decorators"] }); -define("ObjectPattern", { +defineType("ObjectPattern", { visitor: ["properties", "typeAnnotation"], aliases: ["Pattern"] }); -define("SpreadElement", { +defineType("SpreadElement", { visitor: ["argument"], aliases: ["UnaryLike"] }); -define("Super", { +defineType("Super", { aliases: ["Expression"] }); -define("TaggedTemplateExpression", { +defineType("TaggedTemplateExpression", { visitor: ["tag", "quasi"], aliases: ["Expression"] }); -define("TemplateElement"); +defineType("TemplateElement"); -define("TemplateLiteral", { +defineType("TemplateLiteral", { visitor: ["quasis", "expressions"], aliases: ["Expression"] }); -define("YieldExpression", { +defineType("YieldExpression", { builder: ["argument", "delegate"], visitor: ["argument"], aliases: ["Expression", "Terminatorless"] diff --git a/packages/babel/src/types/definitions/experimental.js b/packages/babel/src/types/definitions/experimental.js index 6af58866b9..9c5c8b6889 100644 --- a/packages/babel/src/types/definitions/experimental.js +++ b/packages/babel/src/types/definitions/experimental.js @@ -1,34 +1,34 @@ -import define from "./index"; +import defineType from "./index"; -define("AwaitExpression", { +defineType("AwaitExpression", { builder: ["argument", "all"], visitor: ["argument"], aliases: ["Expression", "Terminatorless"] }); -define("BindExpression", { +defineType("BindExpression", { visitor: ["object", "callee"] }); -define("ComprehensionBlock", { +defineType("ComprehensionBlock", { visitor: ["left", "right"] }); -define("ComprehensionExpression", { +defineType("ComprehensionExpression", { visitor: ["filter", "blocks", "body"], aliases: ["Expression", "Scopable"] }); -define("Decorator", { +defineType("Decorator", { visitor: ["expression"] }); -define("DoExpression", { +defineType("DoExpression", { visitor: ["body"], aliases: ["Expression"] }); -define("SpreadProperty", { +defineType("SpreadProperty", { visitor: ["argument"], aliases: ["UnaryLike"] }); diff --git a/packages/babel/src/types/definitions/flow.js b/packages/babel/src/types/definitions/flow.js index 2cfcc3e3e1..375253bfc2 100644 --- a/packages/babel/src/types/definitions/flow.js +++ b/packages/babel/src/types/definitions/flow.js @@ -1,172 +1,172 @@ -import define from "./index"; +import defineType from "./index"; -define("AnyTypeAnnotation", { +defineType("AnyTypeAnnotation", { aliases: ["Flow", "FlowBaseAnnotation"] }); -define("ArrayTypeAnnotation", { +defineType("ArrayTypeAnnotation", { visitor: ["elementType"], aliases: ["Flow"] }); -define("BooleanTypeAnnotation", { +defineType("BooleanTypeAnnotation", { aliases: ["Flow", "FlowBaseAnnotation"] }); -define("BooleanLiteralTypeAnnotation", { +defineType("BooleanLiteralTypeAnnotation", { aliases: ["Flow"] }); -define("ClassImplements", { +defineType("ClassImplements", { visitor: ["id", "typeParameters"], aliases: ["Flow"] }); -define("ClassProperty", { +defineType("ClassProperty", { visitor: ["key", "value", "typeAnnotation", "decorators"], aliases: ["Flow"] }); -define("DeclareClass", { +defineType("DeclareClass", { visitor: ["id", "typeParameters", "extends", "body"], aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"] }); -define("DeclareFunction", { +defineType("DeclareFunction", { visitor: ["id"], aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"] }); -define("DeclareModule", { +defineType("DeclareModule", { visitor: ["id", "body"], aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"] }); -define("DeclareVariable", { +defineType("DeclareVariable", { visitor: ["id"], aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"] }); -define("FunctionTypeAnnotation", { +defineType("FunctionTypeAnnotation", { visitor: ["typeParameters", "params", "rest", "returnType"], aliases: ["Flow"] }); -define("FunctionTypeParam", { +defineType("FunctionTypeParam", { visitor: ["name", "typeAnnotation"], aliases: ["Flow"] }); -define("GenericTypeAnnotation", { +defineType("GenericTypeAnnotation", { visitor: ["id", "typeParameters"], aliases: ["Flow"] }); -define("InterfaceExtends", { +defineType("InterfaceExtends", { visitor: ["id", "typeParameters"], aliases: ["Flow"] }); -define("InterfaceDeclaration", { +defineType("InterfaceDeclaration", { visitor: ["id", "typeParameters", "extends", "body"], aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"] }); -define("IntersectionTypeAnnotation", { +defineType("IntersectionTypeAnnotation", { visitor: ["types"], aliases: ["Flow"] }); -define("MixedTypeAnnotation", { +defineType("MixedTypeAnnotation", { aliases: ["Flow", "FlowBaseAnnotation"] }); -define("NullableTypeAnnotation", { +defineType("NullableTypeAnnotation", { visitor: ["typeAnnotation"], aliases: ["Flow"] }); -define("NumberLiteralTypeAnnotation", { +defineType("NumberLiteralTypeAnnotation", { aliases: ["Flow"] }); -define("NumberTypeAnnotation", { +defineType("NumberTypeAnnotation", { aliases: ["Flow", "FlowBaseAnnotation"] }); -define("StringLiteralTypeAnnotation", { +defineType("StringLiteralTypeAnnotation", { aliases: ["Flow"] }); -define("StringTypeAnnotation", { +defineType("StringTypeAnnotation", { aliases: ["Flow", "FlowBaseAnnotation"] }); -define("TupleTypeAnnotation", { +defineType("TupleTypeAnnotation", { visitor: ["types"], aliases: ["Flow"] }); -define("TypeofTypeAnnotation", { +defineType("TypeofTypeAnnotation", { visitor: ["argument"], aliases: ["Flow"] }); -define("TypeAlias", { +defineType("TypeAlias", { visitor: ["id", "typeParameters", "right"], aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"] }); -define("TypeAnnotation", { +defineType("TypeAnnotation", { visitor: ["typeAnnotation"], aliases: ["Flow"] }); -define("TypeCastExpression", { +defineType("TypeCastExpression", { visitor: ["expression", "typeAnnotation"], aliases: ["Flow"] }); -define("TypeParameterDeclaration", { +defineType("TypeParameterDeclaration", { visitor: ["params"], aliases: ["Flow"] }); -define("TypeParameterInstantiation", { +defineType("TypeParameterInstantiation", { visitor: ["params"], aliases: ["Flow"] }); -define("ObjectTypeAnnotation", { +defineType("ObjectTypeAnnotation", { visitor: ["properties", "indexers", "callProperties"], aliases: ["Flow"] }); -define("ObjectTypeCallProperty", { +defineType("ObjectTypeCallProperty", { visitor: ["value"], aliases: ["Flow", "UserWhitespacable"] }); -define("ObjectTypeIndexer", { +defineType("ObjectTypeIndexer", { visitor: ["id", "key", "value"], aliases: ["Flow", "UserWhitespacable"] }); -define("ObjectTypeProperty", { +defineType("ObjectTypeProperty", { visitor: ["key", "value"], aliases: ["Flow", "UserWhitespacable"] }); -define("QualifiedTypeIdentifier", { +defineType("QualifiedTypeIdentifier", { visitor: ["id", "qualification"], aliases: ["Flow"] }); -define("UnionTypeAnnotation", { +defineType("UnionTypeAnnotation", { visitor: ["types"], aliases: ["Flow"] }); -define("VoidTypeAnnotation", { +defineType("VoidTypeAnnotation", { aliases: ["Flow", "FlowBaseAnnotation"] }); diff --git a/packages/babel/src/types/definitions/index.js b/packages/babel/src/types/definitions/index.js index 4633ae2999..3c50b4d33b 100644 --- a/packages/babel/src/types/definitions/index.js +++ b/packages/babel/src/types/definitions/index.js @@ -8,7 +8,7 @@ function builderFromArray(arr) { return builder; } -export default function define(type, opts = {}) { +export default function defineType(type, opts = {}) { opts.visitor = opts.visitor || []; opts.aliases = opts.aliases || []; diff --git a/packages/babel/src/types/definitions/jsx.js b/packages/babel/src/types/definitions/jsx.js index e3c2ed04fe..4868235d7d 100644 --- a/packages/babel/src/types/definitions/jsx.js +++ b/packages/babel/src/types/definitions/jsx.js @@ -1,49 +1,49 @@ -import define from "./index"; +import defineType from "./index"; -define("JSXAttribute", { +defineType("JSXAttribute", { visitor: ["name", "value"], aliases: ["JSX", "Immutable"] }); -define("JSXClosingElement", { +defineType("JSXClosingElement", { visitor: ["name"], aliases: ["JSX", "Immutable"] }); -define("JSXElement", { +defineType("JSXElement", { visitor: ["openingElement", "closingElement", "children"], aliases: ["JSX", "Immutable", "Expression"] }); -define("JSXEmptyExpression", { +defineType("JSXEmptyExpression", { aliases: ["JSX", "Expression"] }); -define("JSXExpressionContainer", { +defineType("JSXExpressionContainer", { visitor: ["expression"], aliases: ["JSX", "Immutable"] }); -define("JSXIdentifier", { +defineType("JSXIdentifier", { aliases: ["JSX", "Expression"] }); -define("JSXMemberExpression", { +defineType("JSXMemberExpression", { visitor: ["object", "property"], aliases: ["JSX", "Expression"] }); -define("JSXNamespacedName", { +defineType("JSXNamespacedName", { visitor: ["namespace", "name"], aliases: ["JSX"] }); -define("JSXOpeningElement", { +defineType("JSXOpeningElement", { visitor: ["name", "attributes"], aliases: ["JSX", "Immutable"] }); -define("JSXSpreadAttribute", { +defineType("JSXSpreadAttribute", { visitor: ["argument"], aliases: ["JSX"] }); diff --git a/packages/babel/src/types/definitions/misc.js b/packages/babel/src/types/definitions/misc.js index 28730499f1..35e9b157b2 100644 --- a/packages/babel/src/types/definitions/misc.js +++ b/packages/babel/src/types/definitions/misc.js @@ -1,10 +1,10 @@ -import define from "./index"; +import defineType from "./index"; -define("Noop", { +defineType("Noop", { visitor: [] }); -define("ParenthesizedExpression", { +defineType("ParenthesizedExpression", { visitor: ["expression"], aliases: ["Expression"] }); From 273b7c5e07c739a5b49bf8b402d2a9f3ef8cd7e1 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Sat, 19 Sep 2015 01:52:08 +0100 Subject: [PATCH 16/26] v5.8.25 --- VERSION | 2 +- packages/babel/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index cbfa2cc121..261553830a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.8.24 \ No newline at end of file +5.8.25 \ No newline at end of file diff --git a/packages/babel/package.json b/packages/babel/package.json index 516cd9e9db..8ebc83335b 100644 --- a/packages/babel/package.json +++ b/packages/babel/package.json @@ -1,6 +1,6 @@ { "name": "babel-core", - "version": "5.8.24", + "version": "5.8.25", "description": "A compiler for writing next generation JavaScript", "author": "Sebastian McKenzie ", "homepage": "https://babeljs.io/", From 1d17f85a87f700cd8abd6c6e26d7086e573c3f9f Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Sat, 19 Sep 2015 02:12:17 +0100 Subject: [PATCH 17/26] add 5.8.25 changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc66a9271a..9baeb34a01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,11 @@ _Note: Gaps between patch versions are faulty, broken or test releases._ See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog. +## 5.8.25 + + * **Internal** + * Rename `define` method to avoid webpack assuming those files are AMD. + ## 5.8.24 * **Spec Compliancy** From 0f8eb6691b00b4872951ff6493bdacfa755af32a Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Sat, 19 Sep 2015 02:12:55 +0100 Subject: [PATCH 18/26] add 5.8.26 changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9baeb34a01..06ecb69c8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,11 @@ _Note: Gaps between patch versions are faulty, broken or test releases._ See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog. +## 5.8.26 + + * **Internal** + * Republish to get fix for runtime `typeof-react-element` helper. + ## 5.8.25 * **Internal** From 7eb45351bdc48412697c99ec59a969931c60e4e7 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Sat, 19 Sep 2015 02:17:05 +0100 Subject: [PATCH 19/26] add FORCE_VERSION check when validating whether or not any packages have changed --- scripts/publish.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/publish.js b/scripts/publish.js index 5a10aa948e..f3dfffb007 100755 --- a/scripts/publish.js +++ b/scripts/publish.js @@ -77,7 +77,7 @@ function publish() { } }); - if (!changedPackages.length) { + if (!changedPackages.length && !FORCE_VERSION.length) { throw new Error("No packages changed."); } From 75cd1a5531adb938f2747e4e5bb0928466246b1f Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Sat, 19 Sep 2015 02:17:50 +0100 Subject: [PATCH 20/26] v5.8.26 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 261553830a..96c215198d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.8.25 \ No newline at end of file +5.8.26 \ No newline at end of file From 5553fddd84a2b528fd90abe8731a5ecdbfd18308 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Tue, 22 Sep 2015 11:16:22 -0400 Subject: [PATCH 21/26] Upgrade Regenerator to v0.8.39 Most notably, this release fixes a bug that made it difficult for Promise implementations to track unhandled rejections when using async functions: https://github.com/facebook/regenerator/commit/3d8ee21f3ae918edcc04b8b18b0b5f7208883bf0 --- packages/babel/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/babel/package.json b/packages/babel/package.json index 8ebc83335b..4c67d7cdd1 100644 --- a/packages/babel/package.json +++ b/packages/babel/package.json @@ -63,7 +63,7 @@ "path-exists": "^1.0.0", "path-is-absolute": "^1.0.0", "private": "^0.1.6", - "regenerator": "0.8.35", + "regenerator": "0.8.39", "regexpu": "^1.1.2", "repeating": "^1.1.2", "resolve": "^1.1.6", @@ -75,4 +75,4 @@ "trim-right": "^1.0.0", "try-resolve": "^1.0.0" } -} \ No newline at end of file +} From 46e2a8618394538f5b1e51838a579bdfe46440be Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Wed, 23 Sep 2015 11:13:38 -0700 Subject: [PATCH 22/26] move class properties proposal to stage 1 --- .../src/transformation/transformers/es7/class-properties.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/babel/src/transformation/transformers/es7/class-properties.js b/packages/babel/src/transformation/transformers/es7/class-properties.js index ca95104fab..940ddbf6f2 100644 --- a/packages/babel/src/transformation/transformers/es7/class-properties.js +++ b/packages/babel/src/transformation/transformers/es7/class-properties.js @@ -1,4 +1,4 @@ export var metadata = { - stage: 0, + stage: 1, dependencies: ["es6.classes"] }; From e50476b8a4f100360d2c632453ea6641da9c100d Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Wed, 23 Sep 2015 15:01:42 -0400 Subject: [PATCH 23/26] Upgrade Regenerator to 0.8.40 Most notably, this pegs regenerator to a version of recast (0.10.33) which pegs ast-types to a version (0.8.12) that contains https://github.com/benjamn/ast-types/pull/128, so the Babel client bundle size will be a bit smaller. --- packages/babel/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/babel/package.json b/packages/babel/package.json index 4c67d7cdd1..38261b8d4e 100644 --- a/packages/babel/package.json +++ b/packages/babel/package.json @@ -63,7 +63,7 @@ "path-exists": "^1.0.0", "path-is-absolute": "^1.0.0", "private": "^0.1.6", - "regenerator": "0.8.39", + "regenerator": "0.8.40", "regexpu": "^1.1.2", "repeating": "^1.1.2", "resolve": "^1.1.6", From 7e9a9296ef1586af604f072682584084bdc72be7 Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Wed, 23 Sep 2015 16:41:40 -0700 Subject: [PATCH 24/26] advance es7.trailingFunctionCommas to stage 2 --- .../transformation/transformers/es7/trailing-function-commas.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/babel/src/transformation/transformers/es7/trailing-function-commas.js b/packages/babel/src/transformation/transformers/es7/trailing-function-commas.js index 5059fdd666..83435eaaaa 100644 --- a/packages/babel/src/transformation/transformers/es7/trailing-function-commas.js +++ b/packages/babel/src/transformation/transformers/es7/trailing-function-commas.js @@ -1,3 +1,3 @@ export var metadata = { - stage: 1 + stage: 2 }; From a5fc32e5986374840eab446bde86d8a1aaa4e3cf Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Fri, 11 Sep 2015 00:31:11 -0700 Subject: [PATCH 25/26] bump source-map to ^0.5.0 --- packages/babel-cli/package.json | 2 +- packages/babel/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/babel-cli/package.json b/packages/babel-cli/package.json index 00ed33de06..e8318bf229 100644 --- a/packages/babel-cli/package.json +++ b/packages/babel-cli/package.json @@ -18,7 +18,7 @@ "output-file-sync": "^1.1.0", "path-exists": "^1.0.0", "path-is-absolute": "^1.0.0", - "source-map": "^0.4.0", + "source-map": "^0.5.0", "slash": "^1.0.0" }, "bin": { diff --git a/packages/babel/package.json b/packages/babel/package.json index 4c67d7cdd1..4326bf4fa7 100644 --- a/packages/babel/package.json +++ b/packages/babel/package.json @@ -69,7 +69,7 @@ "resolve": "^1.1.6", "shebang-regex": "^1.0.0", "slash": "^1.0.0", - "source-map": "^0.4.0", + "source-map": "^0.5.0", "source-map-support": "^0.2.10", "to-fast-properties": "^1.0.0", "trim-right": "^1.0.0", From 2f13cfa85b1e40e0758c01d8e9be9b3e6f128f67 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Fri, 11 Sep 2015 00:33:46 -0700 Subject: [PATCH 26/26] optimize bundle builds --- package.json | 4 ++- packages/babel/scripts/build-dist.sh | 44 +++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index a229b833f1..5d11eeac6c 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,10 @@ "devDependencies": { "babel": "5.8.19", "babel-eslint": "^4.0.6", - "browserify": "^11.0.0", + "browserify": "^11.2.0", + "bundle-collapser": "^1.2.1", "chai": "^2.2.0", + "derequire": "^2.0.2", "es5-shim": "^4.1.7", "eslint": "^1.1.0", "fs-readdir-recursive": "^0.1.2", diff --git a/packages/babel/scripts/build-dist.sh b/packages/babel/scripts/build-dist.sh index b43bf42f56..41b8ebc695 100755 --- a/packages/babel/scripts/build-dist.sh +++ b/packages/babel/scripts/build-dist.sh @@ -3,24 +3,54 @@ set -e BROWSERIFY_CMD="../../node_modules/browserify/bin/cmd.js" UGLIFY_CMD="../../node_modules/uglify-js/bin/uglifyjs" -BROWSERIFY_IGNORE="-i esprima-fb" +BROWSERIFY_IGNORE="-i esprima-fb -i through" + +set -x mkdir -p dist node scripts/cache-templates -node $BROWSERIFY_CMD -e lib/polyfill.js >dist/polyfill.js -node $UGLIFY_CMD dist/polyfill.js >dist/polyfill.min.js +node $BROWSERIFY_CMD lib/polyfill.js \ + --insert-global-vars 'global' \ + --plugin bundle-collapser/plugin \ + --plugin derequire/plugin \ + >dist/polyfill.js +node $UGLIFY_CMD dist/polyfill.js \ + --compress warnings=false \ + --mangle \ + >dist/polyfill.min.js # Add a Unicode BOM so browsers will interpret the file as UTF-8 node -p '"\uFEFF"' > dist/browser.js -node $BROWSERIFY_CMD lib/api/browser.js -s babel $BROWSERIFY_IGNORE >>dist/browser.js +node $BROWSERIFY_CMD lib/api/browser.js \ + --standalone babel \ + --plugin bundle-collapser/plugin \ + --plugin derequire/plugin \ + $BROWSERIFY_IGNORE \ + >>dist/browser.js node -p '"\uFEFF"' > dist/browser.min.js -node $UGLIFY_CMD dist/browser.js >>dist/browser.min.js +node $UGLIFY_CMD dist/browser.js \ + --compress warnings=false \ + --mangle \ + >>dist/browser.min.js -node $BROWSERIFY_CMD lib/api/node.js --node $BROWSERIFY_IGNORE >dist/node.js +node $BROWSERIFY_CMD lib/api/node.js \ + --standalone babel \ + --node \ + --plugin bundle-collapser/plugin \ + --plugin derequire/plugin \ + $BROWSERIFY_IGNORE \ + >dist/node.js +node $UGLIFY_CMD dist/node.js \ + --compress warnings=false \ + --mangle \ + >dist/node.min.js node ../babel-cli/lib/babel-external-helpers >dist/external-helpers.js -node $UGLIFY_CMD dist/external-helpers.js >dist/external-helpers.min.js +node $UGLIFY_CMD dist/external-helpers.js \ + --compress warnings=false \ + --mangle \ + >dist/external-helpers.min.js rm -rf templates.json