Date: Fri, 10 Mar 2017 06:49:28 -0800
Subject: [PATCH 19/37] Use absolute paths in Babel's CONTRIBUTING.md (#5431)
---
CONTRIBUTING.md | 42 +++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 340292b2037b..f979d6d797bd 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -2,7 +2,7 @@
----
-
+
Setup
|
Running linting/tests
@@ -27,7 +27,7 @@ Contributions are always welcome, no matter how large or small.
- If you aren't just making a documentation change, you'll probably want to learn a bit about a few topics.
- [ASTs](https://en.wikipedia.org/wiki/Abstract_syntax_tree) (Abstract Syntax Tree): The Babel AST [spec](https://github.com/babel/babylon/blob/master/ast/spec.md) is a bit different from [ESTree](https://github.com/estree/estree). The differences are listed [here](https://github.com/babel/babylon#output).
- - This repository's [`/doc`](/doc) directory for notes on Babel's internals
+ - This repository's [`/doc`](https://github.com/babel/babel/tree/master/doc) directory for notes on Babel's internals
- Check out [the Babel Plugin Handbook](https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#babel-plugin-handbook) - core plugins are written the same way as any other plugin!
- Check out [AST Explorer](http://astexplorer.net/#/scUfOmVOG5) to learn more about ASTs or make your own plugin in the browser
- When you feel ready to finally jump into the babel source code a good start is to look out for issues which are labeled with [help-wanted](https://github.com/babel/babel/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) and/or [beginner-friendly](https://github.com/babel/babel/issues?q=is%3Aissue+is%3Aopen+label%3A%22beginner-friendly%22).
@@ -44,7 +44,7 @@ Babel is built for node 0.10 and up but we develop using node 6. Make sure you a
You can check this with `node -v` and `npm -v`.
-#### Setup
+### Setup
```sh
$ git clone https://github.com/babel/babel
@@ -74,7 +74,7 @@ If you wish to build a copy of Babel for distribution, then run:
$ make build-dist
```
-#### Running linting/tests
+### Running linting/tests
You can run lint via:
@@ -105,7 +105,7 @@ $ make test-only
Most likely you'll want to focus in on a specific issue.
-To run tests for a specific package in [packages](/packages), you can use the `TEST_ONLY` environment variable:
+To run tests for a specific package in [packages](https://github.com/babel/babel/tree/master/packages), you can use the `TEST_ONLY` environment variable:
```sh
$ TEST_ONLY=babel-cli make test
@@ -130,27 +130,27 @@ $ BABEL_ENV=cov make build
$ ./scripts/test-cov.sh
```
-#### Writing tests
+### Writing tests
-Most packages in [`/packages`](/packages) have a `test` folder, however some tests might be in other packages or in [`/packages/babel-core`](/packages/babel-core/test/fixtures).
+Most packages in [`/packages`](https://github.com/babel/babel/tree/master/packages) have a `test` folder, however some tests might be in other packages or in [`/packages/babel-core`](https://github.com/babel/babel/tree/master/packages/babel-core/test/fixtures).
-##### `babel-plugin-x`
+#### `babel-plugin-x`
All the Babel plugins (and other packages) that have a `/test/fixtures` are written in a similar way.
-For example, in [`babel-plugin-transform-exponentiation-operator/test`](/packages/babel-plugin-transform-exponentiation-operator/test):
+For example, in [`babel-plugin-transform-exponentiation-operator/test`](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-exponentiation-operator/test):
-- There is an `index.js` file. It imports our [test helper](/packages/babel-helper-plugin-test-runner). (You don't have to worry about this).
-- There can be multiple folders under [`/fixtures`](/packages/babel-plugin-transform-exponentiation-operator/test/fixtures)
- - There is an [`options.json`](/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/options.json) file whose function is similar to a `.babelrc` file, allowing you to pass in the plugins and settings you need for your tests.
+- There is an `index.js` file. It imports our [test helper](https://github.com/babel/babel/tree/master/packages/babel-helper-plugin-test-runner). (You don't have to worry about this).
+- There can be multiple folders under [`/fixtures`](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures)
+ - There is an [`options.json`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/options.json) file whose function is similar to a `.babelrc` file, allowing you to pass in the plugins and settings you need for your tests.
- For this test, we only need the relevant plugin, so it's just `{ "plugins": ["transform-exponentiation-operator"] }`.
- If necessary, you can have an `options.json` with different options in each subfolder.
- In each subfolder, you can organize your directory structure by categories of tests. (Example: these folders can be named after the feature you are testing or can reference the issue number they fix)
- Generally, there are two kinds of tests for plugins
- - The first is a simple test of the input and output produced by running Babel on some code. We do this by creating an [`actual.js`](packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/binary/actual.js) file and an [`expected.js`](/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/binary/expected.js) file.
+ - The first is a simple test of the input and output produced by running Babel on some code. We do this by creating an [`actual.js`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/binary/actual.js) file and an [`expected.js`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/binary/expected.js) file.
- If you need to expect an error, you can ignore creating the `expected.js` file and pass a new `throws` key to the `options.json` that contains the error string that is created.
- - The second and preferred type is a test that actually evaluates the produced code and asserts that certain properties are true or false. We do this by creating an [`exec.js`](/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/comprehensive/exec.js) file.
+ - The second and preferred type is a test that actually evaluates the produced code and asserts that certain properties are true or false. We do this by creating an [`exec.js`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/comprehensive/exec.js) file.
In an actual/expected test, you simply write out the code you want transformed in `actual.js`.
@@ -183,7 +183,7 @@ If you need to check for an error that is thrown you can add to the `options.jso
}
```
-##### Bootstrapping expected output
+#### Bootstrapping expected output
For both `babel-plugin-x` and `babylon`, you can easily generate an `expected.js`/`expected.json` automatically by just providing `actual.js` and running the tests as you usually would.
@@ -199,7 +199,7 @@ For both `babel-plugin-x` and `babylon`, you can easily generate an `expected.js
- expected.json (will be generated if not created)
```
-#### Debugging code
+### Debugging code
A common approach to debugging JavaScript code is to walk through the code using the [Chrome DevTools](https://developers.google.com/web/tools/chrome-devtools/) debugger.
For illustration purposes, we are going to assume that we need to get a better understanding of [`Generator.generate()`](https://github.com/babel/babel/blob/b5246994b57f06af871be6a63dcc4c6fd41d94d6/packages/babel-generator/src/index.js#L32), which is responsible for generating code for a given AST.
@@ -236,9 +236,9 @@ The debugger starts at the first executed line of code, which is Mocha's first l
Click _Resume script execution_ to jump to the set breakpoint.
Note that the code shown in Chrome DevTools is compiled code and therefore differs.
-#### Internals
+## Internals
- AST spec ([babylon/ast/spec.md](https://github.com/babel/babylon/blob/master/ast/spec.md))
-- Versioning ([doc/design/versioning.md](./doc/design/versioning.md))
-- Monorepo ([doc/design/monorepo.md](./doc/design/monorepo.md))
-- Compiler environment support ([doc/design/compiler-environment-support.md](./doc/design/compiler-environment-support.md))
-- Compiler assumptions ([doc/design/compiler-assumptions.md](./doc/design/compiler-assumptions.md))
+- Versioning ([doc/design/versioning.md](https://github.com/babel/babel/blob/master/doc/design/versioning.md)
+- Monorepo ([doc/design/monorepo.md](https://github.com/babel/babel/blob/master/doc/design/monorepo.md))
+- Compiler environment support ([doc/design/compiler-environment-support.md](https://github.com/babel/babel/blob/master/doc/design/compiler-environment-support.md))
+- Compiler assumptions ([doc/design/compiler-assumptions.md](https://github.com/babel/babel/blob/master/doc/design/compiler-assumptions.md))
From b78fc9b4d0080babaa04eff9f56ce78cfaccf55b Mon Sep 17 00:00:00 2001
From: Henry Zhu
Date: Sun, 12 Mar 2017 21:40:38 -0400
Subject: [PATCH 20/37] Keep parentheses for logical expression when in await
expression (fix #5428) (#5433) (#5453)
---
packages/babel-generator/src/node/parentheses.js | 3 ++-
.../test/fixtures/parentheses/await-expression/actual.js | 1 +
.../test/fixtures/parentheses/await-expression/expected.js | 1 +
3 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/packages/babel-generator/src/node/parentheses.js b/packages/babel-generator/src/node/parentheses.js
index 5cf16c232490..f2ba48d32073 100644
--- a/packages/babel-generator/src/node/parentheses.js
+++ b/packages/babel-generator/src/node/parentheses.js
@@ -50,7 +50,8 @@ export function Binary(node: Object, parent: Object): boolean {
if (
((t.isCallExpression(parent) || t.isNewExpression(parent)) && parent.callee === node) ||
t.isUnaryLike(parent) ||
- (t.isMemberExpression(parent) && parent.object === node)
+ (t.isMemberExpression(parent) && parent.object === node) ||
+ t.isAwaitExpression(parent)
) {
return true;
}
diff --git a/packages/babel-generator/test/fixtures/parentheses/await-expression/actual.js b/packages/babel-generator/test/fixtures/parentheses/await-expression/actual.js
index d4bdc6b74a8d..828926300767 100644
--- a/packages/babel-generator/test/fixtures/parentheses/await-expression/actual.js
+++ b/packages/babel-generator/test/fixtures/parentheses/await-expression/actual.js
@@ -5,6 +5,7 @@ async function asdf() {
true ? (await 1) : (await 2);
await (1 ? 2 : 3);
await (await 1);
+ await (a || b);
}
async function a(b) {
diff --git a/packages/babel-generator/test/fixtures/parentheses/await-expression/expected.js b/packages/babel-generator/test/fixtures/parentheses/await-expression/expected.js
index dc2cb361e0c6..271a15791e19 100644
--- a/packages/babel-generator/test/fixtures/parentheses/await-expression/expected.js
+++ b/packages/babel-generator/test/fixtures/parentheses/await-expression/expected.js
@@ -5,6 +5,7 @@ async function asdf() {
true ? await 1 : await 2;
await (1 ? 2 : 3);
await await 1;
+ await (a || b);
}
async function a(b) {
From a8cf9079a81569d584137fd2a266a6004721ea23 Mon Sep 17 00:00:00 2001
From: Henry Zhu
Date: Sun, 12 Mar 2017 22:03:19 -0400
Subject: [PATCH 21/37] changelog for 6.24.0 [skip ci] (#5452)
---
CHANGELOG.md | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 97 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 96d28278e150..3802a583f751 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,103 @@ _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.
+## 6.24.0 (2017-03-13)
+
+A quick release for 2 features:
+
+- Thanks to @rwjblue, there is now a `noInterop` option for our `es2015-modules` transform to remove the `interopRequireDefault` and `interopRequireWildcard` helpers.
+
+Input
+
+```js
+import foo from "foo";
+foo;
+```
+
+Regular Output
+
+```js
+var _foo = require("foo");
+var _foo2 = _interopRequireDefault(_foo);
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+_foo2.default;
+```
+
+Output with option `noInterop`
+
+```js
+"use strict";
+var _foo = require("foo");
+(0, _foo.default)();
+```
+
+> This also helps [ember-cli migrate to Babel 6](https://github.com/ember-cli/ember-cli/pull/6828).
+
+- @izaakschroeder has added `dirname` to the preset constructor which presets can use to resolve things relative to files.
+
+Example usage of `fileContext.dirname` in a preset
+
+```js
+module.exports = function preset (context, options, fileContext) {
+ if (/resolve-addons-relative-to-file$/.test(fileContext.dirname)) {
+ return {
+ plugins: ['plugin-here'],
+ };
+ }
+ return {};
+};
+```
+
+> This will help out with reusing a [`browserslist` file for babel-preset-env](https://github.com/babel/babel-preset-env/issues/26) and for plugins like https://github.com/tleunen/babel-plugin-module-resolver.
+
+#### :rocket: New Feature
+* `babel-plugin-transform-es2015-modules-amd`, `babel-plugin-transform-es2015-modules-commonjs`
+ * [#5427](https://github.com/babel/babel/pull/5427) Backport `noInterop` flag for modules to 6.x. ([@rwjblue](https://github.com/rwjblue))
+* `babel-core`
+ * [#4834](https://github.com/babel/babel/pull/4834) Pass `dirname` as extra metadata to preset constructor. ([@izaakschroeder](https://github.com/izaakschroeder))
+
+#### :bug: Bug Fix
+* `babel-generator`
+ * [#5453](https://github.com/babel/babel/pull/5453) Keep parentheses for logical expression when in await expression. ([@aaronang](https://github.com/aaronang))
+ * [#5339](https://github.com/babel/babel/pull/5339) Wrap some generated do expressions in parens. ([@zjmiller](https://github.com/zjmiller))
+* `babel-generator`, `babel-plugin-transform-object-rest-spread`
+ * [#5322](https://github.com/babel/babel/pull/5322) Fix for-await printing. ([@danez](https://github.com/danez))
+
+#### :memo: Documentation
+
+* [#5449](https://github.com/babel/babel/pull/5449) Fixed broken links in README.md [skip-ci]. ([@sethbergman](https://github.com/sethbergman))
+* [#5409](https://github.com/babel/babel/pull/5409) Fix transform-object-rest-spread README. ([@existentialism](https://github.com/existentialism))
+* [#5379](https://github.com/babel/babel/pull/5379) Lint code snippets in READMEs. ([@xtuc](https://github.com/xtuc))
+* [#5334](https://github.com/babel/babel/pull/5334) Shorthand properties examples. ([@bhoule](https://github.com/bhoule))
+* [#5329](https://github.com/babel/babel/pull/5329) Update CONTRIBUTING.md with respect to coverage check [skip ci]. ([@zjmiller](https://github.com/zjmiller))
+
+#### :house: Internal
+* Other
+ * [#5338](https://github.com/babel/babel/pull/5338) Improve babel-generator's code coverage. ([@alxpy](https://github.com/alxpy))
+ * [#5336](https://github.com/babel/babel/pull/5336) Enable codecov partial coverage. ([@danez](https://github.com/danez))
+ * [#5350](https://github.com/babel/babel/pull/5350) Remove redundant NODE_ENV=test in Makefile. ([@aaronang](https://github.com/aaronang))
+ * [#5312](https://github.com/babel/babel/pull/5312) [skip ci] Add devEngines to package.json. ([@yavorsky](https://github.com/yavorsky))
+* `babel-cli`
+ * [#5342](https://github.com/babel/babel/pull/5342) Add test for passing arguments to babel-node (#5163). ([@outsideris](https://github.com/outsideris))
+* `babel-traverse`
+ * [#5296](https://github.com/babel/babel/pull/5296) Add test for reference paths. ([@jasonLaster](https://github.com/jasonLaster))
+
+#### Committers: 14
+- Aaron Ang ([aaronang](https://github.com/aaronang))
+- Alex Kuzmenko ([alxpy](https://github.com/alxpy))
+- Artem Gurzhii ([artemgurzhii](https://github.com/artemgurzhii))
+- Artem Yavorsky ([yavorsky](https://github.com/yavorsky))
+- Brendan Houle ([bhoule](https://github.com/bhoule))
+- Brian Ng ([existentialism](https://github.com/existentialism))
+- Daniel Tschinder ([danez](https://github.com/danez))
+- Izaak Schroeder ([izaakschroeder](https://github.com/izaakschroeder))
+- Jason Laster ([jasonLaster](https://github.com/jasonLaster))
+- JeongHoon Byun (aka Outsider) ([outsideris](https://github.com/outsideris))
+- Robert Jackson ([rwjblue](https://github.com/rwjblue))
+- Seth Bergman ([sethbergman](https://github.com/sethbergman))
+- Sven SAULEAU ([xtuc](https://github.com/xtuc))
+- Zachary Miller ([zjmiller](https://github.com/zjmiller))
+
## 6.23.0 (2017-02-13)
#### :rocket: New Feature
From 71e4336f651a7d6ce5b56eefc19570582ca20a69 Mon Sep 17 00:00:00 2001
From: Henry Zhu
Date: Sun, 12 Mar 2017 22:18:08 -0400
Subject: [PATCH 22/37] v6.24.0
---
lerna.json | 2 +-
packages/babel-cli/package.json | 6 +++---
packages/babel-core/package.json | 8 ++++----
packages/babel-generator/package.json | 2 +-
.../babel-helper-plugin-test-runner/package.json | 4 ++--
.../package.json | 4 ++--
.../package.json | 6 +++---
.../package.json | 4 ++--
.../package.json | 6 +++---
packages/babel-preset-es2015/package.json | 12 ++++++------
packages/babel-preset-latest/package.json | 6 +++---
packages/babel-register/package.json | 4 ++--
12 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/lerna.json b/lerna.json
index 169db035c12b..117685b8a5b6 100644
--- a/lerna.json
+++ b/lerna.json
@@ -1,6 +1,6 @@
{
"lerna": "2.0.0-beta.23",
- "version": "6.23.1",
+ "version": "6.24.0",
"changelog": {
"repo": "babel/babel",
"labels": {
diff --git a/packages/babel-cli/package.json b/packages/babel-cli/package.json
index b2f56d6cfa94..650754193a56 100644
--- a/packages/babel-cli/package.json
+++ b/packages/babel-cli/package.json
@@ -1,6 +1,6 @@
{
"name": "babel-cli",
- "version": "6.23.0",
+ "version": "6.24.0",
"description": "Babel command line.",
"author": "Sebastian McKenzie ",
"homepage": "https://babeljs.io/",
@@ -16,8 +16,8 @@
"compiler"
],
"dependencies": {
- "babel-core": "^6.23.0",
- "babel-register": "^6.23.0",
+ "babel-core": "^6.24.0",
+ "babel-register": "^6.24.0",
"babel-polyfill": "^6.23.0",
"babel-runtime": "^6.22.0",
"commander": "^2.8.1",
diff --git a/packages/babel-core/package.json b/packages/babel-core/package.json
index f9eecdac8434..782335fc4454 100644
--- a/packages/babel-core/package.json
+++ b/packages/babel-core/package.json
@@ -1,6 +1,6 @@
{
"name": "babel-core",
- "version": "6.23.1",
+ "version": "6.24.0",
"description": "Babel compiler core.",
"author": "Sebastian McKenzie ",
"homepage": "https://babeljs.io/",
@@ -27,12 +27,12 @@
},
"dependencies": {
"babel-code-frame": "^6.22.0",
- "babel-generator": "^6.23.0",
+ "babel-generator": "^6.24.0",
"babel-helpers": "^6.23.0",
"babel-messages": "^6.23.0",
"babel-template": "^6.23.0",
"babel-runtime": "^6.22.0",
- "babel-register": "^6.23.0",
+ "babel-register": "^6.24.0",
"babel-traverse": "^6.23.1",
"babel-types": "^6.23.0",
"babylon": "^6.11.0",
@@ -48,7 +48,7 @@
},
"devDependencies": {
"babel-helper-fixtures": "^6.22.0",
- "babel-helper-transform-fixture-test-runner": "^6.23.0",
+ "babel-helper-transform-fixture-test-runner": "^6.24.0",
"babel-polyfill": "^6.23.0"
}
}
diff --git a/packages/babel-generator/package.json b/packages/babel-generator/package.json
index 0212353f434c..f306ab966586 100644
--- a/packages/babel-generator/package.json
+++ b/packages/babel-generator/package.json
@@ -1,6 +1,6 @@
{
"name": "babel-generator",
- "version": "6.23.0",
+ "version": "6.24.0",
"description": "Turns an AST into code.",
"author": "Sebastian McKenzie ",
"homepage": "https://babeljs.io/",
diff --git a/packages/babel-helper-plugin-test-runner/package.json b/packages/babel-helper-plugin-test-runner/package.json
index c8b0dfa1f28f..8e305b69649b 100644
--- a/packages/babel-helper-plugin-test-runner/package.json
+++ b/packages/babel-helper-plugin-test-runner/package.json
@@ -1,12 +1,12 @@
{
"name": "babel-helper-plugin-test-runner",
- "version": "6.22.0",
+ "version": "6.24.0",
"description": "Helper function to support test runner",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-plugin-test-runner",
"license": "MIT",
"main": "lib/index.js",
"dependencies": {
"babel-runtime": "^6.22.0",
- "babel-helper-transform-fixture-test-runner": "^6.22.0"
+ "babel-helper-transform-fixture-test-runner": "^6.24.0"
}
}
diff --git a/packages/babel-helper-transform-fixture-test-runner/package.json b/packages/babel-helper-transform-fixture-test-runner/package.json
index 6b4b60f922b7..1f3b785bf573 100644
--- a/packages/babel-helper-transform-fixture-test-runner/package.json
+++ b/packages/babel-helper-transform-fixture-test-runner/package.json
@@ -1,6 +1,6 @@
{
"name": "babel-helper-transform-fixture-test-runner",
- "version": "6.23.0",
+ "version": "6.24.0",
"description": "Transform test runner for babel-helper-fixtures module",
"author": "Sebastian McKenzie ",
"homepage": "https://babeljs.io/",
@@ -9,7 +9,7 @@
"main": "lib/index.js",
"dependencies": {
"babel-runtime": "^6.22.0",
- "babel-core": "^6.23.0",
+ "babel-core": "^6.24.0",
"babel-polyfill": "^6.23.0",
"babel-helper-fixtures": "^6.22.0",
"source-map": "^0.5.0",
diff --git a/packages/babel-plugin-transform-es2015-modules-amd/package.json b/packages/babel-plugin-transform-es2015-modules-amd/package.json
index 81560058ad47..d25079b7a3d2 100644
--- a/packages/babel-plugin-transform-es2015-modules-amd/package.json
+++ b/packages/babel-plugin-transform-es2015-modules-amd/package.json
@@ -1,12 +1,12 @@
{
"name": "babel-plugin-transform-es2015-modules-amd",
- "version": "6.22.0",
+ "version": "6.24.0",
"description": "This plugin transforms ES2015 modules to AMD",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-modules-amd",
"license": "MIT",
"main": "lib/index.js",
"dependencies": {
- "babel-plugin-transform-es2015-modules-commonjs": "^6.22.0",
+ "babel-plugin-transform-es2015-modules-commonjs": "^6.24.0",
"babel-template": "^6.22.0",
"babel-runtime": "^6.22.0"
},
@@ -14,6 +14,6 @@
"babel-plugin"
],
"devDependencies": {
- "babel-helper-plugin-test-runner": "^6.22.0"
+ "babel-helper-plugin-test-runner": "^6.24.0"
}
}
diff --git a/packages/babel-plugin-transform-es2015-modules-commonjs/package.json b/packages/babel-plugin-transform-es2015-modules-commonjs/package.json
index 574befaf5f48..148504224f91 100644
--- a/packages/babel-plugin-transform-es2015-modules-commonjs/package.json
+++ b/packages/babel-plugin-transform-es2015-modules-commonjs/package.json
@@ -1,6 +1,6 @@
{
"name": "babel-plugin-transform-es2015-modules-commonjs",
- "version": "6.23.0",
+ "version": "6.24.0",
"description": "This plugin transforms ES2015 modules to CommonJS",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-modules-commonjs",
"license": "MIT",
@@ -15,6 +15,6 @@
"babel-plugin"
],
"devDependencies": {
- "babel-helper-plugin-test-runner": "^6.22.0"
+ "babel-helper-plugin-test-runner": "^6.24.0"
}
}
diff --git a/packages/babel-plugin-transform-es2015-modules-umd/package.json b/packages/babel-plugin-transform-es2015-modules-umd/package.json
index 8c424e9f1e20..15e7dd4244ef 100644
--- a/packages/babel-plugin-transform-es2015-modules-umd/package.json
+++ b/packages/babel-plugin-transform-es2015-modules-umd/package.json
@@ -1,12 +1,12 @@
{
"name": "babel-plugin-transform-es2015-modules-umd",
- "version": "6.23.0",
+ "version": "6.24.0",
"description": "This plugin transforms ES2015 modules to UMD",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-modules-umd",
"license": "MIT",
"main": "lib/index.js",
"dependencies": {
- "babel-plugin-transform-es2015-modules-amd": "^6.22.0",
+ "babel-plugin-transform-es2015-modules-amd": "^6.24.0",
"babel-template": "^6.23.0",
"babel-runtime": "^6.22.0"
},
@@ -14,6 +14,6 @@
"babel-plugin"
],
"devDependencies": {
- "babel-helper-plugin-test-runner": "^6.22.0"
+ "babel-helper-plugin-test-runner": "^6.24.0"
}
}
diff --git a/packages/babel-preset-es2015/package.json b/packages/babel-preset-es2015/package.json
index 78d66ad21726..15cccddece09 100644
--- a/packages/babel-preset-es2015/package.json
+++ b/packages/babel-preset-es2015/package.json
@@ -1,6 +1,6 @@
{
"name": "babel-preset-es2015",
- "version": "6.22.0",
+ "version": "6.24.0",
"description": "Babel preset for all es2015 plugins.",
"author": "Sebastian McKenzie ",
"homepage": "https://babeljs.io/",
@@ -19,10 +19,10 @@
"babel-plugin-transform-es2015-for-of": "^6.22.0",
"babel-plugin-transform-es2015-function-name": "^6.22.0",
"babel-plugin-transform-es2015-literals": "^6.22.0",
- "babel-plugin-transform-es2015-modules-amd": "^6.22.0",
- "babel-plugin-transform-es2015-modules-commonjs": "^6.22.0",
+ "babel-plugin-transform-es2015-modules-amd": "^6.24.0",
+ "babel-plugin-transform-es2015-modules-commonjs": "^6.24.0",
"babel-plugin-transform-es2015-modules-systemjs": "^6.22.0",
- "babel-plugin-transform-es2015-modules-umd": "^6.22.0",
+ "babel-plugin-transform-es2015-modules-umd": "^6.24.0",
"babel-plugin-transform-es2015-object-super": "^6.22.0",
"babel-plugin-transform-es2015-parameters": "^6.22.0",
"babel-plugin-transform-es2015-shorthand-properties": "^6.22.0",
@@ -34,7 +34,7 @@
"babel-plugin-transform-regenerator": "^6.22.0"
},
"devDependencies": {
- "babel-helper-transform-fixture-test-runner": "^6.22.0",
- "babel-helper-plugin-test-runner": "^6.22.0"
+ "babel-helper-transform-fixture-test-runner": "^6.24.0",
+ "babel-helper-plugin-test-runner": "^6.24.0"
}
}
diff --git a/packages/babel-preset-latest/package.json b/packages/babel-preset-latest/package.json
index f5a306981de5..85791245c0f4 100644
--- a/packages/babel-preset-latest/package.json
+++ b/packages/babel-preset-latest/package.json
@@ -1,6 +1,6 @@
{
"name": "babel-preset-latest",
- "version": "6.22.0",
+ "version": "6.24.0",
"description": "Babel preset including es2015+",
"author": "Sebastian McKenzie ",
"homepage": "https://babeljs.io/",
@@ -8,11 +8,11 @@
"repository": "https://github.com/babel/babel/tree/master/packages/babel-preset-latest",
"main": "lib/index.js",
"dependencies": {
- "babel-preset-es2015": "^6.22.0",
+ "babel-preset-es2015": "^6.24.0",
"babel-preset-es2016": "^6.22.0",
"babel-preset-es2017": "^6.22.0"
},
"devDependencies": {
- "babel-helper-plugin-test-runner": "^6.22.0"
+ "babel-helper-plugin-test-runner": "^6.24.0"
}
}
diff --git a/packages/babel-register/package.json b/packages/babel-register/package.json
index 762d9a336071..2d1e7c766822 100644
--- a/packages/babel-register/package.json
+++ b/packages/babel-register/package.json
@@ -1,6 +1,6 @@
{
"name": "babel-register",
- "version": "6.23.0",
+ "version": "6.24.0",
"description": "babel require hook",
"license": "MIT",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-register",
@@ -8,7 +8,7 @@
"main": "lib/node.js",
"browser": "lib/browser.js",
"dependencies": {
- "babel-core": "^6.23.0",
+ "babel-core": "^6.24.0",
"babel-runtime": "^6.22.0",
"core-js": "^2.4.0",
"home-or-tmp": "^2.0.0",
From e30197b96bda5182e794aadd5ab09263175a1349 Mon Sep 17 00:00:00 2001
From: Sven SAULEAU
Date: Thu, 16 Mar 2017 08:53:38 +0100
Subject: [PATCH 23/37] docs: [skip ci] update documentation
---
packages/babel-generator/README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/packages/babel-generator/README.md b/packages/babel-generator/README.md
index 46a4c051b305..a3371913532f 100644
--- a/packages/babel-generator/README.md
+++ b/packages/babel-generator/README.md
@@ -39,6 +39,7 @@ quotes | `'single'` or `'double'` | autodetect based on `ast.tok
filename | string | | Used in warning messages
flowCommaSeparator | boolean | `false` | Set to `true` to use commas instead of semicolons as Flow property separators
jsonCompatibleStrings | boolean | `false` | Set to true to run `jsesc` with "json": true to print "\u00A9" vs. "©";
+
Options for source maps:
name | type | default | description
From 8859715893cd2cc7d94993abbf02fc233bed9cc6 Mon Sep 17 00:00:00 2001
From: Ryan Paul
Date: Thu, 16 Mar 2017 14:17:37 -0600
Subject: [PATCH 24/37] Removes unused lodash dependency from
babel-helper-builder-react-jsx (#5486)
---
packages/babel-helper-builder-react-jsx/package.json | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/packages/babel-helper-builder-react-jsx/package.json b/packages/babel-helper-builder-react-jsx/package.json
index 6fed8d9b0d9d..92fb33891d60 100644
--- a/packages/babel-helper-builder-react-jsx/package.json
+++ b/packages/babel-helper-builder-react-jsx/package.json
@@ -8,7 +8,6 @@
"dependencies": {
"babel-runtime": "^6.22.0",
"babel-types": "^6.23.0",
- "esutils": "^2.0.0",
- "lodash": "^4.2.0"
+ "esutils": "^2.0.0"
}
}
From 256fcbc58f3bed051b13523fcc2603cd3169c3a1 Mon Sep 17 00:00:00 2001
From: Diogo Franco
Date: Sun, 19 Mar 2017 11:28:52 +0900
Subject: [PATCH 25/37] Treat "await" as an invalid identifier (#4954)
It is valid (outside `async` functions) in the "script" parse goal, but always invalid in the "module" parse goal.
Fixes #4952.
---
.../test/fixtures/function-name/await/actual.js | 3 +++
.../test/fixtures/function-name/await/expected.js | 3 +++
packages/babel-types/src/validators.js | 3 +++
packages/babel-types/test/validators.js | 4 ++++
4 files changed, 13 insertions(+)
create mode 100644 packages/babel-plugin-transform-es2015-function-name/test/fixtures/function-name/await/actual.js
create mode 100644 packages/babel-plugin-transform-es2015-function-name/test/fixtures/function-name/await/expected.js
diff --git a/packages/babel-plugin-transform-es2015-function-name/test/fixtures/function-name/await/actual.js b/packages/babel-plugin-transform-es2015-function-name/test/fixtures/function-name/await/actual.js
new file mode 100644
index 000000000000..8f9c647db8ff
--- /dev/null
+++ b/packages/babel-plugin-transform-es2015-function-name/test/fixtures/function-name/await/actual.js
@@ -0,0 +1,3 @@
+export {};
+
+var obj = { await: function () {} };
diff --git a/packages/babel-plugin-transform-es2015-function-name/test/fixtures/function-name/await/expected.js b/packages/babel-plugin-transform-es2015-function-name/test/fixtures/function-name/await/expected.js
new file mode 100644
index 000000000000..4289b26aa575
--- /dev/null
+++ b/packages/babel-plugin-transform-es2015-function-name/test/fixtures/function-name/await/expected.js
@@ -0,0 +1,3 @@
+export {};
+
+var obj = { await: function _await() {} };
\ No newline at end of file
diff --git a/packages/babel-types/src/validators.js b/packages/babel-types/src/validators.js
index c5f25327bdbb..dc8143ae9d92 100644
--- a/packages/babel-types/src/validators.js
+++ b/packages/babel-types/src/validators.js
@@ -167,6 +167,9 @@ export function isReferenced(node: Object, parent: Object): boolean {
export function isValidIdentifier(name: string): boolean {
if (typeof name !== "string" || esutils.keyword.isReservedWordES6(name, true)) {
return false;
+ } else if (name === "await") {
+ // invalid in module, valid in script; better be safe (see #4952)
+ return false;
} else {
return esutils.keyword.isIdentifierNameES6(name);
}
diff --git a/packages/babel-types/test/validators.js b/packages/babel-types/test/validators.js
index 2e7e55d08567..ccc83f665b52 100644
--- a/packages/babel-types/test/validators.js
+++ b/packages/babel-types/test/validators.js
@@ -26,5 +26,9 @@ suite("validators", function () {
assert(t.isNodesEquivalent(parse(program), parse(program2)) === false);
});
+
+ it("rejects 'await' as an identifier", function () {
+ assert(t.isValidIdentifier("await") === false);
+ });
});
});
From b3c7337face4f3b3154b154486aa31b1ba992fae Mon Sep 17 00:00:00 2001
From: Henry Zhu
Date: Sun, 12 Mar 2017 22:23:51 -0400
Subject: [PATCH 26/37] Fix changelog [skip ci]
---
CHANGELOG.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3802a583f751..f90ac42c1212 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -110,6 +110,10 @@ module.exports = function preset (context, options, fileContext) {
- Sven SAULEAU ([xtuc](https://github.com/xtuc))
- Zachary Miller ([zjmiller](https://github.com/zjmiller))
+## 6.23.1 (2017-02-13)
+
+Regression: Revert https://github.com/babel/babel/pull/5306 since it made a backwards-incompatible change.
+
## 6.23.0 (2017-02-13)
#### :rocket: New Feature
From 9b4c33d44ed303be9506592d6a8466ea990724f3 Mon Sep 17 00:00:00 2001
From: Felix Yan
Date: Tue, 4 Apr 2017 13:38:12 +0800
Subject: [PATCH 27/37] Fix a typo: occurences -> occurrences (#5575)
---
packages/babel-generator/src/index.js | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/packages/babel-generator/src/index.js b/packages/babel-generator/src/index.js
index 27adb6569780..1d511096d394 100644
--- a/packages/babel-generator/src/index.js
+++ b/packages/babel-generator/src/index.js
@@ -99,7 +99,7 @@ function findCommonStringDelimiter(code, tokens) {
return DEFAULT_STRING_DELIMITER;
}
- const occurences = {
+ const occurrences = {
single: 0,
double: 0
};
@@ -112,15 +112,15 @@ function findCommonStringDelimiter(code, tokens) {
const raw = code.slice(token.start, token.end);
if (raw[0] === "'") {
- occurences.single++;
+ occurrences.single++;
} else {
- occurences.double++;
+ occurrences.double++;
}
checked++;
if (checked >= 3) break;
}
- if (occurences.single > occurences.double) {
+ if (occurrences.single > occurrences.double) {
return "single";
} else {
return "double";
From fd3a2c285aac1774425e300121570b0da7cbf191 Mon Sep 17 00:00:00 2001
From: MrSpider
Date: Thu, 6 Apr 2017 17:40:31 +0200
Subject: [PATCH 28/37] Fix replacing function declaration in export default
(fixes #4468) (#5456)
---
.../babel-traverse/src/path/replacement.js | 3 +-
packages/babel-traverse/test/replacement.js | 28 +++++++++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
create mode 100644 packages/babel-traverse/test/replacement.js
diff --git a/packages/babel-traverse/src/path/replacement.js b/packages/babel-traverse/src/path/replacement.js
index 47e706d0d2bb..8ac89eaaf780 100644
--- a/packages/babel-traverse/src/path/replacement.js
+++ b/packages/babel-traverse/src/path/replacement.js
@@ -125,7 +125,8 @@ export function replaceWith(replacement) {
if (this.isNodeType("Statement") && t.isExpression(replacement)) {
if (
!this.canHaveVariableDeclarationOrExpression() &&
- !this.canSwapBetweenExpressionAndStatement(replacement)
+ !this.canSwapBetweenExpressionAndStatement(replacement) &&
+ !this.parentPath.isExportDefaultDeclaration()
) {
// replacing a statement with an expression so wrap it in an expression statement
replacement = t.expressionStatement(replacement);
diff --git a/packages/babel-traverse/test/replacement.js b/packages/babel-traverse/test/replacement.js
new file mode 100644
index 000000000000..eb29364f2fb4
--- /dev/null
+++ b/packages/babel-traverse/test/replacement.js
@@ -0,0 +1,28 @@
+import traverse from "../lib";
+import assert from "assert";
+import { parse } from "babylon";
+import * as t from "babel-types";
+
+describe("path/replacement", function () {
+ describe("replaceWith", function () {
+ const ast = parse("export default function() {};", { sourceType: "module" });
+
+ it("replaces declaration in ExportDefaultDeclaration node", function() {
+ traverse(ast, {
+ FunctionDeclaration(path) {
+ path.replaceWith(t.arrayExpression([
+ t.functionExpression(
+ path.node.id,
+ path.node.params,
+ path.node.body,
+ path.node.generator,
+ path.node.async
+ ),
+ ]));
+ },
+ });
+
+ assert(ast.program.body[0].declaration.type == "ArrayExpression");
+ });
+ });
+});
From d40cb31685cfa627bae3a4fd001aa0129befb5ff Mon Sep 17 00:00:00 2001
From: Sven SAULEAU
Date: Sat, 8 Apr 2017 10:13:20 +0200
Subject: [PATCH 29/37] Update transform-es2015-modules-commonjs doc #5588
---
.../babel-plugin-transform-es2015-modules-commonjs/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/babel-plugin-transform-es2015-modules-commonjs/README.md b/packages/babel-plugin-transform-es2015-modules-commonjs/README.md
index 33088cc8682c..bdad88967004 100644
--- a/packages/babel-plugin-transform-es2015-modules-commonjs/README.md
+++ b/packages/babel-plugin-transform-es2015-modules-commonjs/README.md
@@ -82,7 +82,7 @@ Object.defineProperty(exports, "__esModule", {
});
```
-In environments that don't support this you can enable loose mode on `babel-plugin-transform-es20150-modules-commonjs`
+In environments that don't support this you can enable loose mode on `babel-plugin-transform-es2015-modules-commonjs`
and instead of using `Object.defineProperty` an assignment will be used instead.
```javascript
From 149acc40bdac5ac42bb4e49ff71192274b69de26 Mon Sep 17 00:00:00 2001
From: Sven SAULEAU
Date: Sat, 8 Apr 2017 10:13:47 +0200
Subject: [PATCH 30/37] Remove incorrect docs. #5580
---
.../README.md | 18 ------------------
1 file changed, 18 deletions(-)
diff --git a/packages/babel-plugin-transform-es2015-spread/README.md b/packages/babel-plugin-transform-es2015-spread/README.md
index e33a1db7cff7..ad1fd70d1683 100644
--- a/packages/babel-plugin-transform-es2015-spread/README.md
+++ b/packages/babel-plugin-transform-es2015-spread/README.md
@@ -9,31 +9,13 @@
```js
var a = ['a', 'b', 'c'];
var b = [...a, 'foo'];
-
-var c = { foo: 'bar', baz: 42 };
-var d = {...c, a: 2};
```
**Out**
```js
-var _extends = Object.assign || function (target) {
- for (var i = 1; i < arguments.length; i++) {
- var source = arguments[i];
- for (var key in source) {
- if (Object.prototype.hasOwnProperty.call(source, key)) {
- target[key] = source[key];
- }
- }
- }
- return target;
-}
-
var a = [ 'a', 'b', 'c' ];
var b = [].concat(a, [ 'foo' ]);
-
-var c = { foo: 'bar', baz: 42 };
-var d = _extends({}, c, { a: 2 });
```
## Installation
From 2cb4d08d194040bed7345e72fa3d549518b9836f Mon Sep 17 00:00:00 2001
From: Sven SAULEAU
Date: Sat, 8 Apr 2017 10:14:19 +0200
Subject: [PATCH 31/37] Improve example of
babel-plugin-transform-es2015-arrow-functions #5573
---
.../README.md | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/packages/babel-plugin-transform-es2015-arrow-functions/README.md b/packages/babel-plugin-transform-es2015-arrow-functions/README.md
index 658f413f6cb2..9a5ab5b2f5f3 100644
--- a/packages/babel-plugin-transform-es2015-arrow-functions/README.md
+++ b/packages/babel-plugin-transform-es2015-arrow-functions/README.md
@@ -27,12 +27,12 @@ console.log(bob.printFriends());
**Out**
```javascript
-var a = function a() {};
-var a = function a(b) {
+var a = function () {};
+var a = function (b) {
return b;
};
-var double = [1, 2, 3].map(function (num) {
+const double = [1, 2, 3].map(function (num) {
return num * 2;
});
console.log(double); // [2,4,6]
@@ -40,7 +40,7 @@ console.log(double); // [2,4,6]
var bob = {
_name: "Bob",
_friends: ["Sally", "Tom"],
- printFriends: function printFriends() {
+ printFriends() {
var _this = this;
this._friends.forEach(function (f) {
From e2c2d7d7423a8823dda60ab54e0881011be6baf1 Mon Sep 17 00:00:00 2001
From: Sven SAULEAU
Date: Sat, 8 Apr 2017 10:14:56 +0200
Subject: [PATCH 32/37] Update babel-generator's README #5517
---
packages/babel-generator/README.md | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/packages/babel-generator/README.md b/packages/babel-generator/README.md
index a3371913532f..ff215b753f2a 100644
--- a/packages/babel-generator/README.md
+++ b/packages/babel-generator/README.md
@@ -54,12 +54,7 @@ sourceFileName | string | | The filename for the sourc
In most cases, Babel does a 1:1 transformation of input-file to output-file. However,
you may be dealing with AST constructed from multiple sources - JS files, templates, etc.
If this is the case, and you want the sourcemaps to reflect the correct sources, you'll need
-to make some changes to your code.
-
-First, each node with a `loc` property (which indicates that node's original placement in the
-source document) must also include a `loc.filename` property, set to the source filename.
-
-Second, you should pass an object to `generate` as the `code` parameter. Keys
+to pass an object to `generate` as the `code` parameter. Keys
should be the source filenames, and values should be the source content.
Here's an example of what that might look like:
@@ -70,14 +65,14 @@ import generate from 'babel-generator';
const a = 'var a = 1;';
const b = 'var b = 2;';
-const astA = parse(a, { filename: 'a.js' });
-const astB = parse(b, { filename: 'b.js' });
+const astA = parse(a, { sourceFilename: 'a.js' });
+const astB = parse(b, { sourceFilename: 'b.js' });
const ast = {
type: 'Program',
- body: [].concat(astA.body, ast2.body)
+ body: [].concat(astA.program.body, astB.program.body)
};
-const { code, map } = generate(ast, { /* options */ }, {
+const { code, map } = generate(ast, { sourceMaps: true }, {
'a.js': a,
'b.js': b
});
From e9bc213b140ab1a30b3bb2df1162c7ae95ee5c05 Mon Sep 17 00:00:00 2001
From: Sven SAULEAU
Date: Sat, 8 Apr 2017 10:15:43 +0200
Subject: [PATCH 33/37] Update coffescript/register reference link address
#5475
---
packages/babel-register/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/babel-register/README.md b/packages/babel-register/README.md
index 6a4682b56801..c19e260c4095 100644
--- a/packages/babel-register/README.md
+++ b/packages/babel-register/README.md
@@ -5,7 +5,7 @@
One of the ways you can use Babel is through the require hook. The require hook
will bind itself to node's `require` and automatically compile files on the
fly. This is equivalent to CoffeeScript's
-[coffee-script/register](http://coffeescript.org/documentation/docs/register.html).
+[coffee-script/register](http://coffeescript.org/v2/annotated-source/register.html).
## Install
From c1b374070740ff75d0f6782a12856e37746c5b4d Mon Sep 17 00:00:00 2001
From: Sven SAULEAU
Date: Sat, 8 Apr 2017 10:16:55 +0200
Subject: [PATCH 34/37] document cache option for babel-register #5440
---
packages/babel-register/README.md | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/packages/babel-register/README.md b/packages/babel-register/README.md
index c19e260c4095..413e7a6349e5 100644
--- a/packages/babel-register/README.md
+++ b/packages/babel-register/README.md
@@ -66,7 +66,10 @@ require("babel-register")({
// Setting this will remove the currently hooked extensions of .es6, `.es`, `.jsx`
// and .js so you'll have to add them back if you want them to be used again.
- extensions: [".es6", ".es", ".jsx", ".js"]
+ extensions: [".es6", ".es", ".jsx", ".js"],
+
+ // Setting this to false will disable the cache.
+ cache: true
});
```
From 982aba38e4b13e77fd1e6639b43ce208d1296981 Mon Sep 17 00:00:00 2001
From: Sven SAULEAU
Date: Sat, 8 Apr 2017 10:18:01 +0200
Subject: [PATCH 35/37] [doc] Fix: comments in usage w/ options #5400
---
packages/babel-plugin-transform-runtime/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/babel-plugin-transform-runtime/README.md b/packages/babel-plugin-transform-runtime/README.md
index 011a3eab10de..fb82b38de57b 100644
--- a/packages/babel-plugin-transform-runtime/README.md
+++ b/packages/babel-plugin-transform-runtime/README.md
@@ -50,7 +50,7 @@ Without options:
With options:
-```json
+```js
{
"plugins": [
["transform-runtime", {
From ca435b6d486f356cf8004a6bda07f28fb3c5474a Mon Sep 17 00:00:00 2001
From: Sven SAULEAU
Date: Sat, 8 Apr 2017 10:18:44 +0200
Subject: [PATCH 36/37] Improve options documentation for
`babel-plugin-transform-runtime` #5401
---
.../babel-plugin-transform-runtime/README.md | 64 ++++++++++++++++---
1 file changed, 54 insertions(+), 10 deletions(-)
diff --git a/packages/babel-plugin-transform-runtime/README.md b/packages/babel-plugin-transform-runtime/README.md
index fb82b38de57b..2ab8ae89204f 100644
--- a/packages/babel-plugin-transform-runtime/README.md
+++ b/packages/babel-plugin-transform-runtime/README.md
@@ -1,8 +1,8 @@
# babel-plugin-transform-runtime
-> Externalise references to helpers and builtins, automatically polyfilling your code without polluting globals. (This plugin is recommended in a library/tool)
+> Externalise references to helpers and built-ins, automatically polyfilling your code without polluting globals. (This plugin is recommended in a library/tool)
-NOTE: Instance methods such as `"foobar".includes("foo")` will not work since that would require modification of existing builtins (Use [`babel-polyfill`](http://babeljs.io/docs/usage/polyfill) for that).
+NOTE: Instance methods such as `"foobar".includes("foo")` will not work since that would require modification of existing built-ins (Use [`babel-polyfill`](http://babeljs.io/docs/usage/polyfill) for that).
## Why?
@@ -50,14 +50,14 @@ Without options:
With options:
-```js
+```json
{
"plugins": [
["transform-runtime", {
- "helpers": false, // defaults to true
- "polyfill": false, // defaults to true
- "regenerator": true, // defaults to true
- "moduleName": "babel-runtime" // defaults to "babel-runtime"
+ "helpers": false,
+ "polyfill": false,
+ "regenerator": true,
+ "moduleName": "babel-runtime"
}]
]
}
@@ -77,15 +77,59 @@ require("babel-core").transform("code", {
});
```
+## Options
+
+### `helpers`
+
+`boolean`, defaults to `true`.
+
+Toggles whether or not inlined Babel helpers (`classCallCheck`, `extends`, etc.) are replaced with calls to `moduleName`.
+
+For more information, see [Helper aliasing](#helper-aliasing).
+
+### `polyfill`
+
+`boolean`, defaults to `true`.
+
+Toggles whether or not new built-ins (`Promise`, `Set`, `Map`, etc.) are transformed to use a non-global polluting polyfill.
+
+For more information, see [`core-js` aliasing](#core-js-aliasing).
+
+### `regenerator`
+
+`boolean`, defaults to `true`.
+
+Toggles whether or not generator functions are transformed to use a regenerator runtime that does not pollute the global scope.
+
+For more information, see [Regenerator aliasing](#regenerator-aliasing).
+
+### `moduleName`
+
+`string`, defaults to `"babel-runtime"`.
+
+Sets the name/path of the module used when importing helpers.
+
+Example:
+
+```json
+{
+ "moduleName": "flavortown/runtime"
+}
+```
+
+```js
+import extends from 'flavortown/runtime/helpers/extends';
+```
+
## Technical details
The `runtime` transformer plugin does three things:
* Automatically requires `babel-runtime/regenerator` when you use generators/async functions.
* Automatically requires `babel-runtime/core-js` and maps ES6 static methods and built-ins.
-* Removes the inline babel helpers and uses the module `babel-runtime/helpers` instead.
+* Removes the inline Babel helpers and uses the module `babel-runtime/helpers` instead.
-What does this actually mean though? Basically, you can use built-ins such as `Promise`, `Set`, `Symbol` etc as well use all the Babel features that require a polyfill seamlessly, without global pollution, making it extremely suitable for libraries.
+What does this actually mean though? Basically, you can use built-ins such as `Promise`, `Set`, `Symbol`, etc., as well use all the Babel features that require a polyfill seamlessly, without global pollution, making it extremely suitable for libraries.
Make sure you include `babel-runtime` as a dependency.
@@ -194,7 +238,7 @@ without worrying about where they come from.
### Helper aliasing
-Usually babel will place helpers at the top of your file to do common tasks to avoid
+Usually Babel will place helpers at the top of your file to do common tasks to avoid
duplicating the code around in the current file. Sometimes these helpers can get a
little bulky and add unnecessary duplication across files. The `runtime`
transformer replaces all the helper calls to a module.
From 412180e20304347f8c402f7e3c0613951ac5144c Mon Sep 17 00:00:00 2001
From: ssuman
Date: Sun, 9 Apr 2017 19:49:37 -0400
Subject: [PATCH 37/37] Increase the code coverage for traverse evaluation
(#5363)
* When applied this commit will increase the code coverage for evaluation.js
* Fixing linting issues
---
packages/babel-traverse/test/evaluation.js | 27 ++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/packages/babel-traverse/test/evaluation.js b/packages/babel-traverse/test/evaluation.js
index 148173fa7d01..4b0c01c0828d 100644
--- a/packages/babel-traverse/test/evaluation.js
+++ b/packages/babel-traverse/test/evaluation.js
@@ -61,6 +61,27 @@ describe("evaluation", function () {
);
});
+ it("should evaluate template literals", function () {
+ assert.strictEqual(
+ getPath("var x = 8; var y = 1; var z = `value is ${x >>> y}`")
+ .get("body.2.declarations.0.init").evaluate().value,
+ "value is 4"
+ );
+ });
+
+ it("should evaluate member expressions", function () {
+ assert.strictEqual(
+ getPath("var x = 'foo'.length")
+ .get("body.0.declarations.0.init").evaluate().value,
+ 3
+ );
+ const member_expr = getPath("var x = Math.min(2,Math.max(3,4));var y = Math.random();");
+ const eval_member_expr = member_expr.get("body.0.declarations.0.init").evaluate();
+ const eval_invalid_call = member_expr.get("body.1.declarations.0.init").evaluate();
+ assert.strictEqual(eval_member_expr.value, 2);
+ assert.strictEqual(eval_invalid_call.confident, false);
+ });
+
it("it should not deopt vars in different scope", function () {
const input = "var a = 5; function x() { var a = 5; var b = a + 1; } var b = a + 2";
assert.strictEqual(
@@ -88,6 +109,12 @@ describe("evaluation", function () {
getPath(constExample).get("body.1.consequent.body.1").evaluate().value,
false
);
+ const test_alternate = "var y = (3 < 4)? 3 + 4: 3 + 4;";
+ assert.strictEqual(
+ getPath(test_alternate)
+ .get("body.0.declarations.0.init.alternate").evaluate().value,
+ 7
+ );
});
it("should deopt ids that are referenced before the bindings", function () {