Socket
Socket
Sign inDemoInstall

babel-plugin-polyfill-corejs2

Package Overview
Dependencies
79
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.3 to 0.4.4

3

lib/add-platform-specific-polyfills.js

@@ -5,5 +5,3 @@ "use strict";

exports.default = _default;
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
const webPolyfills = {

@@ -19,3 +17,2 @@ "web.timers": {},

};
function _default(targets, method, polyfills) {

@@ -22,0 +19,0 @@ const targetNames = Object.keys(targets);

@@ -5,7 +5,4 @@ "use strict";

exports.StaticProperties = exports.InstanceProperties = exports.CommonIterators = exports.BuiltIns = void 0;
var _corejs2BuiltIns = _interopRequireDefault(require("@babel/compat-data/corejs2-built-ins"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const define = (name, pure, global = [], meta) => {

@@ -19,11 +16,7 @@ return {

};
const pureAndGlobal = (pure, global, minRuntimeVersion = null) => define(global[0], pure, global, {
minRuntimeVersion
});
const globalOnly = global => define(global[0], null, global);
const pureOnly = (pure, name) => define(name, pure, []);
const ArrayNatureIterators = ["es6.object.to-string", "es6.array.iterator", "web.dom.iterable"];

@@ -117,10 +110,9 @@ const CommonIterators = ["es6.string.iterator", ...ArrayNatureIterators];

values: globalOnly(ArrayNatureIterators)
}; // This isn't present in older @babel/compat-data versions
};
// This isn't present in older @babel/compat-data versions
exports.InstanceProperties = InstanceProperties;
if ("es6.array.slice" in _corejs2BuiltIns.default) {
InstanceProperties.slice = globalOnly(["es6.array.slice"]);
}
const StaticProperties = {

@@ -127,0 +119,0 @@ Array: {

14

lib/helpers.js

@@ -5,6 +5,5 @@ "use strict";

exports.hasMinVersion = hasMinVersion;
var _semver = _interopRequireDefault(require("semver"));
var _semverV = _interopRequireDefault(require("@nicolo-ribaudo/semver-v6"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/// <reference path="../../../lib/semver.d.ts" />

@@ -15,3 +14,5 @@ function hasMinVersion(minVersion, runtimeVersion) {

// that the built output will include all definitions.
if (!runtimeVersion || !minVersion) return true; // semver.intersects() has some surprising behavior with comparing ranges
if (!runtimeVersion || !minVersion) return true;
// semver.intersects() has some surprising behavior with comparing ranges
// with preprelease versions. We add '^' to ensure that we are always

@@ -33,5 +34,4 @@ // comparing ranges with ranges, which sidesteps this logic.

// babel-core's availableHelper() API.
if (_semver.default.valid(runtimeVersion)) runtimeVersion = `^${runtimeVersion}`;
return !_semver.default.intersects(`<${minVersion}`, runtimeVersion) && !_semver.default.intersects(`>=8.0.0`, runtimeVersion);
if (_semverV.default.valid(runtimeVersion)) runtimeVersion = `^${runtimeVersion}`;
return !_semverV.default.intersects(`<${minVersion}`, runtimeVersion) && !_semverV.default.intersects(`>=8.0.0`, runtimeVersion);
}

@@ -5,21 +5,11 @@ "use strict";

exports.default = void 0;
var _corejs2BuiltIns = _interopRequireDefault(require("@babel/compat-data/corejs2-built-ins"));
var _builtInDefinitions = require("./built-in-definitions");
var _addPlatformSpecificPolyfills = _interopRequireDefault(require("./add-platform-specific-polyfills"));
var _helpers = require("./helpers");
var _helperDefinePolyfillProvider = _interopRequireDefault(require("@babel/helper-define-polyfill-provider"));
var _babel = _interopRequireWildcard(require("@babel/core"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const {

@@ -32,3 +22,2 @@ types: t

const has = Function.call.bind(Object.hasOwnProperty);
var _default = (0, _helperDefinePolyfillProvider.default)(function (api, {

@@ -57,3 +46,2 @@ [presetEnvCompat]: {

const coreJSBase = useBabelRuntime ? `${BABEL_RUNTIME}/core-js` : method === "usage-pure" ? "core-js/library/fn" : "core-js/modules";
function inject(name, utils) {

@@ -67,9 +55,6 @@ if (typeof name === "string") {

}
return;
}
name.forEach(name => inject(name, utils));
}
function maybeInjectPure(desc, hint, utils) {

@@ -82,13 +67,11 @@ let {

if (!pure || !shouldInjectPolyfill(name)) return;
if (runtimeVersion && meta && meta.minRuntimeVersion && !(0, _helpers.hasMinVersion)(meta && meta.minRuntimeVersion, runtimeVersion)) {
return;
} // Unfortunately core-js and @babel/runtime-corejs2 don't have the same
}
// Unfortunately core-js and @babel/runtime-corejs2 don't have the same
// directory structure, so we need to special case this.
if (useBabelRuntime && pure === "symbol/index") pure = "symbol";
return utils.injectDefaultImport(`${coreJSBase}/${pure}${ext}`, hint);
}
return {

@@ -98,3 +81,2 @@ name: "corejs2",

polyfills,
entryGlobal(meta, utils, path) {

@@ -104,11 +86,8 @@ if (meta.kind === "import" && meta.source === "core-js") {

inject(Object.keys(polyfills), utils);
if (entryInjectRegenerator) {
utils.injectGlobalImport("regenerator-runtime/runtime.js");
}
path.remove();
}
},
usageGlobal(meta, utils) {

@@ -118,3 +97,2 @@ const resolved = resolve(meta);

let deps = resolved.desc.global;
if (resolved.kind !== "global" && "object" in meta && meta.object && meta.placement === "prototype") {

@@ -124,6 +102,4 @@ const low = meta.object.toLowerCase();

}
inject(deps, utils);
},
usagePure(meta, utils, path) {

@@ -138,7 +114,5 @@ if (meta.kind === "in") {

}
if (path.parentPath.isUnaryExpression({
operator: "delete"
})) return;
if (meta.kind === "property") {

@@ -148,3 +122,2 @@ // We can't compile destructuring.

if (!path.isReferenced()) return;
if (meta.key === "Symbol.iterator" && shouldInjectPolyfill("es6.symbol") && path.parentPath.isCallExpression({

@@ -158,3 +131,2 @@ callee: path.node

}
const resolved = resolve(meta);

@@ -165,3 +137,2 @@ if (!resolved) return;

},
visitor: method === "usage-global" && {

@@ -174,3 +145,2 @@ // yield*

},
// for-of, [a, b] = c

@@ -180,7 +150,5 @@ "ForOfStatement|ArrayPattern"(path) {

}
}
};
});
exports.default = _default;
{
"name": "babel-plugin-polyfill-corejs2",
"version": "0.4.3",
"version": "0.4.4",
"description": "A Babel plugin to inject imports to core-js@2 polyfills",

@@ -29,11 +29,11 @@ "repository": {

"dependencies": {
"@babel/compat-data": "^7.17.7",
"@babel/helper-define-polyfill-provider": "^0.4.0",
"semver": "^6.1.1"
"@babel/compat-data": "^7.22.6",
"@babel/helper-define-polyfill-provider": "^0.4.1",
"@nicolo-ribaudo/semver-v6": "^6.3.3"
},
"devDependencies": {
"@babel/core": "^7.17.8",
"@babel/helper-plugin-test-runner": "^7.16.7",
"@babel/plugin-transform-for-of": "^7.16.7",
"@babel/plugin-transform-modules-commonjs": "^7.17.7"
"@babel/core": "^7.22.6",
"@babel/helper-plugin-test-runner": "^7.22.5",
"@babel/plugin-transform-for-of": "^7.22.5",
"@babel/plugin-transform-modules-commonjs": "^7.22.5"
},

@@ -43,3 +43,3 @@ "peerDependencies": {

},
"gitHead": "476a0d277ae9bdf705fe2b2cce645125b3c774dc"
"gitHead": "74956db5d547985ac8e60bf1af56f4c61af12e4e"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc