`, defaults to `[]`.
An array of plugins to always exclude/remove.
The possible options are the same as the `include` option.
This option is useful for "blacklisting" a transform like `@babel/plugin-transform-regenerator` if you don't use generators and don't want to include `regeneratorRuntime` (when using `useBuiltIns`) or for using another plugin like [fast-async](https://github.com/MatAtBread/fast-async) instead of [Babel's async-to-gen](http://babeljs.io/docs/plugins/proposal-async-generator-functions/).
### `useBuiltIns`
`"usage"` | `"entry"` | `false`, defaults to `false`.
A way to apply `@babel/preset-env` for polyfills (via `@babel/polyfill`).
```sh
npm install @babel/polyfill --save
```
#### `useBuiltIns: 'usage'`
Adds specific imports for polyfills when they are used in each file. We take advantage of the fact that a bundler will load the same polyfill only once.
**In**
a.js
```js
var a = new Promise();
```
b.js
```js
var b = new Map();
```
**Out (if environment doesn't support it)**
```js
import "core-js/modules/es6.promise";
var a = new Promise();
```
```js
import "core-js/modules/es6.map";
var b = new Map();
```
**Out (if environment supports it)**
```js
var a = new Promise();
```
```js
var b = new Map();
```
#### `useBuiltIns: 'entry'`
> NOTE: Only use `require("@babel/polyfill");` once in your whole app.
> Multiple imports or requires of `@babel/polyfill` will throw an error since it can cause global collisions and other issues that are hard to trace.
> We recommend creating a single entry file that only contains the `require` statement.
This option enables a new plugin that replaces the statement `import "@babel/polyfill"` or `require("@babel/polyfill")` with individual requires for `@babel/polyfill` based on environment.
**In**
```js
import "@babel/polyfill";
```
**Out (different based on environment)**
```js
import "core-js/modules/es7.string.pad-start";
import "core-js/modules/es7.string.pad-end";
```
This will also work for `core-js` directly (`import "core-js";` or `require('core-js');`)
#### `useBuiltIns: false`
Don't add polyfills automatically per file, or transform `import "@babel/polyfill"` to individual polyfills.
### `forceAllTransforms`
`boolean`, defaults to `false`.
Example
With Babel 7's .babelrc.js support, you can force all transforms to be run if env is set to `production`.
```js
module.exports = {
presets: [
["@babel/preset-env", {
targets: {
chrome: 59,
edge: 13,
firefox: 50,
},
// for uglifyjs...
forceAllTransforms: process.env === "production"
}],
],
};
```
> NOTE: `targets.uglify` is deprecated and will be removed in the next major in
favor of this.
By default, this preset will run all the transforms needed for the targeted
environment(s). Enable this option if you want to force running _all_
transforms, which is useful if the output will be run through UglifyJS or an
environment that only supports ES5.
> 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 [babel-minify](https://github.com/babel/minify).
### `configPath`
`string`, defaults to `process.cwd()`
The starting point where the config search for browserslist will start, and ascend to the system root until found.
### `ignoreBrowserslistConfig`
`boolean`, defaults to `false`
Toggles whether or not [browserslist config sources](https://github.com/ai/browserslist#queries) are used, which includes searching for any browserslist files or referencing the browserslist key inside package.json. This is useful for projects that use a browserslist config for files that won't be compiled with Babel.
### `shippedProposals`
`boolean`, defaults to `false`
Toggles enabling support for builtin/feature proposals that have shipped in browsers. If your target environments have native support for a feature proposal, its matching parser syntax plugin is enabled instead of performing any transform. Note that this _does not_ enable the same transformations as [`@babel/preset-stage3`](https://babeljs.io/docs/plugins/preset-stage-3/), since proposals can continue to change before landing in browsers.
The following are currently supported:
**Builtins**
- [Promise.prototype.finally](https://github.com/tc39/proposal-promise-finally)
**Features**
- [Asynchronous Iterators](https://github.com/tc39/proposal-async-iteration)
- [Object rest/spread properties](https://github.com/tc39/proposal-object-rest-spread)
- [Optional catch binding](https://github.com/tc39/proposal-optional-catch-binding)
- [Unicode property escapes in regular expressions](https://github.com/tc39/proposal-regexp-unicode-property-escapes)
---
## Examples
### Export with various targets
```js
export class A {}
```
#### Target only Chrome 52
**.babelrc**
```json
{
"presets": [
["@babel/preset-env", {
"targets": {
"chrome": 52
}
}]
]
}
```
**Out**
```js
class A {}
exports.A = A;
```
#### Target Chrome 52 with webpack 2/rollup and loose mode
**.babelrc**
```json
{
"presets": [
["@babel/preset-env", {
"targets": {
"chrome": 52
},
"modules": false,
"loose": true
}]
]
}
```
**Out**
```js
export class A {}
```
#### Target specific browsers via browserslist
**.babelrc**
```json
{
"presets": [
["@babel/preset-env", {
"targets": {
"chrome": 52,
"browsers": ["last 2 versions", "safari 7"]
}
}]
]
}
```
**Out**
```js
export var A = function A() {
_classCallCheck(this, A);
};
```
#### Target latest node via `node: true` or `node: "current"`
**.babelrc**
```json
{
"presets": [
["@babel/preset-env", {
"targets": {
"node": "current"
}
}]
]
}
```
**Out**
```js
class A {}
exports.A = A;
```
### Show debug output
**.babelrc**
```json
{
"presets": [
["@babel/preset-env", {
"targets": {
"safari": 10
},
"modules": false,
"useBuiltIns": "entry",
"debug": true
}]
]
}
```
**stdout**
```sh
Using targets:
{
"safari": 10
}
Modules transform: false
Using plugins:
@babel/plugin-transform-exponentiation-operator {}
@babel/plugin-transform-async-to-generator {}
Using polyfills:
es7.object.values {}
es7.object.entries {}
es7.object.get-own-property-descriptors {}
web.timers {}
web.immediate {}
web.dom.iterable {}
```
### Include and exclude specific plugins/built-ins
> always include arrow functions, explicitly exclude generators
```json
{
"presets": [
["@babel/preset-env", {
"targets": {
"browsers": ["last 2 versions", "safari >= 7"]
},
"include": ["@babel/plugin-transform-arrow-functions", "es6.map"],
"exclude": ["@babel/plugin-transform-regenerator", "es6.set"]
}]
]
}
```
## Issues
If you get a `SyntaxError: Unexpected token ...` error when using the [object-rest-spread](https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-object-rest-spread) transform then make sure the plugin has been updated to, at least, `v6.19.0`.