babel-plugin-polyfill-corejs2 0.1.3 → 0.1.8
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/built-in-definitions.js +11 -2
- package/lib/index.js +5 -9
- package/package.json +4 -4
|
@@ -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
|
@@ -47,7 +47,9 @@ var _default = (0, _helperDefinePolyfillProvider.default)(function (api, {
|
|
|
47
47
|
|
|
48
48
|
function inject(name, utils) {
|
|
49
49
|
if (typeof name === "string") {
|
|
50
|
-
|
|
50
|
+
// Some polyfills aren't always available, for example
|
|
51
|
+
// web.dom.iterable when targeting node
|
|
52
|
+
if (has(polyfills, name) && shouldInjectPolyfill(name)) {
|
|
51
53
|
debug(name);
|
|
52
54
|
utils.injectGlobalImport(`${coreJSBase}/${name}.js`);
|
|
53
55
|
}
|
|
@@ -58,12 +60,6 @@ var _default = (0, _helperDefinePolyfillProvider.default)(function (api, {
|
|
|
58
60
|
name.forEach(name => inject(name, utils));
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
function injectIfAvailable(name, utils) {
|
|
62
|
-
// Some polyfills aren't always available, for example
|
|
63
|
-
// web.dom.iterable when targeting node
|
|
64
|
-
if (has(polyfills, name)) inject(name, utils);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
63
|
function maybeInjectPure(desc, hint, utils) {
|
|
68
64
|
const {
|
|
69
65
|
pure,
|
|
@@ -146,13 +142,13 @@ var _default = (0, _helperDefinePolyfillProvider.default)(function (api, {
|
|
|
146
142
|
// yield*
|
|
147
143
|
YieldExpression(path) {
|
|
148
144
|
if (path.node.delegate) {
|
|
149
|
-
|
|
145
|
+
inject("web.dom.iterable", api.getUtils(path));
|
|
150
146
|
}
|
|
151
147
|
},
|
|
152
148
|
|
|
153
149
|
// for-of, [a, b] = c
|
|
154
150
|
"ForOfStatement|ArrayPattern"(path) {
|
|
155
|
-
_builtInDefinitions.CommonIterators.forEach(name =>
|
|
151
|
+
_builtInDefinitions.CommonIterators.forEach(name => inject(name, api.getUtils(path)));
|
|
156
152
|
}
|
|
157
153
|
|
|
158
154
|
}
|
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.8",
|
|
4
4
|
"description": "A Babel plugin to inject imports to core-js@2 polyfills",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"babel-plugin"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@babel/compat-data": "^7.
|
|
20
|
-
"@babel/helper-define-polyfill-provider": "^0.1.
|
|
19
|
+
"@babel/compat-data": "^7.13.0",
|
|
20
|
+
"@babel/helper-define-polyfill-provider": "^0.1.4",
|
|
21
21
|
"semver": "^6.1.1"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@babel/core": "^7.0.0-0"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "6e6c7d2925b0f512397518d9f5ec35c925ea9960"
|
|
33
33
|
}
|