ES2015 preset

All you need to compile ES2015 to ES5

This preset includes the following plugins:

Basic Setup (with the CLI)

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-node index.js

Installation

$ npm install --save-dev babel-preset-es2015

Usage

Add the following line to your .babelrc file:

{
  "presets": ["es2015"]
}

Options

  • 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"]
  • spec - Enable “spec” transformations for any plugins in this preset that allow them (Disabled by default)
{
  presets: [
    ["es2015", { "loose": true }]
  ]
}
{
  presets: [
    ["es2015", { "modules": false }]
  ]
}
{
  presets: [
    ["es2015", { "loose": true, "modules": false }]
  ]
}
{
  presets: [
    ["es2015", { "spec": true }]
  ]
}