From 7e718e1e46d0407989f161f02a9e23af53412598 Mon Sep 17 00:00:00 2001 From: Artem Yavorsky Date: Mon, 3 Jul 2017 01:22:54 +0300 Subject: [PATCH 1/9] Handle chromeandroid browserslist value. --- experimental/babel-preset-env/src/targets-parser.js | 1 + 1 file changed, 1 insertion(+) diff --git a/experimental/babel-preset-env/src/targets-parser.js b/experimental/babel-preset-env/src/targets-parser.js index 2d1eea2c86..b152ae5b9f 100644 --- a/experimental/babel-preset-env/src/targets-parser.js +++ b/experimental/babel-preset-env/src/targets-parser.js @@ -5,6 +5,7 @@ import { semverify } from "./utils"; const browserNameMap = { android: "android", chrome: "chrome", + and_chr: "chrome", edge: "edge", firefox: "firefox", ie: "ie", From b73dac4f633e6752cf84aa5311a81874f07f9efc Mon Sep 17 00:00:00 2001 From: Brian Ng Date: Mon, 3 Jul 2017 09:06:37 -0500 Subject: [PATCH 2/9] add test --- .../use-builtins-chromeandroid/actual.js | 2 ++ .../use-builtins-chromeandroid/expected.js | 5 +++++ .../use-builtins-chromeandroid/options.json | 11 +++++++++++ 3 files changed, 18 insertions(+) create mode 100644 experimental/babel-preset-env/test/fixtures/preset-options/use-builtins-chromeandroid/actual.js create mode 100644 experimental/babel-preset-env/test/fixtures/preset-options/use-builtins-chromeandroid/expected.js create mode 100644 experimental/babel-preset-env/test/fixtures/preset-options/use-builtins-chromeandroid/options.json diff --git a/experimental/babel-preset-env/test/fixtures/preset-options/use-builtins-chromeandroid/actual.js b/experimental/babel-preset-env/test/fixtures/preset-options/use-builtins-chromeandroid/actual.js new file mode 100644 index 0000000000..7d70ec7d7b --- /dev/null +++ b/experimental/babel-preset-env/test/fixtures/preset-options/use-builtins-chromeandroid/actual.js @@ -0,0 +1,2 @@ +import "babel-polyfill"; +1 ** 2; diff --git a/experimental/babel-preset-env/test/fixtures/preset-options/use-builtins-chromeandroid/expected.js b/experimental/babel-preset-env/test/fixtures/preset-options/use-builtins-chromeandroid/expected.js new file mode 100644 index 0000000000..22628f6657 --- /dev/null +++ b/experimental/babel-preset-env/test/fixtures/preset-options/use-builtins-chromeandroid/expected.js @@ -0,0 +1,5 @@ +import "core-js/modules/web.timers"; +import "core-js/modules/web.immediate"; +import "core-js/modules/web.dom.iterable"; + +1 ** 2; \ No newline at end of file diff --git a/experimental/babel-preset-env/test/fixtures/preset-options/use-builtins-chromeandroid/options.json b/experimental/babel-preset-env/test/fixtures/preset-options/use-builtins-chromeandroid/options.json new file mode 100644 index 0000000000..c5a5e9044d --- /dev/null +++ b/experimental/babel-preset-env/test/fixtures/preset-options/use-builtins-chromeandroid/options.json @@ -0,0 +1,11 @@ +{ + "presets": [ + ["../../../../lib", { + "targets": { + "browsers": "chromeandroid 59" + }, + "modules": false, + "useBuiltIns": true + }] + ] +} From 65fa461a59ebfcc8b8dbad0606fa1d3dc7828034 Mon Sep 17 00:00:00 2001 From: Brian Ng Date: Mon, 3 Jul 2017 13:07:39 -0500 Subject: [PATCH 3/9] Tweak uglify option docs (#368) --- experimental/babel-preset-env/README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/experimental/babel-preset-env/README.md b/experimental/babel-preset-env/README.md index 27c73abc99..5a20c7dc1f 100644 --- a/experimental/babel-preset-env/README.md +++ b/experimental/babel-preset-env/README.md @@ -124,13 +124,15 @@ Note, browsers' results are overridden by explicit items from `targets`. ### `targets.uglify` -`number | true` +`true` -UglifyJS does not currently support any ES6 syntax, so if you are using Uglify to minify your code, targeting later browsers may cause Uglify to throw syntax errors. +When using `uglify-js` to minify your code, you may run into syntax errors when targeting later browsers since `uglify-js` does not support any ES2015+ syntax. -To prevent these errors - specify the uglify option, which will enable all plugins and, as a result, fully compile your code to ES5. However, the `useBuiltIns` option will still work as before, and only include the polyfills that your target(s) need. +To prevent these errors - set the `uglify` option to `true`, which enables all transformation plugins and as a result, your code is fully compiled to ES5. However, the `useBuiltIns` option will still work as before and only include the polyfills that your target(s) need. -> NOTE: Uglify has a work-in-progress "Harmony" branch to address the lack of ES6 support, but it is not yet stable. You can follow its progress in [UglifyJS2 issue #448](https://github.com/mishoo/UglifyJS2/issues/448). If you require an alternative minifier which _does_ support ES6 syntax, we recommend using [Babili](https://github.com/babel/babili). +> Uglify has support for ES2015 syntax via [uglify-es](https://github.com/mishoo/UglifyJS2/tree/harmony). If you are using syntax unsupported by `uglify-es`, we recommend using [Babili](https://github.com/babel/babili). + +> Note: This option is deprecated in 2.x and replaced with a [`forceAllTransforms` option](https://github.com/babel/babel-preset-env/pull/264). ### `spec` From 9f8a44ab7a427e8f7c68eb6af1a35d1f0c9a06fe Mon Sep 17 00:00:00 2001 From: Brian Ng Date: Tue, 4 Jul 2017 09:58:01 -0500 Subject: [PATCH 4/9] Update yarn.lock --- experimental/babel-preset-env/yarn.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/experimental/babel-preset-env/yarn.lock b/experimental/babel-preset-env/yarn.lock index 733daaf429..8af547061f 100644 --- a/experimental/babel-preset-env/yarn.lock +++ b/experimental/babel-preset-env/yarn.lock @@ -1252,6 +1252,7 @@ compat-table@kangax/compat-table#d88c80ea6dcbc7064112eb46bb020718107892f7: babel-preset-stage-0 latest chalk "^1.1.3" cheerio "^0.20.0" + closurecompiler latest core-js latest es5-shim latest es6-shim latest @@ -1260,7 +1261,6 @@ compat-table@kangax/compat-table#d88c80ea6dcbc7064112eb46bb020718107892f7: esdown latest espree latest esprima latest - google-closure-compiler-js "^20170521.0.0" jshint latest jstransform latest lodash.pickby "^4.6.0" @@ -1861,7 +1861,7 @@ form-data@~2.1.1: combined-stream "^1.0.5" mime-types "^2.1.12" -fs-extra@^2.0.0: +fs-extra@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-2.0.0.tgz#337352bded4a0b714f3eb84de8cea765e9d37600" dependencies: From a99f77a2115a81daa04fdc9f75f022df1c3df294 Mon Sep 17 00:00:00 2001 From: Brian Ng Date: Tue, 4 Jul 2017 09:58:08 -0500 Subject: [PATCH 5/9] Update changelog --- experimental/babel-preset-env/CHANGELOG.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/experimental/babel-preset-env/CHANGELOG.md b/experimental/babel-preset-env/CHANGELOG.md index c0910dabae..99a8be5ca6 100644 --- a/experimental/babel-preset-env/CHANGELOG.md +++ b/experimental/babel-preset-env/CHANGELOG.md @@ -1,5 +1,25 @@ # Changelog +## v1.6.0 (2017-07-04) + +### :rocket: New Feature + +- Bump compat-table for node8 support ([#363](https://github.com/babel/babel-preset-env/pull/363)) (@existentialism) + +We updated our mappings to support native trailing function commas and string paddings in Node.js 8+. + +### :bug: Bug Fix + +- Handle `chromeandroid` browserslist value ([#367](https://github.com/babel/babel-preset-env/pull/367)) (@yavorsky) + +We added support for using browserslist's `chromeandroid` in `targets`. + +### :memo: Documentation + +- Tweak uglify option docs ([#368](https://github.com/babel/babel-preset-env/pull/368)) (@existentialism) + +Thanks to @graingert and @pfiaux for pointing out some needed updates to the `uglify-js`-related docs. + ## v1.5.2 (2017-06-07) ### :bug: Bug Fix From f70c9f11fc3161c4c7773d54675a9f7489a9651c Mon Sep 17 00:00:00 2001 From: Brian Ng Date: Tue, 4 Jul 2017 09:59:31 -0500 Subject: [PATCH 6/9] 1.6.0 --- experimental/babel-preset-env/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/experimental/babel-preset-env/package.json b/experimental/babel-preset-env/package.json index 11fef3b983..0308f7215f 100644 --- a/experimental/babel-preset-env/package.json +++ b/experimental/babel-preset-env/package.json @@ -1,6 +1,6 @@ { "name": "babel-preset-env", - "version": "1.5.2", + "version": "1.6.0", "description": "A Babel preset for each environment.", "author": "Henry Zhu ", "homepage": "https://babeljs.io/", From 8e8ddc3ccbb59bc6a728e8cd2daf9363787c201b Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 16 Jul 2017 00:08:42 +0800 Subject: [PATCH 7/9] Fix typo on JavaScript (#375) --- experimental/babel-preset-env/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/experimental/babel-preset-env/README.md b/experimental/babel-preset-env/README.md index 5a20c7dc1f..3d41a28dab 100644 --- a/experimental/babel-preset-env/README.md +++ b/experimental/babel-preset-env/README.md @@ -50,7 +50,7 @@ This should be straightforward to do in most cases. There might be cases where p > Default behavior without options is the same as `babel-preset-latest`. -It won't include `stage-x` plugins. env will support all plugins in what we consider the latest version of Javascript (by matching what we do in [`babel-preset-latest`](http://babeljs.io/docs/plugins/preset-latest/)). +It won't include `stage-x` plugins. env will support all plugins in what we consider the latest version of JavaScript (by matching what we do in [`babel-preset-latest`](http://babeljs.io/docs/plugins/preset-latest/)). Ref: [#14](https://github.com/babel/babel-preset-env/issues/14) From 6ae350773e942547d48ed702b1db4a89e5f4c3d5 Mon Sep 17 00:00:00 2001 From: Ryan Tsao Date: Mon, 17 Jul 2017 13:08:15 -0700 Subject: [PATCH 8/9] Normalize module format of plugins/built-ins data (#376) * Reference plugins json instead of module in normalize-options.js * Make plugins module format match built-ins module --- .../babel-preset-env/data/plugin-features.js | 15 +++++++++------ .../babel-preset-env/src/normalize-options.js | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/experimental/babel-preset-env/data/plugin-features.js b/experimental/babel-preset-env/data/plugin-features.js index fef5180525..8879232308 100644 --- a/experimental/babel-preset-env/data/plugin-features.js +++ b/experimental/babel-preset-env/data/plugin-features.js @@ -1,5 +1,4 @@ -module.exports = { - // es2015 +const es2015 = { "check-es2015-constants": { features: [ "const", @@ -107,16 +106,18 @@ module.exports = { features: [ "generators", ], - }, + } +}; - // es2016 +const es2016 = { "transform-exponentiation-operator": { features: [ "exponentiation (**) operator", ], - }, + } +}; - // es2017 +const es2017 = { "transform-async-to-generator": { features: [ "async functions", @@ -128,3 +129,5 @@ module.exports = { ], } }; + +module.exports = Object.assign({}, es2015, es2016, es2017); diff --git a/experimental/babel-preset-env/src/normalize-options.js b/experimental/babel-preset-env/src/normalize-options.js index 9b8ebd014a..5e95ca9093 100644 --- a/experimental/babel-preset-env/src/normalize-options.js +++ b/experimental/babel-preset-env/src/normalize-options.js @@ -2,10 +2,10 @@ import invariant from "invariant"; import builtInsList from "../data/built-ins.json"; import { defaultWebIncludes } from "./default-includes"; import moduleTransformations from "./module-transformations"; -import pluginFeatures from "../data/plugin-features"; +import pluginsList from "../data/plugins.json"; const validIncludesAndExcludes = [ - ...Object.keys(pluginFeatures), + ...Object.keys(pluginsList), ...Object.keys(moduleTransformations).map((m) => moduleTransformations[m]), ...Object.keys(builtInsList), ...defaultWebIncludes, From d156afff2e95b450f86bacfcc5c3fd27bf5744aa Mon Sep 17 00:00:00 2001 From: Eduardo Leggiero Date: Sat, 22 Jul 2017 18:19:54 +0100 Subject: [PATCH 9/9] Fixed "node: current" example `parseFloat` is not applied anymore to "node: current" logic: The parseFloat was wrong, as `parseFloat('6.3.2')` will parse as 6.3, but `parseFloat('6.10.2')` will output 6.1 that is not correct. Ref: https://github.com/babel/babel-preset-env/blob/master/src/targets-parser.js#L73 --- experimental/babel-preset-env/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/experimental/babel-preset-env/README.md b/experimental/babel-preset-env/README.md index 3d41a28dab..2f3c2b09ae 100644 --- a/experimental/babel-preset-env/README.md +++ b/experimental/babel-preset-env/README.md @@ -112,7 +112,7 @@ The [data](https://github.com/babel/babel-preset-env/blob/master/data/plugins.js `number | string | "current" | true` -If you want to compile against the current node version, you can specify `"node": true` or `"node": "current"`, which would be the same as `"node": parseFloat(process.versions.node)`. +If you want to compile against the current node version, you can specify `"node": true` or `"node": "current"`, which would be the same as `"node": process.versions.node`. ### `targets.browsers`