@babel/plugin-transform-runtime
Advanced tools
@@ -1,9 +0,10 @@ | ||
| export default function (moduleName, dirname, absoluteRuntime) { | ||
| function browser (moduleName, dirname, absoluteRuntime) { | ||
| if (absoluteRuntime === false) return moduleName; | ||
| resolveFSPath(); | ||
| } | ||
| export function resolveFSPath() { | ||
| function resolveFSPath() { | ||
| throw new Error("The 'absoluteRuntime' option is not supported when using @babel/standalone."); | ||
| } | ||
| export { browser as default, resolveFSPath }; | ||
| //# sourceMappingURL=browser.js.map |
@@ -1,5 +0,6 @@ | ||
| import path from "node:path"; | ||
| import { createRequire } from "node:module"; | ||
| import path from 'node:path'; | ||
| import { createRequire } from 'node:module'; | ||
| const require = createRequire(import.meta.url); | ||
| export default function (moduleName, dirname, absoluteRuntime) { | ||
| function index (moduleName, dirname, absoluteRuntime) { | ||
| if (absoluteRuntime === false) return moduleName; | ||
@@ -22,6 +23,7 @@ return resolveAbsoluteRuntime(moduleName, path.resolve(dirname, absoluteRuntime === true ? "." : absoluteRuntime)); | ||
| } | ||
| export function resolveFSPath(path) { | ||
| function resolveFSPath(path) { | ||
| return require.resolve(path).replace(/\\/g, "/"); | ||
| } | ||
| export { index as default, resolveFSPath }; | ||
| //# sourceMappingURL=index.js.map |
+9
-7
@@ -1,7 +0,8 @@ | ||
| import { declare } from "@babel/helper-plugin-utils"; | ||
| import { addDefault, isModule } from "@babel/helper-module-imports"; | ||
| import { types as t } from "@babel/core"; | ||
| import getRuntimePath, { resolveFSPath } from "./get-runtime-path/index.js"; | ||
| export default declare((api, options, dirname) => { | ||
| api.assertVersion("^7.0.0-0 || ^8.0.0 || 8.0.0-beta.4"); | ||
| import { declare } from '@babel/helper-plugin-utils'; | ||
| import { isModule, addDefault } from '@babel/helper-module-imports'; | ||
| import { types } from '@babel/core'; | ||
| import getRuntimePath, { resolveFSPath } from '#get-runtime-path'; | ||
| var index = declare((api, options, dirname) => { | ||
| api.assertVersion("^7.0.0-0 || ^8.0.0 || 8.0.0-rc.1"); | ||
| const { | ||
@@ -64,3 +65,3 @@ version: runtimeVersion = "8.0.0-beta.0", | ||
| if (cached) { | ||
| cached = t.cloneNode(cached); | ||
| cached = types.cloneNode(cached); | ||
| } else { | ||
@@ -80,2 +81,3 @@ cached = addDefault(file.path, source, { | ||
| export { index as default }; | ||
| //# sourceMappingURL=index.js.map |
+21
-14
| { | ||
| "name": "@babel/plugin-transform-runtime", | ||
| "version": "8.0.0-beta.4", | ||
| "version": "8.0.0-rc.1", | ||
| "description": "Externalise references to helpers and builtins, automatically polyfilling your code without polluting globals", | ||
@@ -18,9 +18,5 @@ "repository": { | ||
| ], | ||
| "browser": { | ||
| "./lib/get-runtime-path/index.js": "./lib/get-runtime-path/browser.js", | ||
| "./src/get-runtime-path/index.ts": "./src/get-runtime-path/browser.ts" | ||
| }, | ||
| "dependencies": { | ||
| "@babel/helper-module-imports": "^8.0.0-beta.4", | ||
| "@babel/helper-plugin-utils": "^8.0.0-beta.4" | ||
| "@babel/helper-module-imports": "^8.0.0-rc.1", | ||
| "@babel/helper-plugin-utils": "^8.0.0-rc.1" | ||
| }, | ||
@@ -31,9 +27,9 @@ "peerDependencies": { | ||
| "devDependencies": { | ||
| "@babel/core": "^8.0.0-beta.4", | ||
| "@babel/helper-plugin-test-runner": "^8.0.0-beta.4", | ||
| "@babel/helpers": "^8.0.0-beta.4", | ||
| "@babel/preset-env": "^8.0.0-beta.4", | ||
| "@babel/runtime": "^8.0.0-beta.4", | ||
| "@babel/runtime-corejs3": "^8.0.0-beta.4", | ||
| "babel-plugin-polyfill-corejs3": "^0.13.0" | ||
| "@babel/core": "^8.0.0-rc.1", | ||
| "@babel/helper-plugin-test-runner": "^8.0.0-rc.1", | ||
| "@babel/helpers": "^8.0.0-rc.1", | ||
| "@babel/preset-env": "^8.0.0-rc.1", | ||
| "@babel/runtime": "^8.0.0-rc.1", | ||
| "@babel/runtime-corejs3": "^8.0.0-rc.1", | ||
| "babel-plugin-polyfill-corejs3": "^0.14.0" | ||
| }, | ||
@@ -52,3 +48,14 @@ "homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-runtime", | ||
| }, | ||
| "imports": { | ||
| "#get-runtime-path": { | ||
| "babel-src": { | ||
| "browser": "./src/get-runtime-path/browser.ts", | ||
| "default": "./src/get-runtime-path/index.ts" | ||
| }, | ||
| "types": "./lib/get-runtime-path/index.d.ts", | ||
| "browser": "./lib/get-runtime-path/browser.js", | ||
| "default": "./lib/get-runtime-path/index.js" | ||
| } | ||
| }, | ||
| "type": "module" | ||
| } |
| export default function ( | ||
| moduleName: string, | ||
| dirname: string, | ||
| absoluteRuntime: string | boolean, | ||
| ) { | ||
| if (absoluteRuntime === false) return moduleName; | ||
| resolveFSPath(); | ||
| } | ||
| export function resolveFSPath() { | ||
| throw new Error( | ||
| "The 'absoluteRuntime' option is not supported when using @babel/standalone.", | ||
| ); | ||
| } |
| import path from "node:path"; | ||
| import { createRequire } from "node:module"; | ||
| const require = createRequire(import.meta.url); | ||
| export default function ( | ||
| moduleName: string, | ||
| dirname: string, | ||
| absoluteRuntime: string | boolean, | ||
| ) { | ||
| if (absoluteRuntime === false) return moduleName; | ||
| return resolveAbsoluteRuntime( | ||
| moduleName, | ||
| path.resolve(dirname, absoluteRuntime === true ? "." : absoluteRuntime), | ||
| ); | ||
| } | ||
| function resolveAbsoluteRuntime(moduleName: string, dirname: string) { | ||
| try { | ||
| return path | ||
| .dirname( | ||
| require.resolve(`${moduleName}/package.json`, { paths: [dirname] }), | ||
| ) | ||
| .replace(/\\/g, "/"); | ||
| } catch (err) { | ||
| if (err.code !== "MODULE_NOT_FOUND") throw err; | ||
| throw Object.assign( | ||
| new Error(`Failed to resolve "${moduleName}" relative to "${dirname}"`), | ||
| { | ||
| code: "BABEL_RUNTIME_NOT_FOUND", | ||
| runtime: moduleName, | ||
| dirname, | ||
| }, | ||
| ); | ||
| } | ||
| } | ||
| export function resolveFSPath(path: string) { | ||
| return require.resolve(path).replace(/\\/g, "/"); | ||
| } |
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
21147
-3.24%10
-16.67%127
-26.59%