Babel support for Object.entries

damd picture damd · Jan 29, 2016 · Viewed 23.6k times · Source

I'm looking at the stage 3 proposal of Object.values/Object.entries and I'd really like to use it in my current JavaScript project.

However, I can't figure out whether there's any Babel preset which supports it. Since the GitHub repository linked above says it's a stage 3 proposal, I assumed it would be part of babel-preset-stage-3, but it seems not.

Is there any Babel preset (or even plugin?) that lets me use Object.entries today?

Answer

psv picture psv · Apr 29, 2016

Using babel, installing

  1. babel-preset-env
  2. babel-plugin-transform-runtime

gives support for Object.values/Object.entries as well as other *ES20** functionality.

As per recommendation by the modules, configure .babelrc with the following:

{
  "plugins": ["transform-runtime"],
  "presets": ["env"]
}