babel-plugin-polyfill-corejs2 0.1.1 → 0.1.2
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.
- package/lib/index.js +6 -5
- package/package.json +2 -2
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 ?
|
|
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}
|
|
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
|
|
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
|
|
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.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A Babel plugin to inject imports to core-js@2 polyfills",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@babel/core": "^7.0.0-0"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "b1a6b262d1de56486a2ab662ecc25834be6d2ad5"
|
|
33
33
|
}
|