babel-preset-es2015 -> babel-preset-env

We鈥檙e super 馃樃 excited that you鈥檙e trying to use ES2015 syntax, but instead of continuing yearly presets, the team recommends using babel-preset-env. By default, it has the same behavior as previous presets to compile ES2015+ to ES5. Please check out the v1.x readme for more info. (For Babel 7, we have moved the preset into the main babel repo.

Babel 7

If you are using v7 you鈥檒l need npm install @babel/preset-env and "presets": ["@babel/env"]

Upgrading to babel-preset-env

Install

npm install babel-preset-env --save-dev

Basic .babelrc change

{
+  "presets": ["env"]
-  "presets": ["es2015"]
}

.babelrc change with options

{
  "presets": [
+   ["env", {
-   ["es2015", {
      "modules": false
    }]
  ]
}

babel-preset-env is a new preset, first released over a year ago that replaces many presets that were previously used including:

  • babel-preset-es2015, babel-preset-es2016, babel-preset-es2017
  • babel-preset-latest
  • other community plugins involving es20xx:
    • babel-preset-node5, babel-preset-es2015-node, etc

By targeting specific browsers, Babel can do less work so you can ship native ES2015+ 馃槑!

.babelrc against a specific chrome version

{
  "presets": [
    ["env", {
      "targets": {
        "chrome": "60"
      }
    }]
  ]
}

.babelrc against current node version

{
  "presets": [
    ["env", {
      "targets": {
        "node": "current"
      }
    }]
  ]
}

Some history on babel-preset-env

Can check the readme for more information and further docs.