If you want to stay up to date, use the env preset
This preset includes the following plugins:
You can also check out the React Getting Started page
For more info, check out the setup page on the cli and the usage docs.
Install the CLI and this preset
npm install --save-dev babel-cli babel-preset-es2015
Make a .babelrc config file with the preset
echo '{ "presets": ["es2015"] }' > .babelrc
Create a file to run on
echo 'console.log([1, 2, 3].map(n => n + 1))' > index.js
Run it
./node_modules/.bin/babel index.js
npm install --save-dev babel-preset-es2015
.babelrc
(Recommended).babelrc
{
"presets": ["es2015"]
}
babel script.js --presets es2015
require("babel-core").transform("code", {
presets: ["es2015"]
});
loose
boolean
, defaults to false
.
Enable “loose” transformations for any plugins in this preset that allow them.
modules
"amd" | "umd" | "systemjs" | "commonjs" | false
, defaults to "commonjs"
.
Enable transformation of ES6 module syntax to another module type.
Setting this to false
will not transform modules.
spec
boolean
, defaults to false
.
Enable “spec” transformations for any plugins in this preset that allow them.