@babel/plugin-transform-runtime
Advanced tools
Comparing version 8.0.0-alpha.4 to 8.0.0-alpha.5
@@ -6,11 +6,8 @@ import { declare } from "@babel/helper-plugin-utils"; | ||
import getRuntimePath, { resolveFSPath } from "./get-runtime-path/index.js"; | ||
import { createBasePolyfillsPlugin } from "./polyfills.js"; | ||
function supportsStaticESM(caller) { | ||
return !!caller?.supportsStaticESM; | ||
} | ||
import { createCorejs3Plugin } from "./core-js.js"; | ||
import babel7 from "./babel-7/index.cjs"; | ||
export default declare((api, options, dirname) => { | ||
api.assertVersion(7); | ||
api.assertVersion("8.0.0-alpha.5"); | ||
const { | ||
helpers: useRuntimeHelpers = true, | ||
useESModules = false, | ||
version: runtimeVersion = "7.0.0-beta.0", | ||
@@ -22,5 +19,2 @@ absoluteRuntime = false | ||
} | ||
if (typeof useESModules !== "boolean" && useESModules !== "auto") { | ||
throw new Error("The 'useESModules' option must be undefined, or a boolean, or 'auto'."); | ||
} | ||
if (typeof absoluteRuntime !== "boolean" && typeof absoluteRuntime !== "string") { | ||
@@ -53,7 +47,16 @@ throw new Error("The 'absoluteRuntime' option must be undefined, a boolean, or a string."); | ||
} | ||
const esModules = useESModules === "auto" ? api.caller(supportsStaticESM) : useESModules; | ||
{ | ||
if (has(options, "regenerator")) { | ||
throw new Error("The 'regenerator' option has been removed. The generators transform " + "no longers relies on a 'regeneratorRuntime' global. " + "If you still need to replace imports to the 'regeneratorRuntime' " + "global, you can use babel-plugin-polyfill-regenerator."); | ||
} | ||
} | ||
{ | ||
if (has(options, "useESModules")) { | ||
throw new Error("The 'useESModules' option has been removed. @babel/runtime now uses " + "package.json#exports to support both CommonJS and ESM helpers."); | ||
} | ||
} | ||
const HEADER_HELPERS = ["interopRequireWildcard", "interopRequireDefault"]; | ||
return { | ||
name: "transform-runtime", | ||
inherits: createBasePolyfillsPlugin(options, runtimeVersion, absoluteRuntime), | ||
inherits: options.corejs ? createCorejs3Plugin(options.corejs, absoluteRuntime) : undefined, | ||
pre(file) { | ||
@@ -69,4 +72,3 @@ if (!useRuntimeHelpers) return; | ||
const blockHoist = isInteropHelper && !isModule(file.path) ? 4 : undefined; | ||
const helpersDir = esModules && file.path.node.sourceType === "module" ? "helpers/esm" : "helpers"; | ||
let helperPath = `${modulePath}/${helpersDir}/${name}`; | ||
let helperPath = `${modulePath}/helpers/${name}`; | ||
if (absoluteRuntime) helperPath = resolveFSPath(helperPath); | ||
@@ -73,0 +75,0 @@ return addDefaultImport(helperPath, name, blockHoist, true); |
{ | ||
"name": "@babel/plugin-transform-runtime", | ||
"version": "8.0.0-alpha.4", | ||
"version": "8.0.0-alpha.5", | ||
"description": "Externalise references to helpers and builtins, automatically polyfilling your code without polluting globals", | ||
@@ -23,19 +23,19 @@ "repository": { | ||
"dependencies": { | ||
"@babel/helper-module-imports": "^8.0.0-alpha.4", | ||
"@babel/helper-plugin-utils": "^8.0.0-alpha.4", | ||
"babel-plugin-polyfill-corejs2": "^0.4.6", | ||
"babel-plugin-polyfill-corejs3": "^0.8.5", | ||
"babel-plugin-polyfill-regenerator": "^0.5.3", | ||
"@babel/helper-module-imports": "^8.0.0-alpha.5", | ||
"@babel/helper-plugin-utils": "^8.0.0-alpha.5", | ||
"babel-plugin-polyfill-corejs2": "^0.4.7", | ||
"babel-plugin-polyfill-corejs3": "^0.8.7", | ||
"babel-plugin-polyfill-regenerator": "^0.5.4", | ||
"semver": "^7.3.4" | ||
}, | ||
"peerDependencies": { | ||
"@babel/core": "^8.0.0-alpha.4" | ||
"@babel/core": "^8.0.0-alpha.5" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^8.0.0-alpha.4", | ||
"@babel/helper-plugin-test-runner": "^8.0.0-alpha.4", | ||
"@babel/helpers": "^8.0.0-alpha.4", | ||
"@babel/preset-env": "^8.0.0-alpha.4", | ||
"@babel/runtime": "^8.0.0-alpha.4", | ||
"@babel/runtime-corejs3": "^8.0.0-alpha.4" | ||
"@babel/core": "^8.0.0-alpha.5", | ||
"@babel/helper-plugin-test-runner": "^8.0.0-alpha.5", | ||
"@babel/helpers": "^8.0.0-alpha.5", | ||
"@babel/preset-env": "^8.0.0-alpha.5", | ||
"@babel/runtime": "^8.0.0-alpha.5", | ||
"@babel/runtime-corejs3": "^8.0.0-alpha.5" | ||
}, | ||
@@ -42,0 +42,0 @@ "homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-runtime", |
Sorry, the diff of this file is not supported yet
38297
19
265
137
1
5
1
24