babel preset latest for node 7 (deprecated), node 8 (latest) or node 6 (LTS)
target
:6
,6.5
,7
,7.6
,8
,8.3
or'current'
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 "commonjs"es2016
- Enable es2016 features (Enabled by default)es2017
- Enable es2017 features (Enabled by default)esnext
- Enable features in stages but already available in recent node version (Enabled by default)
Feature | Node 6 | Node 6.5 | Node 7 | Node 7.6 | Node 8 | Node 8.3 |
---|---|---|---|---|---|---|
transform-es2015-modules-commonjs | no | no | no | no | no | no |
transform-es2015-function-name | flag | yes | yes | yes | yes | yes |
transform-exponentiation-operator | no | flag | yes | yes | yes | yes |
syntax-trailing-function-commas | no | no | no | no | yes | yes |
transform-async-to-generator | no | no | flag | yes | yes | yes |
transform-object-rest-spread | no | no | no | no | flag | yes |
npm install --save-dev babel-preset-latest-node
yarn add --dev babel-preset-latest-node
.babelrc
{
"presets": ["latest-node"]
}
{
"presets": [["latest-node", { "target": "current" }]]
}
babel script.js --presets latest-node
require("babel-core").transform("code", {
presets: [require('babel-preset-latest-node')]
});
require("babel-core").transform("code", {
presets: [[require('babel-preset-latest-node'), { target: 'current' }]]
});