Babel Plugin Transform ES2017 Object Entries

raw JSON →
0.0.5 verified Sat Apr 25 auth: no javascript deprecated

Babel plugin (v0.0.5, last updated 2017) that replaces `Object.entries()` and `Object.values()` calls with ES5-compatible generated functions. Unlike alternatives that import core-js polyfills, this plugin inlines inline implementations. It only handles these two methods, not the full object spread or other ES2017 features. Use is discouraged in favor of modern @babel/preset-env with core-js or direct polyfill imports.

error Module build failed: Error: Plugin 0 specified in "../.babelrc" provided an invalid property of type "function".
cause Using the plugin name as default import in babel.config.js instead of string reference.
fix
Use string plugin name in plugins array, e.g., plugins: ['transform-es2017-object-entries']
error ReferenceError: Object.entries is not defined
cause Plugin did not transform the call because it wasn't a direct call to Object.entries.
fix
Rewrite as direct call: Object.entries(obj) or use a different polyfill strategy.
deprecated Package is deprecated; last release over 7 years ago, no updates for modern Babel 7+.
fix Use @babel/preset-env with core-js or @babel/plugin-proposal-object-entries (via preset-env).
gotcha Only transforms call expressions directly on Object.entries/Object.values; not polyfilled if accessed via variable or prototype.
fix Ensure calls are written as `Object.entries(obj)` not `const {entries} = Object; entries(obj)`.
gotcha Does not handle Symbol properties or non-enumerable properties; matches native Object.entries behavior.
fix Accept limitation; use a more complete polyfill if needed.
npm install babel-plugin-transform-es2017-object-entries
yarn add babel-plugin-transform-es2017-object-entries
pnpm add babel-plugin-transform-es2017-object-entries

Shows Babel configuration and transformation of Object.entries and Object.values to ES5 inline functions.

// .babelrc
{
  "plugins": ["transform-es2017-object-entries"]
}

// input.js
const obj = { a: 1, b: 2 };
const entries = Object.entries(obj);
const values = Object.values(obj);

// output (transpiled)
var _entries = function (obj) {
  var ownProps = Object.keys(obj);
  var i = ownProps.length;
  var resArray = new Array(i);
  while (i--) resArray[i] = [ownProps[i], obj[ownProps[i]]];
  return resArray;
};
var _values = function (obj) {
  var ownProps = Object.keys(obj);
  var i = ownProps.length;
  var resArray = new Array(i);
  while (i--) resArray[i] = obj[ownProps[i]];
  return resArray;
};

var entries = _entries(obj);
var values = _values(obj);