babel-plugin-polyfill-corejs2 0.1.1 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,10 @@
3
3
  exports.__esModule = true;
4
4
  exports.StaticProperties = exports.InstanceProperties = exports.BuiltIns = exports.CommonIterators = void 0;
5
5
 
6
+ var _corejs2BuiltIns = _interopRequireDefault(require("@babel/compat-data/corejs2-built-ins"));
7
+
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+
6
10
  const define = (name, pure, global = [], meta) => {
7
11
  return {
8
12
  name,
@@ -91,7 +95,6 @@ const InstanceProperties = {
91
95
  repeat: globalOnly(["es6.string.repeat"]),
92
96
  replace: globalOnly(["es6.regexp.replace"]),
93
97
  search: globalOnly(["es6.regexp.search"]),
94
- slice: globalOnly(["es6.array.slice"]),
95
98
  small: globalOnly(["es6.string.small"]),
96
99
  some: globalOnly(["es6.array.some"]),
97
100
  sort: globalOnly(["es6.array.sort"]),
@@ -109,8 +112,14 @@ const InstanceProperties = {
109
112
  trimRight: globalOnly(["es7.string.trim-right"]),
110
113
  trimStart: globalOnly(["es7.string.trim-left"]),
111
114
  values: globalOnly(ArrayNatureIterators)
112
- };
115
+ }; // This isn't present in older @babel/compat-data versions
116
+
113
117
  exports.InstanceProperties = InstanceProperties;
118
+
119
+ if ("es6.array.slice" in _corejs2BuiltIns.default) {
120
+ InstanceProperties.slice = globalOnly(["es6.array.slice"]);
121
+ }
122
+
114
123
  const StaticProperties = {
115
124
  Array: {
116
125
  from: pureAndGlobal("array/from", ["es6.symbol", "es6.array.from", ...CommonIterators]),
package/lib/index.js CHANGED
@@ -28,7 +28,8 @@ var _default = (0, _helperDefinePolyfillProvider.default)(function (api, {
28
28
  } = {},
29
29
  [runtimeCompat]: {
30
30
  useBabelRuntime,
31
- runtimeVersion
31
+ runtimeVersion,
32
+ ext = ".js"
32
33
  } = {}
33
34
  }) {
34
35
  const resolve = api.createMetaResolver({
@@ -42,7 +43,7 @@ var _default = (0, _helperDefinePolyfillProvider.default)(function (api, {
42
43
  method
43
44
  } = api;
44
45
  const polyfills = (0, _addPlatformSpecificPolyfills.default)(api.targets, method, _corejs2BuiltIns.default);
45
- const coreJSBase = useBabelRuntime ? "@babel/runtime-corejs2/core-js" : method === "usage-pure" ? "core-js/library/fn" : "core-js/modules";
46
+ const coreJSBase = useBabelRuntime ? `${useBabelRuntime}/core-js` : method === "usage-pure" ? "core-js/library/fn" : "core-js/modules";
46
47
 
47
48
  function inject(name, utils) {
48
49
  if (typeof name === "string") {
@@ -75,7 +76,7 @@ var _default = (0, _helperDefinePolyfillProvider.default)(function (api, {
75
76
  return;
76
77
  }
77
78
 
78
- return utils.injectDefaultImport(`${coreJSBase}/${pure}.js`, hint);
79
+ return utils.injectDefaultImport(`${coreJSBase}/${pure}${ext}`, hint);
79
80
  }
80
81
 
81
82
  return {
@@ -111,7 +112,7 @@ var _default = (0, _helperDefinePolyfillProvider.default)(function (api, {
111
112
  usagePure(meta, utils, path) {
112
113
  if (meta.kind === "in") {
113
114
  if (meta.key === "Symbol.iterator") {
114
- path.replaceWith(_core.types.callExpression(utils.injectDefaultImport(`${coreJSBase}/is-iterable.js`, "isIterable"), [path.node.right]));
115
+ path.replaceWith(_core.types.callExpression(utils.injectDefaultImport(`${coreJSBase}/is-iterable${ext}`, "isIterable"), [path.node.right]));
115
116
  }
116
117
 
117
118
  return;
@@ -129,7 +130,7 @@ var _default = (0, _helperDefinePolyfillProvider.default)(function (api, {
129
130
  if (meta.key === "Symbol.iterator" && shouldInjectPolyfill("es6.symbol") && path.parentPath.isCallExpression({
130
131
  callee: path.node
131
132
  }) && path.parent.arguments.length === 0) {
132
- path.parentPath.replaceWith(_core.types.callExpression(utils.injectDefaultImport(`${coreJSBase}/get-iterator.js`, "getIterator"), [path.node.object]));
133
+ path.parentPath.replaceWith(_core.types.callExpression(utils.injectDefaultImport(`${coreJSBase}/get-iterator${ext}`, "getIterator"), [path.node.object]));
133
134
  path.skip();
134
135
  return;
135
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-plugin-polyfill-corejs2",
3
- "version": "0.1.1",
3
+ "version": "0.1.5",
4
4
  "description": "A Babel plugin to inject imports to core-js@2 polyfills",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,12 +16,12 @@
16
16
  "babel-plugin"
17
17
  ],
18
18
  "dependencies": {
19
- "@babel/compat-data": "^7.11.0",
20
- "@babel/helper-define-polyfill-provider": "^0.1.0",
19
+ "@babel/compat-data": "^7.13.0",
20
+ "@babel/helper-define-polyfill-provider": "^0.1.2",
21
21
  "semver": "^6.1.1"
22
22
  },
23
23
  "devDependencies": {
24
- "@babel/core": "^7.11.5",
24
+ "@babel/core": "^7.13.0",
25
25
  "@babel/helper-plugin-test-runner": "^7.10.4",
26
26
  "@babel/plugin-transform-for-of": "^7.10.4",
27
27
  "@babel/plugin-transform-modules-commonjs": "^7.10.4"
@@ -29,5 +29,5 @@
29
29
  "peerDependencies": {
30
30
  "@babel/core": "^7.0.0-0"
31
31
  },
32
- "gitHead": "57edac90ba049d5ac2386cfaa0be131a68030d21"
32
+ "gitHead": "55f582c8ebc4b8a181a51fecaa92c89158cc7ac9"
33
33
  }