diff --git a/packages/babel-plugin-polyfill-es-shims/README.md b/packages/babel-plugin-polyfill-es-shims/README.md index a8687a9d..fa1e7b38 100644 --- a/packages/babel-plugin-polyfill-es-shims/README.md +++ b/packages/babel-plugin-polyfill-es-shims/README.md @@ -43,6 +43,7 @@ This plugin supports the following `es-shims` polyfills. | `Array.prototype.reduce` | [`array.prototype.reduce`](https://github.com/es-shims/Array.prototype.reduce) | | `Array.prototype.reduceRight` | [`array.prototype.reduceright`](https://github.com/es-shims/Array.prototype.reduceRight) | | `Array.prototype.some` | [`array.prototype.some`](https://github.com/es-shims/Array.prototype.some) | +| `Object.keys` | [`object.keys`](https://github.com/ljharb/object-keys) | [@ljharb](https://github.com/ljharb) | `String.prototype.split` | [`string.prototype.split`](https://github.com/es-shims/String.prototype.split) | ### ES2015 (ES6) diff --git a/packages/babel-plugin-polyfill-es-shims/data/polyfills.json b/packages/babel-plugin-polyfill-es-shims/data/polyfills.json index 9fd66bab..b68a94c4 100644 --- a/packages/babel-plugin-polyfill-es-shims/data/polyfills.json +++ b/packages/babel-plugin-polyfill-es-shims/data/polyfills.json @@ -290,6 +290,20 @@ "samsung": "11", "electron": "5" }, + "Object.keys": { + "chrome": "5", + "opera": "12", + "edge": "12", + "firefox": "4", + "safari": "4", + "node": "0.10", + "ie": "9", + "android": "4", + "ios": "6", + "phantom": "2", + "samsung": "1", + "electron": "0.20" + }, "Object.getOwnPropertyDescriptors": { "chrome": "54", "opera": "41", diff --git a/packages/babel-plugin-polyfill-es-shims/missing-polyfills.md b/packages/babel-plugin-polyfill-es-shims/missing-polyfills.md index 0156c512..c1116ba1 100644 --- a/packages/babel-plugin-polyfill-es-shims/missing-polyfills.md +++ b/packages/babel-plugin-polyfill-es-shims/missing-polyfills.md @@ -20,7 +20,6 @@ - `Array.prototype.copyWithin()` - `Array.prototype.fill()` - `Array.prototype.indexOf()` -- `Object.keys()` - `Object.setPrototypeOf()` - `Math.acosh()` - `Math.asinh()` diff --git a/packages/babel-plugin-polyfill-es-shims/src/mappings.js b/packages/babel-plugin-polyfill-es-shims/src/mappings.js index c294686e..00fb9ba8 100644 --- a/packages/babel-plugin-polyfill-es-shims/src/mappings.js +++ b/packages/babel-plugin-polyfill-es-shims/src/mappings.js @@ -72,6 +72,7 @@ defineStatic("Object", "assign", "4.1.0"); defineStatic("Object", "entries", "1.1.1"); defineStatic("Object", "fromEntries", "2.0.2"); defineStatic("Object", "is", "1.1.2", "object-is"); +defineStatic("Object", "keys", "1.1.1", "object-keys"); defineStatic("Object", "getOwnPropertyDescriptors", "2.1.0"); defineStatic("Object", "values", "1.1.1"); diff --git a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-global/conflict-static-instance-1/output.mjs b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-global/conflict-static-instance-1/output.mjs index 7b5128e2..9ec1d885 100644 --- a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-global/conflict-static-instance-1/output.mjs +++ b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-global/conflict-static-instance-1/output.mjs @@ -1,4 +1,5 @@ import "object.entries/auto"; +import "object-keys/auto"; import "object.values/auto"; Object.entries(); Object.keys(); diff --git a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-global/conflict-static-instance-1/stderr.txt b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-global/conflict-static-instance-1/stderr.txt index 2e5b4726..403e63cf 100644 --- a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-global/conflict-static-instance-1/stderr.txt +++ b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-global/conflict-static-instance-1/stderr.txt @@ -1,4 +1,4 @@ Some polyfills have been added but are not present in your dependencies. Please run one of the following commands: - npm install --save object.entries@^1.1.1 object.values@^1.1.1 - yarn add object.entries@^1.1.1 object.values@^1.1.1 + npm install --save object-keys@^1.1.1 object.entries@^1.1.1 object.values@^1.1.1 + yarn add object-keys@^1.1.1 object.entries@^1.1.1 object.values@^1.1.1 diff --git a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-global/static-methods/output.mjs b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-global/static-methods/output.mjs index 0ca1cf05..c3fec5f4 100644 --- a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-global/static-methods/output.mjs +++ b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-global/static-methods/output.mjs @@ -1,3 +1,4 @@ +import "object-keys/auto"; import "object.assign/auto"; Object.keys(foo); const getOwnPropertySymbols = Object.getOwnPropertySymbols; diff --git a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-global/static-methods/stderr.txt b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-global/static-methods/stderr.txt index 7f0cd84b..27807118 100644 --- a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-global/static-methods/stderr.txt +++ b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-global/static-methods/stderr.txt @@ -1,4 +1,4 @@ Some polyfills have been added but are not present in your dependencies. Please run one of the following commands: - npm install --save object.assign@^4.1.0 - yarn add object.assign@^4.1.0 + npm install --save object-keys@^1.1.1 object.assign@^4.1.0 + yarn add object-keys@^1.1.1 object.assign@^4.1.0 diff --git a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/conflict-static-instance/output.mjs b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/conflict-static-instance/output.mjs index 3671d0b2..566fab99 100644 --- a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/conflict-static-instance/output.mjs +++ b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/conflict-static-instance/output.mjs @@ -2,6 +2,7 @@ var _obj, _obj2, _obj3, _str; import _ObjectEntries from "object.entries"; import _ArrayPrototypeEntries from "array.prototype.entries"; +import _ObjectKeys from "object-keys"; import _ArrayPrototypeKeys from "array.prototype.keys"; import _ObjectValues from "object.values"; import _ArrayPrototypeValues from "array.prototype.values"; @@ -13,7 +14,8 @@ _ObjectEntries(); _ArrayPrototypeEntries([]); -Object.keys(); +_ObjectKeys(); + (_obj2 = obj, Array.isArray(_obj2) ? _ArrayPrototypeKeys : Function.call.bind(_obj2.keys))(_obj2); _ArrayPrototypeKeys([]); diff --git a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/conflict-static-instance/stderr.txt b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/conflict-static-instance/stderr.txt index e166c5e9..c5c526a9 100644 --- a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/conflict-static-instance/stderr.txt +++ b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/conflict-static-instance/stderr.txt @@ -1,4 +1,4 @@ Some polyfills have been added but are not present in your dependencies. Please run one of the following commands: - npm install --save array.prototype.entries@^1.0.0 array.prototype.keys@^1.0.0 array.prototype.values@^1.0.0 object.entries@^1.1.1 object.values@^1.1.1 string.prototype.split@^1.0.1 - yarn add array.prototype.entries@^1.0.0 array.prototype.keys@^1.0.0 array.prototype.values@^1.0.0 object.entries@^1.1.1 object.values@^1.1.1 string.prototype.split@^1.0.1 + npm install --save array.prototype.entries@^1.0.0 array.prototype.keys@^1.0.0 array.prototype.values@^1.0.0 object-keys@^1.1.1 object.entries@^1.1.1 object.values@^1.1.1 string.prototype.split@^1.0.1 + yarn add array.prototype.entries@^1.0.0 array.prototype.keys@^1.0.0 array.prototype.values@^1.0.0 object-keys@^1.1.1 object.entries@^1.1.1 object.values@^1.1.1 string.prototype.split@^1.0.1 diff --git a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/modules-loose/output.js b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/modules-loose/output.js index 39f4615b..9446fa85 100644 --- a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/modules-loose/output.js +++ b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/modules-loose/output.js @@ -1,5 +1,7 @@ "use strict"; +var _ObjectKeys = require("object-keys"); + exports.__esModule = true; var _exportNames = { exp: true @@ -16,7 +18,7 @@ var _fuz = require("fuz"); var _mod = require("mod"); -Object.keys(_mod).forEach(function (key) { +_ObjectKeys(_mod).forEach(function (key) { if (key === "default" || key === "__esModule") return; if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; exports[key] = _mod[key]; diff --git a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/modules-loose/stderr.txt b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/modules-loose/stderr.txt index a7fa9658..cc7b1836 100644 --- a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/modules-loose/stderr.txt +++ b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/modules-loose/stderr.txt @@ -1,4 +1,4 @@ Some polyfills have been added but are not present in your dependencies. Please run one of the following commands: - npm install --save array-includes@^3.1.1 string.prototype.includes@^2.0.0 - yarn add array-includes@^3.1.1 string.prototype.includes@^2.0.0 + npm install --save array-includes@^3.1.1 object-keys@^1.1.1 string.prototype.includes@^2.0.0 + yarn add array-includes@^3.1.1 object-keys@^1.1.1 string.prototype.includes@^2.0.0 diff --git a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/modules/output.js b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/modules/output.js index c4f2b258..f523c590 100644 --- a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/modules/output.js +++ b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/modules/output.js @@ -1,5 +1,7 @@ "use strict"; +var _ObjectKeys = require("object-keys"); + Object.defineProperty(exports, "__esModule", { value: true }); @@ -18,7 +20,7 @@ var _fuz = require("fuz"); var _mod = require("mod"); -Object.keys(_mod).forEach(function (key) { +_ObjectKeys(_mod).forEach(function (key) { if (key === "default" || key === "__esModule") return; if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; Object.defineProperty(exports, key, { diff --git a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/modules/stderr.txt b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/modules/stderr.txt index a7fa9658..cc7b1836 100644 --- a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/modules/stderr.txt +++ b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/modules/stderr.txt @@ -1,4 +1,4 @@ Some polyfills have been added but are not present in your dependencies. Please run one of the following commands: - npm install --save array-includes@^3.1.1 string.prototype.includes@^2.0.0 - yarn add array-includes@^3.1.1 string.prototype.includes@^2.0.0 + npm install --save array-includes@^3.1.1 object-keys@^1.1.1 string.prototype.includes@^2.0.0 + yarn add array-includes@^3.1.1 object-keys@^1.1.1 string.prototype.includes@^2.0.0 diff --git a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/static-methods/output.mjs b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/static-methods/output.mjs index ffd191cc..aa310b32 100644 --- a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/static-methods/output.mjs +++ b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/static-methods/output.mjs @@ -6,6 +6,7 @@ import _ObjectEntries from "object.entries"; import _ObjectFromEntries from "object.fromentries"; import _ObjectGetOwnPropertyDescriptors from "object.getownpropertydescriptors"; import _ObjectIs from "object-is"; +import _ObjectKeys from "object-keys"; import _ObjectValues from "object.values"; import _ReflectOwnKeys from "reflect.ownkeys"; import _StringFromCodePoint from "string.fromcodepoint"; @@ -70,7 +71,7 @@ Object.isExtensible; Object.isFrozen; Object.isSealed; _ObjectIs; -Object.keys; +_ObjectKeys; Object.preventExtensions; Object.seal; Object.setPrototypeOf; diff --git a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/static-methods/stderr.txt b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/static-methods/stderr.txt index 28db0b4e..f786ce5b 100644 --- a/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/static-methods/stderr.txt +++ b/packages/babel-plugin-polyfill-es-shims/test/fixtures/usage-pure/static-methods/stderr.txt @@ -1,4 +1,4 @@ Some polyfills have been added but are not present in your dependencies. Please run one of the following commands: - npm install --save array.from@^1.1.0 array.of@^1.0.0 is-nan@^1.2.1 object-is@^1.1.2 object.assign@^4.1.0 object.entries@^1.1.1 object.fromentries@^2.0.2 object.getownpropertydescriptors@^2.1.0 object.values@^1.1.1 reflect.ownkeys@^1.0.1 string.fromcodepoint@^1.0.0 - yarn add array.from@^1.1.0 array.of@^1.0.0 is-nan@^1.2.1 object-is@^1.1.2 object.assign@^4.1.0 object.entries@^1.1.1 object.fromentries@^2.0.2 object.getownpropertydescriptors@^2.1.0 object.values@^1.1.1 reflect.ownkeys@^1.0.1 string.fromcodepoint@^1.0.0 + npm install --save array.from@^1.1.0 array.of@^1.0.0 is-nan@^1.2.1 object-is@^1.1.2 object-keys@^1.1.1 object.assign@^4.1.0 object.entries@^1.1.1 object.fromentries@^2.0.2 object.getownpropertydescriptors@^2.1.0 object.values@^1.1.1 reflect.ownkeys@^1.0.1 string.fromcodepoint@^1.0.0 + yarn add array.from@^1.1.0 array.of@^1.0.0 is-nan@^1.2.1 object-is@^1.1.2 object-keys@^1.1.1 object.assign@^4.1.0 object.entries@^1.1.1 object.fromentries@^2.0.2 object.getownpropertydescriptors@^2.1.0 object.values@^1.1.1 reflect.ownkeys@^1.0.1 string.fromcodepoint@^1.0.0 diff --git a/scripts/build-es-shims-data/es-shims-features.js b/scripts/build-es-shims-data/es-shims-features.js index 2bf61880..201da44c 100644 --- a/scripts/build-es-shims-data/es-shims-features.js +++ b/scripts/build-es-shims-data/es-shims-features.js @@ -36,6 +36,7 @@ module.exports = { "Object.is": "Object static methods / Object.is", "Object.entries": "Object static methods / Object.entries", "Object.fromEntries": "Object.fromEntries", + "Object.keys": "Object static methods / Object.keys", "Object.getOwnPropertyDescriptors": "Object static methods / Object.getOwnPropertyDescriptors", "Object.values": "Object static methods / Object.values", diff --git a/yarn.lock b/yarn.lock index c3c829e1..6620253c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -166,7 +166,7 @@ __metadata: languageName: node linkType: hard -"@babel/helper-define-polyfill-provider@^0.0.4, @babel/helper-define-polyfill-provider@workspace:packages/babel-helper-define-polyfill-provider": +"@babel/helper-define-polyfill-provider@^0.0.5, @babel/helper-define-polyfill-provider@workspace:packages/babel-helper-define-polyfill-provider": version: 0.0.0-use.local resolution: "@babel/helper-define-polyfill-provider@workspace:packages/babel-helper-define-polyfill-provider" dependencies: @@ -3596,7 +3596,7 @@ __metadata: dependencies: "@babel/compat-data": ^7.11.0 "@babel/core": ^7.11.5 - "@babel/helper-define-polyfill-provider": ^0.0.4 + "@babel/helper-define-polyfill-provider": ^0.0.5 "@babel/helper-plugin-test-runner": ^7.10.4 "@babel/plugin-transform-for-of": ^7.10.4 "@babel/plugin-transform-modules-commonjs": ^7.10.4 @@ -3611,7 +3611,7 @@ __metadata: resolution: "babel-plugin-polyfill-corejs3@workspace:packages/babel-plugin-polyfill-corejs3" dependencies: "@babel/core": ^7.11.5 - "@babel/helper-define-polyfill-provider": ^0.0.4 + "@babel/helper-define-polyfill-provider": ^0.0.5 "@babel/helper-plugin-test-runner": ^7.10.4 "@babel/plugin-syntax-dynamic-import": ^7.8.3 "@babel/plugin-transform-for-of": ^7.10.4 @@ -3628,7 +3628,7 @@ __metadata: resolution: "babel-plugin-polyfill-es-shims@workspace:packages/babel-plugin-polyfill-es-shims" dependencies: "@babel/core": ^7.11.5 - "@babel/helper-define-polyfill-provider": ^0.0.4 + "@babel/helper-define-polyfill-provider": ^0.0.5 "@babel/helper-plugin-test-runner": ^7.10.4 array.from: ^1.1.0 peerDependencies: @@ -3641,7 +3641,7 @@ __metadata: resolution: "babel-plugin-polyfill-regenerator@workspace:packages/babel-plugin-polyfill-regenerator" dependencies: "@babel/core": ^7.11.5 - "@babel/helper-define-polyfill-provider": ^0.0.4 + "@babel/helper-define-polyfill-provider": ^0.0.5 "@babel/helper-plugin-test-runner": ^7.10.4 peerDependencies: "@babel/core": ^7.0.0-0