Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Babel support for Object.entries

Tags:

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?

like image 726
damd Avatar asked Jan 29 '16 17:01

damd


People also ask

What are presets in Babel?

In Babel, a preset is a set of plugins used to support particular language features. The two presets Babel uses by default: es2015 : Adds support for ES2015 (or ES6) JavaScript. react : Adds support for JSX.

What is Babel in Android?

Babel is a highly configurable compiler that lets us use newer JavaScript language features (and extensions, like JSX), compiling "down" into older versions of JavaScript that are supported on a wider range of engines.


1 Answers

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"] } 
like image 96
psv Avatar answered Sep 28 '22 03:09

psv