Merge branch 'master' into merge-master
# Conflicts: # lerna.json # packages/babel-cli/package.json # packages/babel-core/package.json # packages/babel-generator/package.json # packages/babel-helper-builder-react-jsx/package.json # packages/babel-helper-function-name/package.json # packages/babel-helper-optimise-call-expression/package.json # packages/babel-helper-replace-supers/package.json # packages/babel-helper-transform-fixture-test-runner/package.json # packages/babel-helpers/package.json # packages/babel-plugin-transform-class-properties/package.json # packages/babel-plugin-transform-es2015-block-scoping/package.json # packages/babel-plugin-transform-es2015-classes/package.json # packages/babel-plugin-transform-es2015-modules-commonjs/package.json # packages/babel-plugin-transform-es2015-modules-systemjs/package.json # packages/babel-plugin-transform-es2015-modules-umd/package.json # packages/babel-plugin-transform-es2015-parameters/package.json # packages/babel-plugin-transform-react-jsx/package.json # packages/babel-register/package.json # packages/babel-template/package.json # packages/babel-traverse/package.json # packages/babel/package.json
This commit is contained in:
commit
6c03cb0783
@ -1,5 +1,11 @@
|
|||||||
{
|
{
|
||||||
"userBlacklist": [ "amasad", "thejameskyle", "jmm", "kittens" ],
|
"userBlacklist": [
|
||||||
|
"amasad",
|
||||||
|
"greenkeeperio-bot",
|
||||||
|
"jmm",
|
||||||
|
"kittens",
|
||||||
|
"thejameskyle"
|
||||||
|
],
|
||||||
"fileBlacklist": ["*.md"],
|
"fileBlacklist": ["*.md"],
|
||||||
"skipAlreadyAssignedPR": true,
|
"skipAlreadyAssignedPR": true,
|
||||||
"createReviewRequest": true
|
"createReviewRequest": true
|
||||||
|
|||||||
90
CHANGELOG.md
90
CHANGELOG.md
@ -13,6 +13,96 @@ _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.
|
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
|
||||||
|
|
||||||
|
## 6.23.0 (2017-02-13)
|
||||||
|
|
||||||
|
#### :rocket: New Feature
|
||||||
|
* `babel-plugin-transform-react-constant-elements`
|
||||||
|
* [#4812](https://github.com/babel/babel/pull/4812) feature: Support pure expressions in transform-react-constant-elements. ([@STRML](https://github.com/STRML))
|
||||||
|
* `babel-preset-flow`, `babel-preset-react`
|
||||||
|
* [#5288](https://github.com/babel/babel/pull/5288) Add new flow preset. ([@thejameskyle](https://github.com/thejameskyle))
|
||||||
|
* `babel-traverse`
|
||||||
|
* [#5230](https://github.com/babel/babel/pull/5230) Add path/family sibling traversal methods. ([@chitchu](https://github.com/chitchu))
|
||||||
|
* `babel-plugin-transform-es2015-block-scoping`
|
||||||
|
* [#5236](https://github.com/babel/babel/pull/5236) Add option to block-scoping to throw on slow code. ([@spicyj](https://github.com/spicyj))
|
||||||
|
|
||||||
|
#### :bug: Bug Fix
|
||||||
|
* `babel-core`, `babel-traverse`
|
||||||
|
* [#5050](https://github.com/babel/babel/pull/5050) Rewrite Hub as interface #5047. ([@yongxu](https://github.com/yongxu))
|
||||||
|
* `babel-plugin-transform-es2015-for-of`
|
||||||
|
* [#5298](https://github.com/babel/babel/pull/5298) Fix loose for-of with label. ([@jridgewell](https://github.com/jridgewell))
|
||||||
|
* `babel-plugin-transform-react-constant-elements`, `babel-traverse`
|
||||||
|
* [#5153](https://github.com/babel/babel/pull/5153) Fix react constant elements bindings. ([@STRML](https://github.com/STRML))
|
||||||
|
* [#5143](https://github.com/babel/babel/pull/5143) Fix PathHoister hoisting JSX member expressions on "this".. ([@STRML](https://github.com/STRML))
|
||||||
|
* `babel-plugin-transform-do-expressions`, `babel-traverse`
|
||||||
|
* [#5030](https://github.com/babel/babel/pull/5030) Prevent multiple return statements in a loop when replacing expressions. ([@existentialism](https://github.com/existentialism))
|
||||||
|
* `babel-register`
|
||||||
|
* [#5260](https://github.com/babel/babel/pull/5260) Fix TypeError with babel-register's cache. ([@xtuc](https://github.com/xtuc))
|
||||||
|
* `babel-traverse`
|
||||||
|
* [#5206](https://github.com/babel/babel/pull/5206) Deopt evaluation of undefined with a local binding. Closes [#5204](https://github.com/babel/babel/issues/5204). ([@boopathi](https://github.com/boopathi))
|
||||||
|
* `babel-plugin-transform-runtime`
|
||||||
|
* [#5195](https://github.com/babel/babel/pull/5195) Don't transpile ES7 symbol properties. ([@taion](https://github.com/taion))
|
||||||
|
* `babel`
|
||||||
|
* [#5258](https://github.com/babel/babel/pull/5258) checks if babel is installed globally and displays correct cli message. ([@xtina-starr](https://github.com/xtina-starr))
|
||||||
|
* `babel-generator`
|
||||||
|
* [#5270](https://github.com/babel/babel/pull/5270) Emit parens for await of ternary expressions. ([@erikdesjardins](https://github.com/erikdesjardins))
|
||||||
|
* [#5193](https://github.com/babel/babel/pull/5193) Fix missing parens when function expressions is tag. ([@existentialism](https://github.com/existentialism))
|
||||||
|
* `babel-plugin-transform-es2015-modules-commonjs`
|
||||||
|
* [#5235](https://github.com/babel/babel/pull/5235) Limit export node default assignment stack size #4323. ([@mattste](https://github.com/mattste))
|
||||||
|
|
||||||
|
#### :memo: Documentation
|
||||||
|
* `babel-*`
|
||||||
|
* [#5244](https://github.com/babel/babel/pull/5244) Normalize options sections in docs [skip ci]. ([@existentialism](https://github.com/existentialism))
|
||||||
|
* [#5216](https://github.com/babel/babel/pull/5216) Remove link to REPL. ([@xtuc](https://github.com/xtuc))
|
||||||
|
* Other
|
||||||
|
* [#5242](https://github.com/babel/babel/pull/5242) Add our business model [skip ci]. ([@hzoo](https://github.com/hzoo))
|
||||||
|
* `babel-plugin-transform-es2015-spread`
|
||||||
|
* [#5227](https://github.com/babel/babel/pull/5227) Add example to spread README [skip ci]. ([@finkef](https://github.com/finkef))
|
||||||
|
* `babel-plugin-transform-flow-strip-types`
|
||||||
|
* [#5212](https://github.com/babel/babel/pull/5212) Remove REPL link transform-flow-strip-types doc. ([@xtuc](https://github.com/xtuc))
|
||||||
|
* `babel-plugin-transform-regenerator`
|
||||||
|
* [#5202](https://github.com/babel/babel/pull/5202) Fix transform-regenerator README. ([@xtuc](https://github.com/xtuc))
|
||||||
|
* `babel-plugin-transform-es2015-arrow-functions`
|
||||||
|
* [#5200](https://github.com/babel/babel/pull/5200) Fix transform-es2015-arrow-functions code blocks on the website. ([@xtuc](https://github.com/xtuc))
|
||||||
|
* [#5194](https://github.com/babel/babel/pull/5194) Fix transform-es2015-arrow-functions README. ([@xtuc](https://github.com/xtuc))
|
||||||
|
|
||||||
|
#### :house: Internal
|
||||||
|
* `babel-core`
|
||||||
|
* [#5302](https://github.com/babel/babel/pull/5302) Add charset so tests work with convert-source-map@>1.4. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||||
|
* `babel-core`, `babel-traverse`
|
||||||
|
* [#5050](https://github.com/babel/babel/pull/5050) Rewrite Hub as interface #5047. ([@yongxu](https://github.com/yongxu))
|
||||||
|
* `babel-generator`
|
||||||
|
* [#5255](https://github.com/babel/babel/pull/5255) codegen performance: use trim instead of lodash/trimEnd. ([@jwbay](https://github.com/jwbay))
|
||||||
|
* `babel-types`
|
||||||
|
* [#5181](https://github.com/babel/babel/pull/5181) Remove uses of lodash/compact. ([@zertosh](https://github.com/zertosh))
|
||||||
|
* `babel-*`
|
||||||
|
* [#5265](https://github.com/babel/babel/pull/5265) Re-enable the max-len ESLint rule.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||||
|
* Other
|
||||||
|
* [#5264](https://github.com/babel/babel/pull/5264) Add a sublime project file. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||||
|
* [#5182](https://github.com/babel/babel/pull/5182) Run coverage only once. ([@existentialism](https://github.com/existentialism))
|
||||||
|
* [#5165](https://github.com/babel/babel/pull/5165) Add Node 7 to CI. ([@chicoxyzzy](https://github.com/chicoxyzzy))
|
||||||
|
|
||||||
|
#### Committers: 20
|
||||||
|
- Andres Suarez ([zertosh](https://github.com/zertosh))
|
||||||
|
- Ben Alpert ([spicyj](https://github.com/spicyj))
|
||||||
|
- Boopathi Rajaa ([boopathi](https://github.com/boopathi))
|
||||||
|
- Brian Ng ([existentialism](https://github.com/existentialism))
|
||||||
|
- Christina ([xtina-starr](https://github.com/xtina-starr))
|
||||||
|
- Erik Desjardins ([erikdesjardins](https://github.com/erikdesjardins))
|
||||||
|
- Fabian Finke ([finkef](https://github.com/finkef))
|
||||||
|
- Henry Zhu ([hzoo](https://github.com/hzoo))
|
||||||
|
- Jimmy Jia ([taion](https://github.com/taion))
|
||||||
|
- Justin Ridgewell ([jridgewell](https://github.com/jridgewell))
|
||||||
|
- Logan Smyth ([loganfsmyth](https://github.com/loganfsmyth))
|
||||||
|
- Matt Stewart ([mattste](https://github.com/mattste))
|
||||||
|
- Samuel Reed ([STRML](https://github.com/STRML))
|
||||||
|
- Sergey Rubanov ([chicoxyzzy](https://github.com/chicoxyzzy))
|
||||||
|
- Sven SAULEAU ([xtuc](https://github.com/xtuc))
|
||||||
|
- Vicente Jr Yuchitcho ([chitchu](https://github.com/chitchu))
|
||||||
|
- Yongxu Ren ([yongxu](https://github.com/yongxu))
|
||||||
|
- [jwbay](https://github.com/jwbay)
|
||||||
|
- james kyle ([thejameskyle](https://github.com/thejameskyle))
|
||||||
|
- Łukasz Lityński ([hex13](https://github.com/hex13))
|
||||||
|
|
||||||
## 6.22.2 (2017-01-19)
|
## 6.22.2 (2017-01-19)
|
||||||
|
|
||||||
#### :bug: Bug Fix
|
#### :bug: Bug Fix
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-cli",
|
"name": "babel-cli",
|
||||||
"version": "6.22.2",
|
"version": "6.23.0",
|
||||||
"description": "Babel command line.",
|
"description": "Babel command line.",
|
||||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||||
"homepage": "https://babeljs.io/",
|
"homepage": "https://babeljs.io/",
|
||||||
@ -16,9 +16,9 @@
|
|||||||
"compiler"
|
"compiler"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-core": "^6.22.1",
|
"babel-core": "^6.23.0",
|
||||||
"babel-register": "^6.22.0",
|
"babel-register": "^6.23.0",
|
||||||
"babel-polyfill": "^6.22.0",
|
"babel-polyfill": "^6.23.0",
|
||||||
"commander": "^2.8.1",
|
"commander": "^2.8.1",
|
||||||
"convert-source-map": "^1.1.0",
|
"convert-source-map": "^1.1.0",
|
||||||
"fs-readdir-recursive": "^1.0.0",
|
"fs-readdir-recursive": "^1.0.0",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-core",
|
"name": "babel-core",
|
||||||
"version": "6.22.1",
|
"version": "6.23.1",
|
||||||
"description": "Babel compiler core.",
|
"description": "Babel compiler core.",
|
||||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||||
"homepage": "https://babeljs.io/",
|
"homepage": "https://babeljs.io/",
|
||||||
@ -27,13 +27,13 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-code-frame": "^6.22.0",
|
"babel-code-frame": "^6.22.0",
|
||||||
"babel-generator": "^6.22.0",
|
"babel-generator": "^6.23.0",
|
||||||
"babel-helpers": "^6.22.0",
|
"babel-helpers": "^6.23.0",
|
||||||
"babel-messages": "^6.22.0",
|
"babel-messages": "^6.23.0",
|
||||||
"babel-template": "^6.22.0",
|
"babel-template": "^6.23.0",
|
||||||
"babel-register": "^6.22.0",
|
"babel-register": "^6.23.0",
|
||||||
"babel-traverse": "^6.22.1",
|
"babel-traverse": "^6.23.1",
|
||||||
"babel-types": "^6.22.0",
|
"babel-types": "^6.23.0",
|
||||||
"babylon": "^6.11.0",
|
"babylon": "^6.11.0",
|
||||||
"convert-source-map": "^1.1.0",
|
"convert-source-map": "^1.1.0",
|
||||||
"debug": "^2.1.1",
|
"debug": "^2.1.1",
|
||||||
@ -46,7 +46,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-helper-fixtures": "^6.22.0",
|
"babel-helper-fixtures": "^6.22.0",
|
||||||
"babel-helper-transform-fixture-test-runner": "^6.22.0",
|
"babel-helper-transform-fixture-test-runner": "^6.23.0",
|
||||||
"babel-polyfill": "^6.22.0"
|
"babel-polyfill": "^6.23.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
function wrapper(fn) {
|
function wrapper(fn) {
|
||||||
return (...args) => {
|
return (...args) => {
|
||||||
if (someCondition) {
|
while (someCondition) {
|
||||||
const val = fn(...args);
|
const val = fn(...args);
|
||||||
return val.test(() => {
|
return val.test(() => {
|
||||||
console.log(val);
|
console.log(val);
|
||||||
|
|||||||
@ -2,15 +2,17 @@ function wrapper(fn) {
|
|||||||
return function () {
|
return function () {
|
||||||
var _arguments = arguments;
|
var _arguments = arguments;
|
||||||
|
|
||||||
if (someCondition) {
|
var _loop = function () {
|
||||||
var _ret = function () {
|
|
||||||
var val = fn(..._arguments);
|
var val = fn(..._arguments);
|
||||||
return {
|
return {
|
||||||
v: val.test(function () {
|
v: val.test(function () {
|
||||||
console.log(val);
|
console.log(val);
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
}();
|
};
|
||||||
|
|
||||||
|
while (someCondition) {
|
||||||
|
var _ret = _loop();
|
||||||
|
|
||||||
if (typeof _ret === "object") return _ret.v;
|
if (typeof _ret === "object") return _ret.v;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
arr.map(function (x) {
|
arr.map(function (x) {
|
||||||
return x * x;
|
return x * x;
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNvdXJjZS1tYXBzL2lubGluZS9hY3R1YWwuanMiXSwibmFtZXMiOlsiYXJyIiwibWFwIiwieCJdLCJtYXBwaW5ncyI6IkFBQUFBLElBQUlDLEdBQUosQ0FBUTtBQUFBLFNBQUtDLElBQUlBLENBQVQ7QUFBQSxDQUFSIiwiZmlsZSI6InNvdXJjZS1tYXBzL2lubGluZS9leHBlY3RlZC5qcyIsInNvdXJjZXNDb250ZW50IjpbImFyci5tYXAoeCA9PiB4ICogeCk7Il19
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNvdXJjZS1tYXBzL2lubGluZS9hY3R1YWwuanMiXSwibmFtZXMiOlsiYXJyIiwibWFwIiwieCJdLCJtYXBwaW5ncyI6IkFBQUFBLElBQUlDLEdBQUosQ0FBUTtBQUFBLFNBQUtDLElBQUlBLENBQVQ7QUFBQSxDQUFSIiwiZmlsZSI6InNvdXJjZS1tYXBzL2lubGluZS9leHBlY3RlZC5qcyIsInNvdXJjZXNDb250ZW50IjpbImFyci5tYXAoeCA9PiB4ICogeCk7Il19
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-generator",
|
"name": "babel-generator",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Turns an AST into code.",
|
"description": "Turns an AST into code.",
|
||||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||||
"homepage": "https://babeljs.io/",
|
"homepage": "https://babeljs.io/",
|
||||||
@ -11,9 +11,9 @@
|
|||||||
"lib"
|
"lib"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-messages": "^6.22.0",
|
"babel-messages": "^6.23.0",
|
||||||
"babel-types": "^6.22.0",
|
"babel-types": "^6.23.0",
|
||||||
"detect-indent": "^5.0.0",
|
"detect-indent": "^4.0.0",
|
||||||
"jsesc": "^1.3.0",
|
"jsesc": "^1.3.0",
|
||||||
"lodash": "^4.2.0",
|
"lodash": "^4.2.0",
|
||||||
"source-map": "^0.5.0",
|
"source-map": "^0.5.0",
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-helper-builder-react-jsx",
|
"name": "babel-helper-builder-react-jsx",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Helper function to build react jsx",
|
"description": "Helper function to build react jsx",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-builder-react-jsx",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-builder-react-jsx",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-types": "^6.22.0",
|
"babel-types": "^6.23.0",
|
||||||
"esutils": "^2.0.0",
|
"esutils": "^2.0.0",
|
||||||
"lodash": "^4.2.0"
|
"lodash": "^4.2.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-helper-define-map",
|
"name": "babel-helper-define-map",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Helper function to define a map",
|
"description": "Helper function to define a map",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-define-map",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-define-map",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"lodash": "^4.2.0",
|
"lodash": "^4.2.0",
|
||||||
"babel-types": "^6.22.0",
|
"babel-types": "^6.23.0",
|
||||||
"babel-helper-function-name": "^6.22.0"
|
"babel-helper-function-name": "^6.23.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-helper-function-name",
|
"name": "babel-helper-function-name",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Helper function to change the property 'name' of every function",
|
"description": "Helper function to change the property 'name' of every function",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-function-name",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-function-name",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-types": "^6.22.0",
|
"babel-types": "^6.23.0",
|
||||||
"babel-traverse": "^6.22.0",
|
"babel-traverse": "^6.23.0",
|
||||||
"babel-helper-get-function-arity": "^6.22.0",
|
"babel-helper-get-function-arity": "^6.22.0",
|
||||||
"babel-template": "^6.22.0"
|
"babel-template": "^6.23.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-helper-optimise-call-expression",
|
"name": "babel-helper-optimise-call-expression",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Helper function to optimise call expression",
|
"description": "Helper function to optimise call expression",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-optimise-call-expression",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-optimise-call-expression",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-types": "^6.22.0"
|
"babel-types": "^6.23.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-helper-replace-supers",
|
"name": "babel-helper-replace-supers",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Helper function to replace supers",
|
"description": "Helper function to replace supers",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-replace-supers",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-replace-supers",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-helper-optimise-call-expression": "^6.22.0",
|
"babel-helper-optimise-call-expression": "^6.23.0",
|
||||||
"babel-traverse": "^6.22.0",
|
"babel-traverse": "^6.23.0",
|
||||||
"babel-messages": "^6.22.0",
|
"babel-messages": "^6.23.0",
|
||||||
"babel-template": "^6.22.0",
|
"babel-template": "^6.23.0",
|
||||||
"babel-types": "^6.22.0"
|
"babel-types": "^6.23.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-helper-transform-fixture-test-runner",
|
"name": "babel-helper-transform-fixture-test-runner",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Transform test runner for babel-helper-fixtures module",
|
"description": "Transform test runner for babel-helper-fixtures module",
|
||||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||||
"homepage": "https://babeljs.io/",
|
"homepage": "https://babeljs.io/",
|
||||||
@ -8,8 +8,8 @@
|
|||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-transform-fixture-test-runner",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-transform-fixture-test-runner",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-core": "^6.22.0",
|
"babel-core": "^6.23.0",
|
||||||
"babel-polyfill": "^6.22.0",
|
"babel-polyfill": "^6.23.0",
|
||||||
"babel-helper-fixtures": "^6.22.0",
|
"babel-helper-fixtures": "^6.22.0",
|
||||||
"source-map": "^0.5.0",
|
"source-map": "^0.5.0",
|
||||||
"babel-code-frame": "^6.22.0",
|
"babel-code-frame": "^6.22.0",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-helpers",
|
"name": "babel-helpers",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Collection of helper functions used by Babel transforms.",
|
"description": "Collection of helper functions used by Babel transforms.",
|
||||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||||
"homepage": "https://babeljs.io/",
|
"homepage": "https://babeljs.io/",
|
||||||
@ -8,6 +8,6 @@
|
|||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helpers",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helpers",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-template": "^6.22.0"
|
"babel-template": "^6.23.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-messages",
|
"name": "babel-messages",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Collection of debug messages used by Babel.",
|
"description": "Collection of debug messages used by Babel.",
|
||||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||||
"homepage": "https://babeljs.io/",
|
"homepage": "https://babeljs.io/",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-plugin-transform-class-properties",
|
"name": "babel-plugin-transform-class-properties",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "This plugin transforms static class properties as well as properties declared with the property initializer syntax",
|
"description": "This plugin transforms static class properties as well as properties declared with the property initializer syntax",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-class-properties",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-class-properties",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -9,9 +9,9 @@
|
|||||||
"babel-plugin"
|
"babel-plugin"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-helper-function-name": "^6.22.0",
|
"babel-helper-function-name": "^6.23.0",
|
||||||
"babel-plugin-syntax-class-properties": "^6.8.0",
|
"babel-plugin-syntax-class-properties": "^6.8.0",
|
||||||
"babel-template": "^6.22.0"
|
"babel-template": "^6.23.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-helper-plugin-test-runner": "^6.22.0"
|
"babel-helper-plugin-test-runner": "^6.22.0"
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-plugin-transform-es2015-block-scoping",
|
"name": "babel-plugin-transform-es2015-block-scoping",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Compile ES2015 block scoping (const and let) to ES5",
|
"description": "Compile ES2015 block scoping (const and let) to ES5",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-block-scoping",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-block-scoping",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-traverse": "^6.22.0",
|
"babel-traverse": "^6.23.0",
|
||||||
"babel-types": "^6.22.0",
|
"babel-types": "^6.23.0",
|
||||||
"babel-template": "^6.22.0",
|
"babel-template": "^6.23.0",
|
||||||
"lodash": "^4.2.0"
|
"lodash": "^4.2.0"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@ -112,8 +112,21 @@ function isVar(node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const letReferenceBlockVisitor = traverse.visitors.merge([{
|
const letReferenceBlockVisitor = traverse.visitors.merge([{
|
||||||
|
Loop: {
|
||||||
|
enter(path, state) {
|
||||||
|
state.loopDepth++;
|
||||||
|
},
|
||||||
|
exit(path, state) {
|
||||||
|
state.loopDepth--;
|
||||||
|
},
|
||||||
|
},
|
||||||
Function(path, state) {
|
Function(path, state) {
|
||||||
|
// References to block-scoped variables only require added closures if it's
|
||||||
|
// possible for the code to run more than once -- otherwise it is safe to
|
||||||
|
// simply rename the variables.
|
||||||
|
if (state.loopDepth > 0) {
|
||||||
path.traverse(letReferenceFunctionVisitor, state);
|
path.traverse(letReferenceFunctionVisitor, state);
|
||||||
|
}
|
||||||
return path.skip();
|
return path.skip();
|
||||||
}
|
}
|
||||||
}, tdzVisitor]);
|
}, tdzVisitor]);
|
||||||
@ -549,9 +562,19 @@ class BlockScoping {
|
|||||||
const state = {
|
const state = {
|
||||||
letReferences: this.letReferences,
|
letReferences: this.letReferences,
|
||||||
closurify: false,
|
closurify: false,
|
||||||
file: this.file
|
file: this.file,
|
||||||
|
loopDepth: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const loopOrFunctionParent = this.blockPath.find(
|
||||||
|
(path) => path.isLoop() || path.isFunction()
|
||||||
|
);
|
||||||
|
if (loopOrFunctionParent && loopOrFunctionParent.isLoop()) {
|
||||||
|
// There is a loop ancestor closer than the closest function, so we
|
||||||
|
// consider ourselves to be in a loop.
|
||||||
|
state.loopDepth++;
|
||||||
|
}
|
||||||
|
|
||||||
// traverse through this block, stopping on functions and checking if they
|
// traverse through this block, stopping on functions and checking if they
|
||||||
// contain any local let references
|
// contain any local let references
|
||||||
this.blockPath.traverse(letReferenceBlockVisitor, state);
|
this.blockPath.traverse(letReferenceBlockVisitor, state);
|
||||||
|
|||||||
@ -1,11 +1,9 @@
|
|||||||
if (true) {
|
if (true) {
|
||||||
var x;
|
var foo = function () {};
|
||||||
|
|
||||||
(function () {
|
var bar = function () {
|
||||||
function foo() {}
|
|
||||||
function bar() {
|
|
||||||
return foo;
|
return foo;
|
||||||
}
|
};
|
||||||
for (x in {}) {}
|
|
||||||
})();
|
for (var x in {}) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,34 @@
|
|||||||
|
function foo() {
|
||||||
|
const x = 5;
|
||||||
|
console.log(x);
|
||||||
|
|
||||||
|
{
|
||||||
|
const x = 7;
|
||||||
|
setTimeout(() => x, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function bar() {
|
||||||
|
const x = 5;
|
||||||
|
console.log(x);
|
||||||
|
|
||||||
|
for (let i = 0; i < 7; i++) {
|
||||||
|
{
|
||||||
|
const x = i;
|
||||||
|
setTimeout(() => x, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function baz() {
|
||||||
|
const x = 5;
|
||||||
|
console.log(x);
|
||||||
|
|
||||||
|
for (let i = 0; i < 7; i++) {
|
||||||
|
var qux = function qux(y) {
|
||||||
|
const x = y;
|
||||||
|
setTimeout(() => x, 0);
|
||||||
|
};
|
||||||
|
qux(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
function foo() {
|
||||||
|
var x = 5;
|
||||||
|
console.log(x);
|
||||||
|
|
||||||
|
{
|
||||||
|
var _x = 7;
|
||||||
|
setTimeout(function () {
|
||||||
|
return _x;
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function bar() {
|
||||||
|
var x = 5;
|
||||||
|
console.log(x);
|
||||||
|
|
||||||
|
for (var i = 0; i < 7; i++) {
|
||||||
|
{
|
||||||
|
(function () {
|
||||||
|
var x = i;
|
||||||
|
setTimeout(function () {
|
||||||
|
return x;
|
||||||
|
}, 0);
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function baz() {
|
||||||
|
var x = 5;
|
||||||
|
console.log(x);
|
||||||
|
|
||||||
|
for (var i = 0; i < 7; i++) {
|
||||||
|
var qux = function qux(y) {
|
||||||
|
var x = y;
|
||||||
|
setTimeout(function () {
|
||||||
|
return x;
|
||||||
|
}, 0);
|
||||||
|
};
|
||||||
|
qux(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
var f1, f2;
|
||||||
|
{
|
||||||
|
let z = 'z1 value';
|
||||||
|
f1 = function() { return z; };
|
||||||
|
}
|
||||||
|
{
|
||||||
|
let z = 'z2 value';
|
||||||
|
f2 = function() { return z; };
|
||||||
|
}
|
||||||
|
f1();
|
||||||
|
f2();
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
var f1, f2;
|
||||||
|
{
|
||||||
|
var z = 'z1 value';
|
||||||
|
f1 = function () {
|
||||||
|
return z;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
var _z = 'z2 value';
|
||||||
|
f2 = function () {
|
||||||
|
return _z;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
f1();
|
||||||
|
f2();
|
||||||
@ -1,4 +1,5 @@
|
|||||||
function foo() {
|
function foo() {
|
||||||
|
while (true) {
|
||||||
switch (2) {
|
switch (2) {
|
||||||
case 0: {
|
case 0: {
|
||||||
if (true) {
|
if (true) {
|
||||||
@ -14,3 +15,4 @@ function foo() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
function foo() {
|
function foo() {
|
||||||
|
while (true) {
|
||||||
switch (2) {
|
switch (2) {
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
@ -27,3 +28,4 @@ function foo() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
function fn() {
|
function fn() {
|
||||||
|
while (true) {
|
||||||
switch (true) {
|
switch (true) {
|
||||||
default:
|
default:
|
||||||
let foo = 4;
|
let foo = 4;
|
||||||
@ -8,3 +9,4 @@ function fn() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
function fn() {
|
function fn() {
|
||||||
|
while (true) {
|
||||||
(function () {
|
(function () {
|
||||||
switch (true) {
|
switch (true) {
|
||||||
default:
|
default:
|
||||||
@ -12,3 +13,4 @@ function fn() {
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -0,0 +1,6 @@
|
|||||||
|
for (var i = 0; i < 5; i++) {
|
||||||
|
var l = i;
|
||||||
|
setTimeout(function () {
|
||||||
|
console.log(l);
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
@ -1,16 +0,0 @@
|
|||||||
function foo() {
|
|
||||||
switch (2) {
|
|
||||||
case 0: {
|
|
||||||
if (true) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const stuff = new Map();
|
|
||||||
const data = 0;
|
|
||||||
stuff.forEach(() => {
|
|
||||||
const d = data;
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"throws": "Compiling let/const in this block would add a closure (throwIfClosureRequired)."
|
|
||||||
}
|
|
||||||
@ -1,19 +1,19 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-plugin-transform-es2015-classes",
|
"name": "babel-plugin-transform-es2015-classes",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Compile ES2015 classes to ES5",
|
"description": "Compile ES2015 classes to ES5",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-classes",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-classes",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-helper-optimise-call-expression": "^6.22.0",
|
"babel-helper-optimise-call-expression": "^6.23.0",
|
||||||
"babel-helper-function-name": "^6.22.0",
|
"babel-helper-function-name": "^6.23.0",
|
||||||
"babel-helper-replace-supers": "^6.22.0",
|
"babel-helper-replace-supers": "^6.23.0",
|
||||||
"babel-template": "^6.22.0",
|
"babel-template": "^6.23.0",
|
||||||
"babel-traverse": "^6.22.0",
|
"babel-traverse": "^6.23.0",
|
||||||
"babel-helper-define-map": "^6.22.0",
|
"babel-helper-define-map": "^6.23.0",
|
||||||
"babel-messages": "^6.22.0",
|
"babel-messages": "^6.23.0",
|
||||||
"babel-types": "^6.22.0"
|
"babel-types": "^6.23.0"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"babel-plugin"
|
"babel-plugin"
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-plugin-transform-es2015-destructuring",
|
"name": "babel-plugin-transform-es2015-destructuring",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Compile ES2015 destructuring to ES5",
|
"description": "Compile ES2015 destructuring to ES5",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-destructuring",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-destructuring",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-plugin-transform-es2015-for-of",
|
"name": "babel-plugin-transform-es2015-for-of",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Compile ES2015 for...of to ES5",
|
"description": "Compile ES2015 for...of to ES5",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-for-of",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-for-of",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@ -135,9 +135,8 @@ export default function ({ messages, template, types: t }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function loose(path, file) {
|
function loose(path, file) {
|
||||||
const { node, scope } = path;
|
const { node, scope, parent } = path;
|
||||||
|
const { left } = node;
|
||||||
const left = node.left;
|
|
||||||
let declar, id;
|
let declar, id;
|
||||||
|
|
||||||
if (t.isIdentifier(left) || t.isPattern(left) || t.isMemberExpression(left)) {
|
if (t.isIdentifier(left) || t.isPattern(left) || t.isMemberExpression(left)) {
|
||||||
@ -171,10 +170,17 @@ export default function ({ messages, template, types: t }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
const isLabeledParent = t.isLabeledStatement(parent);
|
||||||
|
let labeled;
|
||||||
|
|
||||||
|
if (isLabeledParent) {
|
||||||
|
labeled = t.labeledStatement(parent.label, loop);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
replaceParent: isLabeledParent,
|
||||||
declar: declar,
|
declar: declar,
|
||||||
node: loop,
|
node: labeled || loop,
|
||||||
loop: loop
|
loop: loop
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,5 @@
|
|||||||
|
b: for (let c of d()) {
|
||||||
|
for (let e of f()) {
|
||||||
|
continue b;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
b: for (var _iterator = d(), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
||||||
|
var _ref;
|
||||||
|
|
||||||
|
if (_isArray) {
|
||||||
|
if (_i >= _iterator.length) break;
|
||||||
|
_ref = _iterator[_i++];
|
||||||
|
} else {
|
||||||
|
_i = _iterator.next();
|
||||||
|
if (_i.done) break;
|
||||||
|
_ref = _i.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
let c = _ref;
|
||||||
|
|
||||||
|
for (var _iterator2 = f(), _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
|
||||||
|
var _ref2;
|
||||||
|
|
||||||
|
if (_isArray2) {
|
||||||
|
if (_i2 >= _iterator2.length) break;
|
||||||
|
_ref2 = _iterator2[_i2++];
|
||||||
|
} else {
|
||||||
|
_i2 = _iterator2.next();
|
||||||
|
if (_i2.done) break;
|
||||||
|
_ref2 = _i2.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
let e = _ref2;
|
||||||
|
|
||||||
|
continue b;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-plugin-transform-es2015-modules-commonjs",
|
"name": "babel-plugin-transform-es2015-modules-commonjs",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "This plugin transforms ES2015 modules to CommonJS",
|
"description": "This plugin transforms ES2015 modules to CommonJS",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-modules-commonjs",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-modules-commonjs",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-types": "^6.22.0",
|
"babel-types": "^6.23.0",
|
||||||
"babel-template": "^6.22.0",
|
"babel-template": "^6.23.0",
|
||||||
"babel-plugin-transform-strict-mode": "^6.22.0"
|
"babel-plugin-transform-strict-mode": "^6.22.0"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-plugin-transform-es2015-modules-systemjs",
|
"name": "babel-plugin-transform-es2015-modules-systemjs",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "This plugin transforms ES2015 modules to SystemJS",
|
"description": "This plugin transforms ES2015 modules to SystemJS",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-modules-systemjs",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-modules-systemjs",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-template": "^6.22.0",
|
"babel-template": "^6.23.0",
|
||||||
"babel-helper-hoist-variables": "^6.22.0"
|
"babel-helper-hoist-variables": "^6.22.0"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-plugin-transform-es2015-modules-umd",
|
"name": "babel-plugin-transform-es2015-modules-umd",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "This plugin transforms ES2015 modules to UMD",
|
"description": "This plugin transforms ES2015 modules to UMD",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-modules-umd",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-modules-umd",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-plugin-transform-es2015-modules-amd": "^6.22.0",
|
"babel-plugin-transform-es2015-modules-amd": "^6.22.0",
|
||||||
"babel-template": "^6.22.0"
|
"babel-template": "^6.23.0"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"babel-plugin"
|
"babel-plugin"
|
||||||
|
|||||||
@ -1,16 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-plugin-transform-es2015-parameters",
|
"name": "babel-plugin-transform-es2015-parameters",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Compile ES2015 default and rest parameters to ES5",
|
"description": "Compile ES2015 default and rest parameters to ES5",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-parameters",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-parameters",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-traverse": "^6.22.0",
|
"babel-traverse": "^6.23.0",
|
||||||
"babel-helper-call-delegate": "^6.22.0",
|
"babel-helper-call-delegate": "^6.22.0",
|
||||||
"babel-helper-get-function-arity": "^6.22.0",
|
"babel-helper-get-function-arity": "^6.22.0",
|
||||||
"babel-template": "^6.22.0",
|
"babel-template": "^6.23.0",
|
||||||
"babel-types": "^6.22.0"
|
"babel-types": "^6.23.0"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"babel-plugin"
|
"babel-plugin"
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-plugin-transform-es2015-typeof-symbol",
|
"name": "babel-plugin-transform-es2015-typeof-symbol",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "This transformer wraps all typeof expressions with a method that replicates native behaviour. (ie. returning “symbol” for symbols)",
|
"description": "This transformer wraps all typeof expressions with a method that replicates native behaviour. (ie. returning “symbol” for symbols)",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-typeof-symbol",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-typeof-symbol",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-plugin-transform-object-rest-spread",
|
"name": "babel-plugin-transform-object-rest-spread",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Compile object rest and spread to ES5",
|
"description": "Compile object rest and spread to ES5",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-object-rest-spread",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-object-rest-spread",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-plugin-transform-proto-to-assign",
|
"name": "babel-plugin-transform-proto-to-assign",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Babel plugin for turning __proto__ into a shallow property clone",
|
"description": "Babel plugin for turning __proto__ into a shallow property clone",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-proto-to-assign",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-proto-to-assign",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-plugin-transform-react-constant-elements",
|
"name": "babel-plugin-transform-react-constant-elements",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Treat React JSX elements as value types and hoist them to the highest scope",
|
"description": "Treat React JSX elements as value types and hoist them to the highest scope",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-react-constant-elements",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-react-constant-elements",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
export default function () {
|
export default function ({ types: t }) {
|
||||||
const immutabilityVisitor = {
|
const immutabilityVisitor = {
|
||||||
enter(path, state) {
|
enter(path, state) {
|
||||||
const stop = () => {
|
const stop = () => {
|
||||||
@ -11,15 +11,39 @@ export default function () {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Elements with refs are not safe to hoist.
|
||||||
if (path.isJSXIdentifier({ name: "ref" }) && path.parentPath.isJSXAttribute({ name: path.node })) {
|
if (path.isJSXIdentifier({ name: "ref" }) && path.parentPath.isJSXAttribute({ name: path.node })) {
|
||||||
return stop();
|
return stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ignore identifiers & JSX expressions.
|
||||||
if (path.isJSXIdentifier() || path.isIdentifier() || path.isJSXMemberExpression()) {
|
if (path.isJSXIdentifier() || path.isIdentifier() || path.isJSXMemberExpression()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!path.isImmutable()) stop();
|
if (!path.isImmutable()) {
|
||||||
|
// If it's not immutable, it may still be a pure expression, such as string concatenation.
|
||||||
|
// It is still safe to hoist that, so long as its result is immutable.
|
||||||
|
// If not, it is not safe to replace as mutable values (like objects) could be mutated after render.
|
||||||
|
// https://github.com/facebook/react/issues/3226
|
||||||
|
if (path.isPure()) {
|
||||||
|
const expressionResult = path.evaluate();
|
||||||
|
if (expressionResult.confident) {
|
||||||
|
// We know the result; check its mutability.
|
||||||
|
const { value } = expressionResult;
|
||||||
|
const isMutable = (value && typeof value === "object") || (typeof value === "function");
|
||||||
|
if (!isMutable) {
|
||||||
|
// It evaluated to an immutable value, so we can hoist it.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (t.isIdentifier(expressionResult.deopt)) {
|
||||||
|
// It's safe to hoist here if the deopt reason is an identifier (e.g. func param).
|
||||||
|
// The hoister will take care of how high up it can be hoisted.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,18 +1,19 @@
|
|||||||
var _ref = <p>Parent</p>;
|
|
||||||
|
|
||||||
var _ref2 = <div>child</div>;
|
var _ref2 = <div>child</div>;
|
||||||
|
|
||||||
|
var _ref3 = <p>Parent</p>;
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
class App extends React.Component {
|
class App extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
return <div>
|
return _ref;
|
||||||
{_ref}
|
|
||||||
<AppItem />
|
|
||||||
</div>;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const AppItem = () => {
|
const AppItem = () => {
|
||||||
return _ref2;
|
return _ref2;
|
||||||
};
|
},
|
||||||
|
_ref = <div>
|
||||||
|
{_ref3}
|
||||||
|
<AppItem />
|
||||||
|
</div>;
|
||||||
});
|
});
|
||||||
@ -1,16 +1,14 @@
|
|||||||
var _ref = <p>Parent</p>;
|
|
||||||
|
|
||||||
export default class App extends React.Component {
|
export default class App extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
return <div>
|
return _ref;
|
||||||
{_ref}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const _ref2 = <div>child</div>,
|
||||||
|
AppItem = () => {
|
||||||
|
return _ref2;
|
||||||
|
},
|
||||||
|
_ref = <div>
|
||||||
|
<p>Parent</p>
|
||||||
<AppItem />
|
<AppItem />
|
||||||
</div>;
|
</div>;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ref2 = <div>child</div>;
|
|
||||||
|
|
||||||
const AppItem = () => {
|
|
||||||
return _ref2;
|
|
||||||
};
|
|
||||||
|
|||||||
@ -0,0 +1,15 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
const Parent = ({}) => (
|
||||||
|
<div className="parent">
|
||||||
|
<Child/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
export default Parent;
|
||||||
|
|
||||||
|
let Child = () => (
|
||||||
|
<div className="child">
|
||||||
|
ChildTextContent
|
||||||
|
</div>
|
||||||
|
);
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
const Parent = ({}) => _ref;
|
||||||
|
|
||||||
|
export default Parent;
|
||||||
|
|
||||||
|
let _ref2 = <div className="child">
|
||||||
|
ChildTextContent
|
||||||
|
</div>,
|
||||||
|
Child = () => _ref2,
|
||||||
|
_ref = <div className="parent">
|
||||||
|
<Child />
|
||||||
|
</div>;
|
||||||
@ -8,8 +8,9 @@ function render() {
|
|||||||
|
|
||||||
function render() {
|
function render() {
|
||||||
const bar = "bar",
|
const bar = "bar",
|
||||||
renderFoo = () => <foo bar={bar} baz={baz} />,
|
renderFoo = () => _ref2,
|
||||||
baz = "baz";
|
baz = "baz",
|
||||||
|
_ref2 = <foo bar={bar} baz={baz} />;
|
||||||
|
|
||||||
return renderFoo();
|
return renderFoo();
|
||||||
}
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
const HOC = component => component;
|
||||||
|
|
||||||
|
const Parent = ({}) => (
|
||||||
|
<div className="parent">
|
||||||
|
<Child/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
export default Parent;
|
||||||
|
|
||||||
|
let Child = () => (
|
||||||
|
<div className="child">
|
||||||
|
ChildTextContent
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
Child = HOC(Child);
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
const HOC = component => component;
|
||||||
|
|
||||||
|
const Parent = ({}) => _ref;
|
||||||
|
|
||||||
|
export default Parent;
|
||||||
|
|
||||||
|
var _ref2 = <div className="child">
|
||||||
|
ChildTextContent
|
||||||
|
</div>;
|
||||||
|
|
||||||
|
let Child = () => _ref2;
|
||||||
|
Child = HOC(Child);
|
||||||
|
|
||||||
|
var _ref = <div className="parent">
|
||||||
|
<Child />
|
||||||
|
</div>;
|
||||||
@ -1,16 +1,10 @@
|
|||||||
function render(flag) {
|
function render(flag) {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
var _ret = function () {
|
|
||||||
var bar = "bar";
|
var bar = "bar";
|
||||||
|
|
||||||
[].map(() => bar);
|
[].map(() => bar);
|
||||||
|
|
||||||
return {
|
return <foo bar={bar} />;
|
||||||
v: <foo bar={bar} />
|
|
||||||
};
|
|
||||||
}();
|
|
||||||
|
|
||||||
if (typeof _ret === "object") return _ret.v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -0,0 +1,4 @@
|
|||||||
|
function render() {
|
||||||
|
this.component = "div";
|
||||||
|
return () => <this.component />;
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
function render() {
|
||||||
|
this.component = "div";
|
||||||
|
|
||||||
|
var _ref = <this.component />;
|
||||||
|
|
||||||
|
return () => _ref;
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
class Component extends React.Component {
|
||||||
|
subComponent = () => <span>Sub Component</span>
|
||||||
|
|
||||||
|
render = () => <this.subComponent />
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
var _ref = <span>Sub Component</span>;
|
||||||
|
|
||||||
|
class Component extends React.Component {
|
||||||
|
constructor(...args) {
|
||||||
|
var _temp;
|
||||||
|
|
||||||
|
var _ref2 = <this.subComponent />;
|
||||||
|
|
||||||
|
return _temp = super(...args), this.subComponent = () => _ref, this.render = () => _ref2, _temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["syntax-jsx", "transform-react-constant-elements", "transform-class-properties"]
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
const els = {
|
||||||
|
subComponent: () => <span>Sub Component</span>
|
||||||
|
};
|
||||||
|
class Component extends React.Component {
|
||||||
|
render = () => <els.subComponent />
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
var _ref = <span>Sub Component</span>;
|
||||||
|
|
||||||
|
const els = {
|
||||||
|
subComponent: () => _ref
|
||||||
|
};
|
||||||
|
|
||||||
|
var _ref2 = <els.subComponent />;
|
||||||
|
|
||||||
|
class Component extends React.Component {
|
||||||
|
constructor(...args) {
|
||||||
|
var _temp;
|
||||||
|
|
||||||
|
return _temp = super(...args), this.render = () => _ref2, _temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": ["syntax-jsx", "transform-react-constant-elements", "transform-class-properties"]
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
// https://github.com/facebook/react/issues/3226
|
||||||
|
// Not safe to reuse because it is mutable
|
||||||
|
function render() {
|
||||||
|
return <div style={{ width: 100 }} />;
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
// https://github.com/facebook/react/issues/3226
|
||||||
|
// Not safe to reuse because it is mutable
|
||||||
|
function render() {
|
||||||
|
return <div style={{ width: 100 }} />;
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
function render(offset) {
|
||||||
|
return function () {
|
||||||
|
return <div tabIndex={offset + 1} />;
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
function render(offset) {
|
||||||
|
var _ref = <div tabIndex={offset + 1} />;
|
||||||
|
|
||||||
|
return function () {
|
||||||
|
return _ref;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
const OFFSET = 3;
|
||||||
|
|
||||||
|
var Foo = React.createClass({
|
||||||
|
render: function () {
|
||||||
|
return (
|
||||||
|
<div tabIndex={OFFSET + 1} />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
const OFFSET = 3;
|
||||||
|
|
||||||
|
var _ref = <div tabIndex={OFFSET + 1} />;
|
||||||
|
|
||||||
|
var Foo = React.createClass({
|
||||||
|
render: function () {
|
||||||
|
return _ref;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
var Foo = React.createClass({
|
||||||
|
render: function () {
|
||||||
|
return (
|
||||||
|
<div data-text={
|
||||||
|
"Some text, " +
|
||||||
|
"and some more too."
|
||||||
|
} />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
var _ref = <div data-text={"Some text, " + "and some more too."} />;
|
||||||
|
|
||||||
|
var Foo = React.createClass({
|
||||||
|
render: function () {
|
||||||
|
return _ref;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-plugin-transform-react-display-name",
|
"name": "babel-plugin-transform-react-display-name",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Add displayName to React.createClass calls",
|
"description": "Add displayName to React.createClass calls",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-react-display-name",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-react-display-name",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-plugin-transform-react-jsx",
|
"name": "babel-plugin-transform-react-jsx",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Turn JSX into React function calls",
|
"description": "Turn JSX into React function calls",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-react-jsx",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-react-jsx",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -9,7 +9,7 @@
|
|||||||
"babel-plugin"
|
"babel-plugin"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-helper-builder-react-jsx": "^6.22.0",
|
"babel-helper-builder-react-jsx": "^6.23.0",
|
||||||
"babel-plugin-syntax-jsx": "^6.8.0"
|
"babel-plugin-syntax-jsx": "^6.8.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-plugin-transform-runtime",
|
"name": "babel-plugin-transform-runtime",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Externalise references to helpers and builtins, automatically polyfilling your code without polluting globals",
|
"description": "Externalise references to helpers and builtins, automatically polyfilling your code without polluting globals",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-runtime",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-runtime",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-polyfill",
|
"name": "babel-polyfill",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Provides polyfills necessary for a full ES2015+ environment",
|
"description": "Provides polyfills necessary for a full ES2015+ environment",
|
||||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||||
"homepage": "https://babeljs.io/",
|
"homepage": "https://babeljs.io/",
|
||||||
|
|||||||
3
packages/babel-preset-flow/.npmignore
Normal file
3
packages/babel-preset-flow/.npmignore
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
src
|
||||||
|
test
|
||||||
|
node_modules
|
||||||
53
packages/babel-preset-flow/README.md
Normal file
53
packages/babel-preset-flow/README.md
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# babel-preset-flow
|
||||||
|
|
||||||
|
> Babel preset for all Flow plugins.
|
||||||
|
|
||||||
|
This preset includes the following plugins:
|
||||||
|
|
||||||
|
- [transform-flow-strip-types](https://babeljs.io/docs/plugins/transform-flow-strip-types/)
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
**In**
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
function foo(one: any, two: number, three?): string {}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Out**
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
function foo(one, two, three) {}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install --save-dev babel-preset-flow
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Via `.babelrc` (Recommended)
|
||||||
|
|
||||||
|
**.babelrc**
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"presets": ["flow"]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Via CLI
|
||||||
|
|
||||||
|
```sh
|
||||||
|
babel --presets flow script.js
|
||||||
|
```
|
||||||
|
|
||||||
|
### Via Node API
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
require("babel-core").transform("code", {
|
||||||
|
presets: ["flow"]
|
||||||
|
});
|
||||||
|
```
|
||||||
18
packages/babel-preset-flow/package.json
Normal file
18
packages/babel-preset-flow/package.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"name": "babel-preset-flow",
|
||||||
|
"version": "6.23.0",
|
||||||
|
"description": "Babel preset for all Flow plugins.",
|
||||||
|
"author": "James Kyle <me@thejameskyle.com>",
|
||||||
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-preset-flow",
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "lib/index.js",
|
||||||
|
"keywords": [
|
||||||
|
"babel-preset",
|
||||||
|
"flowtype",
|
||||||
|
"flow",
|
||||||
|
"types"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"babel-plugin-transform-flow-strip-types": "^6.22.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
7
packages/babel-preset-flow/src/index.js
Normal file
7
packages/babel-preset-flow/src/index.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import transformFlowStripTypes from "babel-plugin-transform-flow-strip-types";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
plugins: [
|
||||||
|
transformFlowStripTypes
|
||||||
|
]
|
||||||
|
};
|
||||||
@ -2,11 +2,10 @@
|
|||||||
|
|
||||||
> Babel preset for all React plugins.
|
> Babel preset for all React plugins.
|
||||||
|
|
||||||
This preset includes the following plugins:
|
This preset includes the following plugins/presets:
|
||||||
|
|
||||||
- [syntax-flow](https://babeljs.io/docs/plugins/syntax-flow/)
|
- [preset-flow](https://babeljs.io/docs/plugins/preset-flow/)
|
||||||
- [syntax-jsx](https://babeljs.io/docs/plugins/syntax-jsx/)
|
- [syntax-jsx](https://babeljs.io/docs/plugins/syntax-jsx/)
|
||||||
- [transform-flow-strip-types](https://babeljs.io/docs/plugins/transform-flow-strip-types/)
|
|
||||||
- [transform-react-jsx](https://babeljs.io/docs/plugins/transform-react-jsx/)
|
- [transform-react-jsx](https://babeljs.io/docs/plugins/transform-react-jsx/)
|
||||||
- [transform-react-display-name](https://babeljs.io/docs/plugins/transform-react-display-name/)
|
- [transform-react-display-name](https://babeljs.io/docs/plugins/transform-react-display-name/)
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-preset-react",
|
"name": "babel-preset-react",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Babel preset for all React plugins.",
|
"description": "Babel preset for all React plugins.",
|
||||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||||
"homepage": "https://babeljs.io/",
|
"homepage": "https://babeljs.io/",
|
||||||
@ -8,11 +8,10 @@
|
|||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-preset-react",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-preset-react",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-plugin-syntax-flow": "^6.3.13",
|
"babel-preset-flow": "^6.23.0",
|
||||||
"babel-plugin-syntax-jsx": "^6.3.13",
|
"babel-plugin-syntax-jsx": "^6.3.13",
|
||||||
"babel-plugin-transform-flow-strip-types": "^6.22.0",
|
"babel-plugin-transform-react-display-name": "^6.23.0",
|
||||||
"babel-plugin-transform-react-display-name": "^6.22.0",
|
"babel-plugin-transform-react-jsx": "^6.23.0",
|
||||||
"babel-plugin-transform-react-jsx": "^6.22.0",
|
|
||||||
"babel-plugin-transform-react-jsx-source": "^6.22.0",
|
"babel-plugin-transform-react-jsx-source": "^6.22.0",
|
||||||
"babel-plugin-transform-react-jsx-self": "^6.22.0"
|
"babel-plugin-transform-react-jsx-self": "^6.22.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
|
import presetFlow from "babel-preset-flow";
|
||||||
import transformReactJSX from "babel-plugin-transform-react-jsx";
|
import transformReactJSX from "babel-plugin-transform-react-jsx";
|
||||||
import transformFlowStripTypes from "babel-plugin-transform-flow-strip-types";
|
|
||||||
import transformSyntaxFlow from "babel-plugin-syntax-flow";
|
|
||||||
import transformSyntaxJSX from "babel-plugin-syntax-jsx";
|
import transformSyntaxJSX from "babel-plugin-syntax-jsx";
|
||||||
import transformReactDisplayName from "babel-plugin-transform-react-display-name";
|
import transformReactDisplayName from "babel-plugin-transform-react-display-name";
|
||||||
|
|
||||||
@ -9,10 +8,11 @@ import transformReactDisplayName from "babel-plugin-transform-react-display-name
|
|||||||
// import transformReactJSXSelf from "babel-plugin-transform-react-jsx-self";
|
// import transformReactJSXSelf from "babel-plugin-transform-react-jsx-self";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
presets: [
|
||||||
|
presetFlow
|
||||||
|
],
|
||||||
plugins: [
|
plugins: [
|
||||||
transformReactJSX,
|
transformReactJSX,
|
||||||
transformFlowStripTypes,
|
|
||||||
transformSyntaxFlow,
|
|
||||||
transformSyntaxJSX,
|
transformSyntaxJSX,
|
||||||
transformReactDisplayName
|
transformReactDisplayName
|
||||||
],
|
],
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-register",
|
"name": "babel-register",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "babel require hook",
|
"description": "babel require hook",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-register",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-register",
|
||||||
@ -8,7 +8,7 @@
|
|||||||
"main": "lib/node.js",
|
"main": "lib/node.js",
|
||||||
"browser": "lib/browser.js",
|
"browser": "lib/browser.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-core": "^6.22.0",
|
"babel-core": "^6.23.0",
|
||||||
"core-js": "^2.4.0",
|
"core-js": "^2.4.0",
|
||||||
"home-or-tmp": "^3.0.0",
|
"home-or-tmp": "^3.0.0",
|
||||||
"lodash": "^4.2.0",
|
"lodash": "^4.2.0",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-template",
|
"name": "babel-template",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Generate an AST from a string template.",
|
"description": "Generate an AST from a string template.",
|
||||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||||
"homepage": "https://babeljs.io/",
|
"homepage": "https://babeljs.io/",
|
||||||
@ -9,8 +9,8 @@
|
|||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babylon": "^6.11.0",
|
"babylon": "^6.11.0",
|
||||||
"babel-traverse": "^6.22.0",
|
"babel-traverse": "^6.23.0",
|
||||||
"babel-types": "^6.22.0",
|
"babel-types": "^6.23.0",
|
||||||
"lodash": "^4.2.0"
|
"lodash": "^4.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-traverse",
|
"name": "babel-traverse",
|
||||||
"version": "6.22.1",
|
"version": "6.23.1",
|
||||||
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",
|
"description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes",
|
||||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||||
"homepage": "https://babeljs.io/",
|
"homepage": "https://babeljs.io/",
|
||||||
@ -9,8 +9,8 @@
|
|||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-code-frame": "^6.22.0",
|
"babel-code-frame": "^6.22.0",
|
||||||
"babel-messages": "^6.22.0",
|
"babel-messages": "^6.23.0",
|
||||||
"babel-types": "^6.22.0",
|
"babel-types": "^6.23.0",
|
||||||
"babylon": "^6.15.0",
|
"babylon": "^6.15.0",
|
||||||
"debug": "^2.2.0",
|
"debug": "^2.2.0",
|
||||||
"globals": "^9.0.0",
|
"globals": "^9.0.0",
|
||||||
@ -18,6 +18,6 @@
|
|||||||
"lodash": "^4.2.0"
|
"lodash": "^4.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-generator": "^6.22.0"
|
"babel-generator": "^6.23.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,11 +2,27 @@ import { react } from "babel-types";
|
|||||||
import * as t from "babel-types";
|
import * as t from "babel-types";
|
||||||
|
|
||||||
const referenceVisitor = {
|
const referenceVisitor = {
|
||||||
|
// This visitor looks for bindings to establish a topmost scope for hoisting.
|
||||||
ReferencedIdentifier(path, state) {
|
ReferencedIdentifier(path, state) {
|
||||||
if (path.isJSXIdentifier() && react.isCompatTag(path.node.name)) {
|
// Don't hoist regular JSX identifiers ('div', 'span', etc).
|
||||||
|
// We do have to consider member expressions for hoisting (e.g. `this.component`)
|
||||||
|
if (
|
||||||
|
path.isJSXIdentifier() &&
|
||||||
|
react.isCompatTag(path.node.name) &&
|
||||||
|
!path.parentPath.isJSXMemberExpression()
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the identifier refers to `this`, we need to break on the closest non-arrow scope.
|
||||||
|
if (path.node.name === "this") {
|
||||||
|
let scope = path.scope;
|
||||||
|
do {
|
||||||
|
if (scope.path.isFunction() && !scope.path.isArrowFunctionExpression()) break;
|
||||||
|
} while (scope = scope.parent);
|
||||||
|
if (scope) state.breakOnScopePaths.push(scope.path);
|
||||||
|
}
|
||||||
|
|
||||||
// direct references that we need to track to hoist this to the highest scope we can
|
// direct references that we need to track to hoist this to the highest scope we can
|
||||||
const binding = path.scope.getBinding(path.node.name);
|
const binding = path.scope.getBinding(path.node.name);
|
||||||
if (!binding) return;
|
if (!binding) return;
|
||||||
@ -15,25 +31,27 @@ const referenceVisitor = {
|
|||||||
// eg. it's in a closure etc
|
// eg. it's in a closure etc
|
||||||
if (binding !== state.scope.getBinding(path.node.name)) return;
|
if (binding !== state.scope.getBinding(path.node.name)) return;
|
||||||
|
|
||||||
if (binding.constant) {
|
|
||||||
state.bindings[path.node.name] = binding;
|
state.bindings[path.node.name] = binding;
|
||||||
} else {
|
|
||||||
for (const violationPath of (binding.constantViolations: Array)) {
|
|
||||||
state.breakOnScopePaths = state.breakOnScopePaths.concat(violationPath.getAncestry());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default class PathHoister {
|
export default class PathHoister {
|
||||||
constructor(path, scope) {
|
constructor(path, scope) {
|
||||||
|
// Storage for scopes we can't hoist above.
|
||||||
this.breakOnScopePaths = [];
|
this.breakOnScopePaths = [];
|
||||||
|
// Storage for bindings that may affect what path we can hoist to.
|
||||||
this.bindings = {};
|
this.bindings = {};
|
||||||
|
// Storage for eligible scopes.
|
||||||
this.scopes = [];
|
this.scopes = [];
|
||||||
|
// Our original scope and path.
|
||||||
this.scope = scope;
|
this.scope = scope;
|
||||||
this.path = path;
|
this.path = path;
|
||||||
|
// By default, we attach as far up as we can; but if we're trying
|
||||||
|
// to avoid referencing a binding, we may have to go after.
|
||||||
|
this.attachAfter = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A scope is compatible if all required bindings are reachable.
|
||||||
isCompatibleScope(scope) {
|
isCompatibleScope(scope) {
|
||||||
for (const key in this.bindings) {
|
for (const key in this.bindings) {
|
||||||
const binding = this.bindings[key];
|
const binding = this.bindings[key];
|
||||||
@ -45,6 +63,7 @@ export default class PathHoister {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Look through all scopes and push compatible ones.
|
||||||
getCompatibleScopes() {
|
getCompatibleScopes() {
|
||||||
let scope = this.path.scope;
|
let scope = this.path.scope;
|
||||||
do {
|
do {
|
||||||
@ -54,6 +73,7 @@ export default class PathHoister {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// deopt: These scopes are set in the visitor on const violations
|
||||||
if (this.breakOnScopePaths.indexOf(scope.path) >= 0) {
|
if (this.breakOnScopePaths.indexOf(scope.path) >= 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -61,7 +81,7 @@ export default class PathHoister {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getAttachmentPath() {
|
getAttachmentPath() {
|
||||||
const path = this._getAttachmentPath();
|
let path = this._getAttachmentPath();
|
||||||
if (!path) return;
|
if (!path) return;
|
||||||
|
|
||||||
let targetScope = path.scope;
|
let targetScope = path.scope;
|
||||||
@ -82,8 +102,18 @@ export default class PathHoister {
|
|||||||
// allow parameter references
|
// allow parameter references
|
||||||
if (binding.kind === "param") continue;
|
if (binding.kind === "param") continue;
|
||||||
|
|
||||||
// if this binding appears after our attachment point then don't hoist it
|
// if this binding appears after our attachment point, then we move after it.
|
||||||
if (this.getAttachmentParentForPath(binding.path).key > path.key) return;
|
if (this.getAttachmentParentForPath(binding.path).key > path.key) {
|
||||||
|
this.attachAfter = true;
|
||||||
|
path = binding.path;
|
||||||
|
|
||||||
|
// We also move past any constant violations.
|
||||||
|
for (const violationPath of (binding.constantViolations: Array)) {
|
||||||
|
if (this.getAttachmentParentForPath(violationPath).key > path.key) {
|
||||||
|
path = violationPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,11 +124,12 @@ export default class PathHoister {
|
|||||||
const scopes = this.scopes;
|
const scopes = this.scopes;
|
||||||
|
|
||||||
const scope = scopes.pop();
|
const scope = scopes.pop();
|
||||||
|
// deopt: no compatible scopes
|
||||||
if (!scope) return;
|
if (!scope) return;
|
||||||
|
|
||||||
if (scope.path.isFunction()) {
|
if (scope.path.isFunction()) {
|
||||||
if (this.hasOwnParamBindings(scope)) {
|
if (this.hasOwnParamBindings(scope)) {
|
||||||
// should ignore this scope since it's ourselves
|
// deopt: should ignore this scope since it's ourselves
|
||||||
if (this.scope === scope) return;
|
if (this.scope === scope) return;
|
||||||
|
|
||||||
// needs to be attached to the body
|
// needs to be attached to the body
|
||||||
@ -117,26 +148,30 @@ export default class PathHoister {
|
|||||||
if (scope) return this.getAttachmentParentForPath(scope.path);
|
if (scope) return this.getAttachmentParentForPath(scope.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Find an attachment for this path.
|
||||||
getAttachmentParentForPath(path) {
|
getAttachmentParentForPath(path) {
|
||||||
do {
|
do {
|
||||||
if (!path.parentPath ||
|
if (
|
||||||
|
// Beginning of the scope
|
||||||
|
!path.parentPath ||
|
||||||
|
// Has siblings and is a statement
|
||||||
(Array.isArray(path.container) && path.isStatement()) ||
|
(Array.isArray(path.container) && path.isStatement()) ||
|
||||||
(
|
// Is part of multiple var declarations
|
||||||
path.isVariableDeclarator() &&
|
(path.isVariableDeclarator() &&
|
||||||
path.parentPath.node !== null &&
|
path.parentPath.node !== null &&
|
||||||
path.parentPath.node.declarations.length > 1
|
path.parentPath.node.declarations.length > 1))
|
||||||
)
|
|
||||||
)
|
|
||||||
return path;
|
return path;
|
||||||
} while ((path = path.parentPath));
|
} while ((path = path.parentPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns true if a scope has param bindings.
|
||||||
hasOwnParamBindings(scope) {
|
hasOwnParamBindings(scope) {
|
||||||
for (const name in this.bindings) {
|
for (const name in this.bindings) {
|
||||||
if (!scope.hasOwnBinding(name)) continue;
|
if (!scope.hasOwnBinding(name)) continue;
|
||||||
|
|
||||||
const binding = this.bindings[name];
|
const binding = this.bindings[name];
|
||||||
if (binding.kind === "param") return true;
|
// Ensure constant; without it we could place behind a reassignment
|
||||||
|
if (binding.kind === "param" && binding.constant) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -161,7 +196,8 @@ export default class PathHoister {
|
|||||||
let uid = attachTo.scope.generateUidIdentifier("ref");
|
let uid = attachTo.scope.generateUidIdentifier("ref");
|
||||||
const declarator = t.variableDeclarator(uid, this.path.node);
|
const declarator = t.variableDeclarator(uid, this.path.node);
|
||||||
|
|
||||||
attachTo.insertBefore([
|
const insertFn = this.attachAfter ? "insertAfter" : "insertBefore";
|
||||||
|
attachTo[insertFn]([
|
||||||
attachTo.isVariableDeclarator() ? declarator : t.variableDeclaration("var", [declarator])
|
attachTo.isVariableDeclarator() ? declarator : t.variableDeclaration("var", [declarator])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@ -930,6 +930,7 @@ Aliases: `ModuleSpecifier`
|
|||||||
|
|
||||||
- `local`: `Identifier` (required)
|
- `local`: `Identifier` (required)
|
||||||
- `imported`: `Identifier` (required)
|
- `imported`: `Identifier` (required)
|
||||||
|
- `importKind`: `null | 'type' | 'typeof'` (default: `null`)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "babel-types",
|
"name": "babel-types",
|
||||||
"version": "6.22.0",
|
"version": "6.23.0",
|
||||||
"description": "Babel Types is a Lodash-esque utility library for AST nodes",
|
"description": "Babel Types is a Lodash-esque utility library for AST nodes",
|
||||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||||
"homepage": "https://babeljs.io/",
|
"homepage": "https://babeljs.io/",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user