diff --git a/experimental/babel-preset-env/README.md b/experimental/babel-preset-env/README.md index 94c07d8914..b34136b0be 100644 --- a/experimental/babel-preset-env/README.md +++ b/experimental/babel-preset-env/README.md @@ -1,32 +1,36 @@ -## 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) +# 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) > Babel preset for all environments. -### How it currently works +## How it currently works -#### Determine browser support for ECMAScript features (up to `latest`) +### Determine browser support for ECMAScript features (up to `latest`) -[#7](https://github.com/babel/babel-preset-env/issues/7) - Use external data such as [`compat-table`](https://github.com/kangax/compat-table) to determine browser support. We should create PRs there when necessary. +[#7](https://github.com/babel/babel-preset-env/issues/7) - Use external data such as [`compat-table`](https://github.com/kangax/compat-table) to determine browser support. (We should create PRs there when necessary) ![](https://cloud.githubusercontent.com/assets/588473/19214029/58deebce-8d48-11e6-9004-ee3fbcb75d8b.png) -We run the script [build-data.js](/scripts/build-data.js) which creates [plugins.json](/data/plugins.json). +We can periodically run [build-data.js](/scripts/build-data.js) which generates [plugins.json](/data/plugins.json). -#### Make mapping between javascript features and plugins +### Make mapping between javascript features and plugins -This should be straightforward to do in most cases. There might be cases were plugins should be split up more. Currently located at [pluginFeatures.js](/data/pluginFeatures.js). +> Currently located at [pluginFeatures.js](/data/pluginFeatures.js). -#### Support all plugins in Babel that are considered `latest` +This should be straightforward to do in most cases. There might be cases were plugins should be split up more or certain plugins aren't standalone enough (or impossible to do). + +### Support all plugins in Babel that are considered `latest` > Default behavior without options is the same as `babel-preset-latest`. [#14](https://github.com/babel/babel-preset-env/issues/14) - 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/)). -#### Determine the lowest common denominator of plugins to be included in the preset +Support a node option `"node": "current"` to only compile for the current running node version. + +### Determine the lowest common denominator of plugins to be included in the preset If you are targeting IE 8 and Chrome 55 it will include all plugins required by IE 8 since you would need to support both still. -#### Support a `browsers` option like autoprefixer +### Support a `browsers` option like autoprefixer [#19](https://github.com/babel/babel-preset-env/pull/19) - Use [browserslist](https://github.com/ai/browserslist) to also queries like `> 1%, last 2 versions`. @@ -40,29 +44,49 @@ $ npm install --save-dev babel-preset-env ### [Options](http://babeljs.io/docs/plugins/#pluginpresets-options) -* `targets` - an object of browsers/environment versions to support (ex: chrome, node, etc). +#### `targets`: { [string]: number }; + +Defaults to `{}`. + +> Takes an object of environment versions to support. +> Each target environment takes a number (you can specify a decimal like `node: 6.5`) + +Example environments: "chrome, edge, firefox, safari, ie, ios, node". The data for this is currently at: [/data/plugins.json](/data/plugins.json) and being generated by [/scripts/build-data.js](/scripts/build-data.js) using https://kangax.github.io/compat-table. -> We would like help to make sure the data is correct! This just means usage/testing! - -Currently: "chrome, edge, firefox, safari, ie, node". - -> adding `ie` will enable all transforms (may still need es3 transforms) -> Each target takes a number (you can specify a decimal like `node: 6.5`) - -* `browsers` (array/string) - an query to select browsers (ex: last 2 versions, > 5%). - -> Note, browsers' results are overridden by explicit items from `targets`. +##### `node`: number | "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)` -* `loose` (boolean) - Enable "loose" transformations for any plugins in this preset that allow them (Defaults to `false`). -* `modules` - Enable transformation of ES6 module syntax to another module type (Defaults to `"commonjs"`). - * Can be `false` to not transform modules, or one of `["amd", "umd", "systemjs", "commonjs"]`. -* `debug` (boolean) - `console.log` out the targets and plugins being used as well as the version specified in `/data/plugins.json`. (Defaults to `false`) -* `whitelist` (Array) - Enable a whitelist of plugins to always include. (Defaults to `[]`) - * Useful if there is a bug in a native implementation, or a combination of a non-supported feature + a supported one doesn't work. (Ex: Node 4 supports native classes but not spread) +#### `browsers`: Array | string + +> A query to select browsers (ex: last 2 versions, > 5%) using [browserslist](https://github.com/ai/browserslist). + +> Note, browsers' results are overridden by explicit items from `targets`. + +#### `loose`: boolean + +Defaults to `false`. +Enable "loose" transformations for any plugins in this preset that allow them. + +#### `modules`: "amd" | "umd" | "systemjs" | "commonjs" | true | false + +Defaults to `"commonjs"`. +Enable transformation of ES6 module syntax to another module type. +Can be `false` to not transform modules. + +#### `debug:` boolean + +Defaults to `false` +`console.log` out the targets and plugins being used as well as the version specified in `/data/plugins.json`. + +#### `whitelist`: Array + +Defaults to `[]` +Enable a whitelist of plugins to always include. + +Useful if there is a bug in a native implementation, or a combination of a non-supported feature + a supported one doesn't work. (Ex: Node 4 supports native classes but not spread) ### Examples