From bd915ad8dcf3bd456db560b9c3ebe6215eb7136a Mon Sep 17 00:00:00 2001 From: Matthias Kern Date: Sat, 12 Aug 2017 19:55:37 +0200 Subject: [PATCH 1/7] Rename Babili to Babel-Minify (#392) --- 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 2f3c2b09ae..b5c01a29e9 100644 --- a/experimental/babel-preset-env/README.md +++ b/experimental/babel-preset-env/README.md @@ -130,7 +130,7 @@ When using `uglify-js` to minify your code, you may run into syntax errors when 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. -> 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). +> 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 [babel-minify](https://github.com/babel/minify). > Note: This option is deprecated in 2.x and replaced with a [`forceAllTransforms` option](https://github.com/babel/babel-preset-env/pull/264). From 0507c067f4a159aacfbbf7fa5bc99611180947d3 Mon Sep 17 00:00:00 2001 From: Evgeniy Date: Wed, 23 Aug 2017 18:48:21 +0300 Subject: [PATCH 2/7] Change license --- experimental/babel-preset-env/LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/experimental/babel-preset-env/LICENSE b/experimental/babel-preset-env/LICENSE index c61257ccce..f659b81881 100644 --- a/experimental/babel-preset-env/LICENSE +++ b/experimental/babel-preset-env/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2016 Babel +Copyright (c) 2016-2017 Babel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 5196b94fa54c8febe9c73234eefb3b9b2b0cea7f Mon Sep 17 00:00:00 2001 From: Cory Simmons Date: Wed, 30 Aug 2017 00:25:10 -0400 Subject: [PATCH 3/7] Add Node usage (#398) [skip ci] I can never remember the syntax and end up coming here to copy/paste this snippet all the time. I assume other people want to as well, or at least make it clear for newbs that this can be used with Node without them having to scroll. --- experimental/babel-preset-env/README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/experimental/babel-preset-env/README.md b/experimental/babel-preset-env/README.md index b5c01a29e9..2fcc47cdd8 100644 --- a/experimental/babel-preset-env/README.md +++ b/experimental/babel-preset-env/README.md @@ -18,6 +18,18 @@ npm install babel-preset-env --save-dev } ``` +```json +{ + "presets": [ + ["env", { + "targets": { + "node": "current" + } + }] + ] +} +``` + Check out the many options (especially `useBuiltIns` to polyfill less)! - [How it Works](#how-it-works) From 7c70b27b5306f81aff2d86bc60ddc7f8d869f956 Mon Sep 17 00:00:00 2001 From: Henry Zhu Date: Wed, 6 Sep 2017 00:03:06 -0400 Subject: [PATCH 4/7] add basic example [skip ci] (#409) --- experimental/babel-preset-env/README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/experimental/babel-preset-env/README.md b/experimental/babel-preset-env/README.md index 2fcc47cdd8..d4f6e2b289 100644 --- a/experimental/babel-preset-env/README.md +++ b/experimental/babel-preset-env/README.md @@ -6,6 +6,16 @@ npm install babel-preset-env --save-dev ``` +Acts as a replacement for preset-es2015,16,17,latest + +```json +{ + "presets": ["env"] +} +``` + +You can target specific versions with browserslist + ```json { "presets": [ @@ -18,6 +28,8 @@ npm install babel-preset-env --save-dev } ``` +Or even the current (running) version of Node + ```json { "presets": [ From f3fe5001e6140c6651413e66baa829a5dac88f1c Mon Sep 17 00:00:00 2001 From: Stephen Scott Date: Wed, 13 Sep 2017 11:29:30 -0600 Subject: [PATCH 5/7] Flesh out readme (#410) --- experimental/babel-preset-env/README.md | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/experimental/babel-preset-env/README.md b/experimental/babel-preset-env/README.md index d4f6e2b289..935947b994 100644 --- a/experimental/babel-preset-env/README.md +++ b/experimental/babel-preset-env/README.md @@ -1,12 +1,12 @@ # babel-preset-env [![npm](https://img.shields.io/npm/v/babel-preset-env.svg)](https://www.npmjs.com/package/babel-preset-env) [![travis](https://img.shields.io/travis/babel/babel-preset-env/master.svg)](https://travis-ci.org/babel/babel-preset-env) [![npm-downloads](https://img.shields.io/npm/dm/babel-preset-env.svg)](https://www.npmjs.com/package/babel-preset-env) [![codecov](https://img.shields.io/codecov/c/github/babel/babel-preset-env/master.svg?maxAge=43200)](https://codecov.io/github/babel/babel-preset-env) -> A Babel preset that can automatically determine the Babel plugins and polyfills you need based on your supported environments. +> A Babel preset that gives you everything standardized in [ES2015+](https://github.com/tc39/proposals/blob/master/finished-proposals.md), and can automatically determine the Babel plugins and polyfills you need based on your supported environments. ```sh npm install babel-preset-env --save-dev ``` -Acts as a replacement for preset-es2015,16,17,latest +Without any configuration options, babel-preset-env behaves exactly the same as babel-preset-latest (or babel-preset-es2015, babel-preset-es2016, and babel-preset-es2017 together). ```json { @@ -14,7 +14,9 @@ Acts as a replacement for preset-es2015,16,17,latest } ``` -You can target specific versions with browserslist +You can also configure it to only include the polyfills and transforms needed for the browsers you support. Compiling only what's needed can make your bundles smaller and your life easier. + +This example only includes the polyfills and code transforms needed for the last two versions of each browser, and versions of Safari greater than or equal to 7. We use [browserslist](https://github.com/ai/browserslist) to parse this information, so you can use [any valid query format supported by browserslist](https://github.com/ai/browserslist#queries). ```json { @@ -28,7 +30,21 @@ You can target specific versions with browserslist } ``` -Or even the current (running) version of Node +Similarly, if you're targeting Node.js instead of the browser, you can configure babel-preset-env to only include the polyfills and transforms necessary for a particular version: + +```json +{ + "presets": [ + ["env", { + "targets": { + "node": "6.10" + } + }] + ] +} +``` + +For convenience, you can use `"node": "current"` to only include the necessary polyfills and transforms for the Node.js version that you use to run Babel: ```json { From 4df876b4b5003742f3b73e84496472e097678f6d Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Sat, 16 Sep 2017 00:29:58 -0700 Subject: [PATCH 6/7] Docs: fix claim about node versions in readme --- 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 935947b994..6aca4fea25 100644 --- a/experimental/babel-preset-env/README.md +++ b/experimental/babel-preset-env/README.md @@ -100,7 +100,7 @@ If you are targeting IE 8 and Chrome 55 it will include all plugins required by ### Support a target option `"node": "current"` to compile for the currently running node version. -For example, if you are building on Node 4, arrow functions won't be converted, but they will if you build on Node 0.12. +For example, if you are building on Node 6, arrow functions won't be converted, but they will if you build on Node 0.12. ### Support a `browsers` option like autoprefixer From 8b97a8acf92fd311210c33a53bfcd1675a984441 Mon Sep 17 00:00:00 2001 From: James Hegedus Date: Tue, 19 Sep 2017 09:32:18 +1000 Subject: [PATCH 7/7] Clarify purpose of the tool in README (#419) --- 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 6aca4fea25..6a7381a2ae 100644 --- a/experimental/babel-preset-env/README.md +++ b/experimental/babel-preset-env/README.md @@ -1,6 +1,6 @@ # babel-preset-env [![npm](https://img.shields.io/npm/v/babel-preset-env.svg)](https://www.npmjs.com/package/babel-preset-env) [![travis](https://img.shields.io/travis/babel/babel-preset-env/master.svg)](https://travis-ci.org/babel/babel-preset-env) [![npm-downloads](https://img.shields.io/npm/dm/babel-preset-env.svg)](https://www.npmjs.com/package/babel-preset-env) [![codecov](https://img.shields.io/codecov/c/github/babel/babel-preset-env/master.svg?maxAge=43200)](https://codecov.io/github/babel/babel-preset-env) -> A Babel preset that gives you everything standardized in [ES2015+](https://github.com/tc39/proposals/blob/master/finished-proposals.md), and can automatically determine the Babel plugins and polyfills you need based on your supported environments. +> A Babel preset that compiles [ES2015+](https://github.com/tc39/proposals/blob/master/finished-proposals.md) down to ES5 by automatically determining the Babel plugins and polyfills you need based on your targeted browser or runtime environments. ```sh npm install babel-preset-env --save-dev