Socket
Socket
Sign inDemoInstall

@babel/plugin-transform-runtime

Package Overview
Dependencies
Maintainers
5
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.55 to 7.0.0-beta.56

86

lib/index.js

@@ -6,8 +6,2 @@ "use strict";

});
Object.defineProperty(exports, "definitions", {
enumerable: true,
get: function () {
return _definitions.default;
}
});
exports.default = void 0;

@@ -52,15 +46,25 @@

const {
helpers,
moduleName = "@babel/runtime",
polyfill,
regenerator,
useBuiltIns,
useESModules
corejs: corejsVersion = false,
helpers: useRuntimeHelpers = true,
regenerator: useRuntimeRegenerator = true,
useESModules = false,
version: runtimeVersion = "7.0.0-beta.0"
} = 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;
if (typeof useRuntimeRegenerator !== "boolean") {
throw new Error("The 'regenerator' option must be undefined, or a boolean.");
}
if (typeof useRuntimeHelpers !== "boolean") {
throw new Error("The 'helpers' option must be undefined, or a boolean.");
}
if (typeof useESModules !== "boolean") {
throw new Error("The 'useESModules' option must be undefined, or a boolean.");
}
if (corejsVersion !== false && (typeof corejsVersion !== "number" || corejsVersion !== 2) && (typeof corejsVersion !== "string" || corejsVersion !== "2")) {
throw new Error(`The 'corejs' option must be undefined, false, or 2, or '2', ` + `but got ${JSON.stringify(corejsVersion)}.`);
}
function has(obj, key) {

@@ -70,7 +74,34 @@ return Object.prototype.hasOwnProperty.call(obj, key);

if (has(options, "useBuiltIns")) {
if (options.useBuiltIns) {
throw new Error("The 'useBuiltIns' option has been removed. The @babel/runtime " + "module now uses builtins by default.");
} else {
throw new Error("The 'useBuiltIns' option has been removed. Use the 'corejs'" + "option with value '2' to polyfill with CoreJS 2.x via @babel/runtime.");
}
}
if (has(options, "polyfill")) {
if (options.polyfill === false) {
throw new Error("The 'polyfill' option has been removed. The @babel/runtime " + "module now skips polyfilling by default.");
} else {
throw new Error("The 'polyfill' option has been removed. Use the 'corejs'" + "option with value '2' to polyfill with CoreJS 2.x via @babel/runtime.");
}
}
if (has(options, "moduleName")) {
throw new Error("The 'moduleName' option has been removed. @babel/transform-runtime " + "no longer supports arbitrary runtimes.");
}
const helpersDir = useESModules ? "helpers/esm" : "helpers";
const injectCoreJS2 = `${corejsVersion}` === "2";
const moduleName = injectCoreJS2 ? "@babel/runtime-corejs2" : "@babel/runtime";
const HEADER_HELPERS = ["interopRequireWildcard", "interopRequireDefault"];
return {
pre(file) {
if (helpers !== false) {
if (useRuntimeHelpers) {
file.set("helperGenerator", name => {
if (file.availableHelper && !file.availableHelper(name, runtimeVersion)) {
return;
}
const isInteropHelper = HEADER_HELPERS.indexOf(name) !== -1;

@@ -82,7 +113,2 @@ const blockHoist = isInteropHelper && !(0, _helperModuleImports().isModule)(file.path) ? 4 : undefined;

if (isPolyfillAndUseBuiltIns) {
throw new Error("The polyfill option conflicts with useBuiltIns; use one or the other");
}
this.moduleName = moduleName;
const cache = new Map();

@@ -118,8 +144,8 @@

if (node.name === "regeneratorRuntime" && regeneratorEnabled) {
path.replaceWith(this.addDefaultImport(`${this.moduleName}/regenerator`, "regeneratorRuntime"));
if (node.name === "regeneratorRuntime" && useRuntimeRegenerator) {
path.replaceWith(this.addDefaultImport(`${moduleName}/regenerator`, "regeneratorRuntime"));
return;
}
if (notPolyfillOrDoesUseBuiltIns) return;
if (!injectCoreJS2) return;
if (_core().types.isMemberExpression(parent)) return;

@@ -132,3 +158,3 @@ if (!has(_definitions.default.builtins, node.name)) return;

CallExpression(path) {
if (notPolyfillOrDoesUseBuiltIns) return;
if (!injectCoreJS2) return;
if (path.node.arguments.length) return;

@@ -147,3 +173,3 @@ const callee = path.node.callee;

BinaryExpression(path) {
if (notPolyfillOrDoesUseBuiltIns) return;
if (!injectCoreJS2) return;
if (path.node.operator !== "in") return;

@@ -156,3 +182,3 @@ if (!path.get("left").matchesPattern("Symbol.iterator")) return;

enter(path) {
if (notPolyfillOrDoesUseBuiltIns) return;
if (!injectCoreJS2) return;
if (!path.isReferenced()) return;

@@ -183,3 +209,3 @@ const {

exit(path) {
if (notPolyfillOrDoesUseBuiltIns) return;
if (!injectCoreJS2) return;
if (!path.isReferenced()) return;

@@ -186,0 +212,0 @@ const {

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

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

"dependencies": {
"@babel/helper-module-imports": "7.0.0-beta.55",
"@babel/helper-plugin-utils": "7.0.0-beta.55"
"@babel/helper-module-imports": "7.0.0-beta.56",
"@babel/helper-plugin-utils": "7.0.0-beta.56"
},

@@ -20,5 +20,10 @@ "peerDependencies": {

"devDependencies": {
"@babel/core": "7.0.0-beta.55",
"@babel/helper-plugin-test-runner": "7.0.0-beta.55"
"@babel/core": "7.0.0-beta.56",
"@babel/helper-plugin-test-runner": "7.0.0-beta.56",
"@babel/helpers": "7.0.0-beta.56",
"@babel/plugin-transform-runtime": "7.0.0-beta.56",
"@babel/preset-env": "7.0.0-beta.56",
"@babel/template": "7.0.0-beta.56",
"@babel/types": "7.0.0-beta.53"
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc