Babel preset for all envs.
$ npm install --save-dev babel-preset-env
targets
- an object of browsers/environment versions to support. The data for this is currently at: https://github.com/babel/babel-preset-env/blob/master/src/plugins.js (It would be nice to move this to use a data source like kangax.github.io/compat-table).
We would like help to make the data is correct! This just means usage/testing!
loose
- Enable "loose" transformations for any plugins in this preset that allow them (Disabled by default).modules
- Enable transformation of ES6 module syntax to another module type (Enabled by default to"commonjs"
).- Can be
false
to not transform modules, or one of["amd", "umd", "systemjs", "commonjs"]
- Can be
{
"presets": [
["env", {
"targets": {
"chrome": 52
},
"loose": true,
"modules": false
}]
]
}
// src
export class A {}
// default is to run all transforms
{
"presets": [
["env", {}]
]
}
// ...
var A = exports.A = function A() {
_classCallCheck(this, A);
};
// target chrome 52
{
"presets": [
["env", {
"targets": {
"chrome": 52
}
}]
]
}
// ...
class A {}
exports.A = A;
// target chrome 52 with webpack 2/rollup
{
"presets": [
["env", {
"targets": {
"chrome": 52
},
"modules": false
}]
]
}
// ...
export class A {}