🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@babel/plugin-transform-runtime

Package Overview
Dependencies
Maintainers
4
Versions
154
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

to
8.0.0-alpha.0

11

lib/get-runtime-path/browser.js

@@ -1,13 +0,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
exports.resolveFSPath = resolveFSPath;
function _default(moduleName, dirname, absoluteRuntime) {
export default function (moduleName, dirname, absoluteRuntime) {
if (absoluteRuntime === false) return moduleName;
resolveFSPath();
}
function resolveFSPath() {
export function resolveFSPath() {
throw new Error("The 'absoluteRuntime' option is not supported when using @babel/standalone.");

@@ -14,0 +7,0 @@ }

28

lib/get-runtime-path/index.js

@@ -1,25 +0,11 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
exports.resolveFSPath = resolveFSPath;
var _path = require("path");
var _module = require("module");
function _default(moduleName, dirname, absoluteRuntime) {
import path from "path";
import { createRequire } from "module";
const require = createRequire(import.meta.url);
export default function (moduleName, dirname, absoluteRuntime) {
if (absoluteRuntime === false) return moduleName;
return resolveAbsoluteRuntime(moduleName, _path.resolve(dirname, absoluteRuntime === true ? "." : absoluteRuntime));
return resolveAbsoluteRuntime(moduleName, path.resolve(dirname, absoluteRuntime === true ? "." : absoluteRuntime));
}
function resolveAbsoluteRuntime(moduleName, dirname) {
try {
return _path.dirname((((v, w) => (v = v.split("."), w = w.split("."), +v[0] > +w[0] || v[0] == w[0] && +v[1] >= +w[1]))(process.versions.node, "8.9") ? require.resolve : (r, {
paths: [b]
}, M = require("module")) => {
let f = M._findPath(r, M._nodeModulePaths(b).concat(b));
if (f) return f;
f = new Error(`Cannot resolve module '${r}'`);
f.code = "MODULE_NOT_FOUND";
throw f;
})(`${moduleName}/package.json`, {
return path.dirname(require.resolve(`${moduleName}/package.json`, {
paths: [dirname]

@@ -36,3 +22,3 @@ })).replace(/\\/g, "/");

}
function resolveFSPath(path) {
export function resolveFSPath(path) {
return require.resolve(path).replace(/\\/g, "/");

@@ -39,0 +25,0 @@ }

@@ -1,14 +0,8 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.hasMinVersion = hasMinVersion;
var _semver = require("semver");
function hasMinVersion(minVersion, runtimeVersion) {
import semver from "semver";
export function hasMinVersion(minVersion, runtimeVersion) {
if (!runtimeVersion) return true;
if (_semver.valid(runtimeVersion)) runtimeVersion = `^${runtimeVersion}`;
return !_semver.intersects(`<${minVersion}`, runtimeVersion) && !_semver.intersects(`>=8.0.0`, runtimeVersion);
if (semver.valid(runtimeVersion)) runtimeVersion = `^${runtimeVersion}`;
return !semver.intersects(`<${minVersion}`, runtimeVersion) && !semver.intersects(`>=8.0.0`, runtimeVersion);
}
//# sourceMappingURL=helpers.js.map

@@ -1,17 +0,11 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _helperModuleImports = require("@babel/helper-module-imports");
var _core = require("@babel/core");
var _helpers = require("./helpers");
var _getRuntimePath = require("./get-runtime-path");
var _polyfills = require("./polyfills");
import { declare } from "@babel/helper-plugin-utils";
import { addDefault, isModule } from "@babel/helper-module-imports";
import { types as t } from "@babel/core";
import { hasMinVersion } from "./helpers.js";
import getRuntimePath, { resolveFSPath } from "./get-runtime-path/index.js";
import { createBasePolyfillsPlugin } from "./polyfills.js";
function supportsStaticESM(caller) {
return !!(caller != null && caller.supportsStaticESM);
return !!caller?.supportsStaticESM;
}
var _default = (0, _helperPluginUtils.declare)((api, options, dirname) => {
export default declare((api, options, dirname) => {
api.assertVersion(7);

@@ -36,6 +30,3 @@ const {

}
{
const DUAL_MODE_RUNTIME = "7.13.0";
var supportsCJSDefault = (0, _helpers.hasMinVersion)(DUAL_MODE_RUNTIME, runtimeVersion);
}
;
function has(obj, key) {

@@ -65,3 +56,3 @@ return Object.prototype.hasOwnProperty.call(obj, key);

name: "transform-runtime",
inherits: (0, _polyfills.createBasePolyfillsPlugin)(options, runtimeVersion, absoluteRuntime),
inherits: createBasePolyfillsPlugin(options, runtimeVersion, absoluteRuntime),
pre(file) {

@@ -71,17 +62,11 @@ if (!useRuntimeHelpers) return;

file.set("helperGenerator", name => {
var _modulePath, _file$get;
(_modulePath = modulePath) != null ? _modulePath : modulePath = (0, _getRuntimePath.default)((_file$get = file.get("runtimeHelpersModuleName")) != null ? _file$get : "@babel/runtime", dirname, absoluteRuntime);
modulePath ??= getRuntimePath(file.get("runtimeHelpersModuleName") ?? "@babel/runtime", dirname, absoluteRuntime);
{
if (!(file.availableHelper != null && file.availableHelper(name, runtimeVersion))) {
if (name === "regeneratorRuntime") {
return _core.types.arrowFunctionExpression([], _core.types.identifier("regeneratorRuntime"));
}
return;
}
if (!file.availableHelper(name, runtimeVersion)) return;
}
const isInteropHelper = HEADER_HELPERS.indexOf(name) !== -1;
const blockHoist = isInteropHelper && !(0, _helperModuleImports.isModule)(file.path) ? 4 : undefined;
const blockHoist = isInteropHelper && !isModule(file.path) ? 4 : undefined;
const helpersDir = esModules && file.path.node.sourceType === "module" ? "helpers/esm" : "helpers";
let helperPath = `${modulePath}/${helpersDir}/${name}`;
if (absoluteRuntime) helperPath = (0, _getRuntimePath.resolveFSPath)(helperPath);
if (absoluteRuntime) helperPath = resolveFSPath(helperPath);
return addDefaultImport(helperPath, name, blockHoist, true);

@@ -91,10 +76,10 @@ });

function addDefaultImport(source, nameHint, blockHoist, isHelper = false) {
const cacheKey = (0, _helperModuleImports.isModule)(file.path);
const cacheKey = isModule(file.path);
const key = `${source}:${nameHint}:${cacheKey || ""}`;
let cached = cache.get(key);
if (cached) {
cached = _core.types.cloneNode(cached);
cached = t.cloneNode(cached);
} else {
cached = (0, _helperModuleImports.addDefault)(file.path, source, {
importedInterop: isHelper && supportsCJSDefault ? "compiled" : "uncompiled",
cached = addDefault(file.path, source, {
importedInterop: isHelper ? "compiled" : "uncompiled",
nameHint,

@@ -110,4 +95,3 @@ blockHoist

});
exports.default = _default;
//# sourceMappingURL=index.js.map

@@ -1,13 +0,7 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createBasePolyfillsPlugin = createBasePolyfillsPlugin;
var _babelPluginPolyfillCorejs = require("babel-plugin-polyfill-corejs2");
var _babelPluginPolyfillCorejs2 = require("babel-plugin-polyfill-corejs3");
var _babelPluginPolyfillRegenerator = require("babel-plugin-polyfill-regenerator");
const pluginCorejs2 = _babelPluginPolyfillCorejs.default || _babelPluginPolyfillCorejs;
const pluginCorejs3 = _babelPluginPolyfillCorejs2.default || _babelPluginPolyfillCorejs2;
const pluginRegenerator = _babelPluginPolyfillRegenerator.default || _babelPluginPolyfillRegenerator;
import _pluginCorejs2 from "babel-plugin-polyfill-corejs2";
import _pluginCorejs3 from "babel-plugin-polyfill-corejs3";
import _pluginRegenerator from "babel-plugin-polyfill-regenerator";
const pluginCorejs2 = _pluginCorejs2.default || _pluginCorejs2;
const pluginCorejs3 = _pluginCorejs3.default || _pluginCorejs3;
const pluginRegenerator = _pluginRegenerator.default || _pluginRegenerator;
const pluginsCompat = "#__secret_key__@babel/runtime__compatibility";

@@ -27,3 +21,3 @@ function createCorejsPlugin(plugin, options, regeneratorPlugin) {

}
function createBasePolyfillsPlugin({
export function createBasePolyfillsPlugin({
corejs,

@@ -30,0 +24,0 @@ regenerator: useRuntimeRegenerator = true

{
"name": "@babel/plugin-transform-runtime",
"version": "7.22.9",
"version": "8.0.0-alpha.0",
"description": "Externalise references to helpers and builtins, automatically polyfilling your code without polluting globals",

@@ -23,27 +23,30 @@ "repository": {

"dependencies": {
"@babel/helper-module-imports": "^7.22.5",
"@babel/helper-plugin-utils": "^7.22.5",
"@babel/helper-module-imports": "^8.0.0-alpha.0",
"@babel/helper-plugin-utils": "^8.0.0-alpha.0",
"babel-plugin-polyfill-corejs2": "^0.4.4",
"babel-plugin-polyfill-corejs3": "^0.8.2",
"babel-plugin-polyfill-regenerator": "^0.5.1",
"semver": "^6.3.1"
"semver": "^7.3.4"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
"@babel/core": "^8.0.0-alpha.0"
},
"devDependencies": {
"@babel/core": "^7.22.9",
"@babel/helper-plugin-test-runner": "^7.22.5",
"@babel/helpers": "^7.22.6",
"@babel/preset-env": "^7.22.9",
"@babel/runtime": "^7.22.6",
"@babel/runtime-corejs3": "^7.22.6",
"make-dir": "^2.1.0"
"@babel/core": "^8.0.0-alpha.0",
"@babel/helper-plugin-test-runner": "^8.0.0-alpha.0",
"@babel/helpers": "^8.0.0-alpha.0",
"@babel/preset-env": "^8.0.0-alpha.0",
"@babel/runtime": "^8.0.0-alpha.0",
"@babel/runtime-corejs3": "^8.0.0-alpha.0"
},
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-runtime",
"engines": {
"node": ">=6.9.0"
"node": "^16.20.0 || ^18.16.0 || >=20.0.0"
},
"author": "The Babel Team (https://babel.dev/team)",
"type": "commonjs"
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
},
"type": "module"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet