babel-plugin-polyfill-corejs2 0.1.5 → 0.1.6

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.
Files changed (2) hide show
  1. package/lib/index.js +5 -9
  2. package/package.json +2 -2
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
- if (shouldInjectPolyfill(name)) {
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
- injectIfAvailable("web.dom.iterable", api.getUtils(path));
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 => injectIfAvailable(name, api.getUtils(path)));
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.5",
3
+ "version": "0.1.6",
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": "55f582c8ebc4b8a181a51fecaa92c89158cc7ac9"
32
+ "gitHead": "476f2b453e689512c722a5971812ea0558e56564"
33
33
  }