Socket
Socket
Sign inDemoInstall

@babel/plugin-transform-runtime

Package Overview
Dependencies
Maintainers
6
Versions
138
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/plugin-transform-runtime - npm Package Compare versions

Comparing version 7.0.0-beta.43 to 7.0.0-beta.44

125

lib/index.js

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

enumerable: true,
get: function () {
get: function get() {
return _definitions.default;

@@ -16,5 +16,5 @@ }

function _helperPluginUtils() {
const data = require("@babel/helper-plugin-utils");
var data = require("@babel/helper-plugin-utils");
_helperPluginUtils = function () {
_helperPluginUtils = function _helperPluginUtils() {
return data;

@@ -27,5 +27,5 @@ };

function _helperModuleImports() {
const data = require("@babel/helper-module-imports");
var data = require("@babel/helper-module-imports");
_helperModuleImports = function () {
_helperModuleImports = function _helperModuleImports() {
return data;

@@ -38,5 +38,5 @@ };

function _core() {
const data = require("@babel/core");
var data = require("@babel/core");
_core = function () {
_core = function _core() {
return data;

@@ -52,17 +52,16 @@ };

var _default = (0, _helperPluginUtils().declare)((api, options) => {
var _default = (0, _helperPluginUtils().declare)(function (api, options) {
api.assertVersion(7);
const {
helpers,
moduleName = "@babel/runtime",
polyfill,
regenerator,
useBuiltIns,
useESModules
} = options;
const regeneratorEnabled = regenerator !== false;
const notPolyfillOrDoesUseBuiltIns = polyfill === false || useBuiltIns;
const isPolyfillAndUseBuiltIns = polyfill && useBuiltIns;
const baseHelpersDir = useBuiltIns ? "helpers/builtin" : "helpers";
const helpersDir = useESModules ? `${baseHelpersDir}/es6` : baseHelpersDir;
var helpers = options.helpers,
_options$moduleName = options.moduleName,
moduleName = _options$moduleName === void 0 ? "@babel/runtime" : _options$moduleName,
polyfill = options.polyfill,
regenerator = options.regenerator,
useBuiltIns = options.useBuiltIns,
useESModules = options.useESModules;
var regeneratorEnabled = regenerator !== false;
var notPolyfillOrDoesUseBuiltIns = polyfill === false || useBuiltIns;
var isPolyfillAndUseBuiltIns = polyfill && useBuiltIns;
var baseHelpersDir = useBuiltIns ? "helpers/builtin" : "helpers";
var helpersDir = useESModules ? baseHelpersDir + "/es6" : baseHelpersDir;

@@ -73,10 +72,12 @@ function has(obj, key) {

const HEADER_HELPERS = ["interopRequireWildcard", "interopRequireDefault"];
var HEADER_HELPERS = ["interopRequireWildcard", "interopRequireDefault"];
return {
pre(file) {
pre: function pre(file) {
var _this = this;
if (helpers !== false) {
file.set("helperGenerator", name => {
const isInteropHelper = HEADER_HELPERS.indexOf(name) !== -1;
const blockHoist = isInteropHelper && !(0, _helperModuleImports().isModule)(file.path) ? 4 : undefined;
return this.addDefaultImport(`${moduleName}/${helpersDir}/${name}`, name, blockHoist);
file.set("helperGenerator", function (name) {
var isInteropHelper = HEADER_HELPERS.indexOf(name) !== -1;
var blockHoist = isInteropHelper && !(0, _helperModuleImports().isModule)(file.path) ? 4 : undefined;
return _this.addDefaultImport(moduleName + "/" + helpersDir + "/" + name, name, blockHoist);
});

@@ -90,8 +91,8 @@ }

this.moduleName = moduleName;
const cache = new Map();
var cache = new Map();
this.addDefaultImport = (source, nameHint, blockHoist) => {
const cacheKey = (0, _helperModuleImports().isModule)(file.path);
const key = `${source}:${nameHint}:${cacheKey || ""}`;
let cached = cache.get(key);
this.addDefaultImport = function (source, nameHint, blockHoist) {
var cacheKey = (0, _helperModuleImports().isModule)(file.path);
var key = source + ":" + nameHint + ":" + (cacheKey || "");
var cached = cache.get(key);

@@ -103,4 +104,4 @@ if (cached) {

importedInterop: "uncompiled",
nameHint,
blockHoist
nameHint: nameHint,
blockHoist: blockHoist
});

@@ -113,13 +114,10 @@ cache.set(key, cached);

},
visitor: {
ReferencedIdentifier(path) {
const {
node,
parent,
scope
} = path;
ReferencedIdentifier: function ReferencedIdentifier(path) {
var node = path.node,
parent = path.parent,
scope = path.scope;
if (node.name === "regeneratorRuntime" && regeneratorEnabled) {
path.replaceWith(this.addDefaultImport(`${this.moduleName}/regenerator`, "regeneratorRuntime"));
path.replaceWith(this.addDefaultImport(this.moduleName + "/regenerator", "regeneratorRuntime"));
return;

@@ -132,9 +130,8 @@ }

if (scope.getBindingIdentifier(node.name)) return;
path.replaceWith(this.addDefaultImport(`${moduleName}/core-js/${_definitions.default.builtins[node.name]}`, node.name));
path.replaceWith(this.addDefaultImport(moduleName + "/core-js/" + _definitions.default.builtins[node.name], node.name));
},
CallExpression(path) {
CallExpression: function CallExpression(path) {
if (notPolyfillOrDoesUseBuiltIns) return;
if (path.node.arguments.length) return;
const callee = path.node.callee;
var callee = path.node.callee;
if (!_core().types.isMemberExpression(callee)) return;

@@ -147,25 +144,21 @@ if (!callee.computed) return;

path.replaceWith(_core().types.callExpression(this.addDefaultImport(`${moduleName}/core-js/get-iterator`, "getIterator"), [callee.object]));
path.replaceWith(_core().types.callExpression(this.addDefaultImport(moduleName + "/core-js/get-iterator", "getIterator"), [callee.object]));
},
BinaryExpression(path) {
BinaryExpression: function BinaryExpression(path) {
if (notPolyfillOrDoesUseBuiltIns) return;
if (path.node.operator !== "in") return;
if (!path.get("left").matchesPattern("Symbol.iterator")) return;
path.replaceWith(_core().types.callExpression(this.addDefaultImport(`${moduleName}/core-js/is-iterable`, "isIterable"), [path.node.right]));
path.replaceWith(_core().types.callExpression(this.addDefaultImport(moduleName + "/core-js/is-iterable", "isIterable"), [path.node.right]));
},
MemberExpression: {
enter(path) {
enter: function enter(path) {
if (notPolyfillOrDoesUseBuiltIns) return;
if (!path.isReferenced()) return;
const {
node
} = path;
const obj = node.object;
const prop = node.property;
var node = path.node;
var obj = node.object;
var prop = node.property;
if (!_core().types.isReferenced(obj, node)) return;
if (node.computed) return;
if (!has(_definitions.default.methods, obj.name)) return;
const methods = _definitions.default.methods[obj.name];
var methods = _definitions.default.methods[obj.name];
if (!has(methods, prop.name)) return;

@@ -175,3 +168,3 @@ if (path.scope.getBindingIdentifier(obj.name)) return;

if (obj.name === "Object" && prop.name === "defineProperty" && path.parentPath.isCallExpression()) {
const call = path.parentPath.node;
var call = path.parentPath.node;

@@ -183,17 +176,13 @@ if (call.arguments.length === 3 && _core().types.isLiteral(call.arguments[1])) {

path.replaceWith(this.addDefaultImport(`${moduleName}/core-js/${methods[prop.name]}`, `${obj.name}$${prop.name}`));
path.replaceWith(this.addDefaultImport(moduleName + "/core-js/" + methods[prop.name], obj.name + "$" + prop.name));
},
exit(path) {
exit: function exit(path) {
if (notPolyfillOrDoesUseBuiltIns) return;
if (!path.isReferenced()) return;
const {
node
} = path;
const obj = node.object;
var node = path.node;
var obj = node.object;
if (!has(_definitions.default.builtins, obj.name)) return;
if (path.scope.getBindingIdentifier(obj.name)) return;
path.replaceWith(_core().types.memberExpression(this.addDefaultImport(`${moduleName}/core-js/${_definitions.default.builtins[obj.name]}`, obj.name), node.property, node.computed));
path.replaceWith(_core().types.memberExpression(this.addDefaultImport(moduleName + "/core-js/" + _definitions.default.builtins[obj.name], obj.name), node.property, node.computed));
}
}

@@ -200,0 +189,0 @@ }

{
"name": "@babel/plugin-transform-runtime",
"version": "7.0.0-beta.43",
"version": "7.0.0-beta.44",
"description": "Externalise references to helpers and builtins, automatically polyfilling your code without polluting globals",

@@ -12,12 +12,12 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-runtime",

"dependencies": {
"@babel/helper-module-imports": "7.0.0-beta.43",
"@babel/helper-plugin-utils": "7.0.0-beta.43"
"@babel/helper-module-imports": "7.0.0-beta.44",
"@babel/helper-plugin-utils": "7.0.0-beta.44"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.43"
"@babel/core": "7.0.0-beta.44"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.43",
"@babel/helper-plugin-test-runner": "7.0.0-beta.43"
"@babel/core": "7.0.0-beta.44",
"@babel/helper-plugin-test-runner": "7.0.0-beta.44"
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc