1 line
12 KiB
Plaintext
1 line
12 KiB
Plaintext
|
{"version":3,"names":["_helperPluginUtils","require","_helperModuleImports","_core","_helpers","_index","_polyfills","supportsStaticESM","caller","_default","declare","api","options","dirname","assertVersion","helpers","useRuntimeHelpers","useESModules","version","runtimeVersion","absoluteRuntime","Error","DUAL_MODE_RUNTIME","supportsCJSDefault","hasMinVersion","has","obj","key","Object","prototype","hasOwnProperty","call","esModules","HEADER_HELPERS","name","inherits","createBasePolyfillsPlugin","pre","file","modulePath","set","_modulePath","_file$get","getRuntimePath","get","availableHelper","t","arrowFunctionExpression","identifier","isInteropHelper","indexOf","blockHoist","isModule","path","undefined","helpersDir","node","sourceType","helperPath","resolveFSPath","addDefaultImport","cache","Map","source","nameHint","isHelper","cacheKey","cached","cloneNode","addDefault","importedInterop","exports","default"],"sources":["../src/index.ts"],"sourcesContent":["import { declare } from \"@babel/helper-plugin-utils\";\nimport { addDefault, isModule } from \"@babel/helper-module-imports\";\nimport { types as t, type CallerMetadata } from \"@babel/core\";\n\nimport { hasMinVersion } from \"./helpers.ts\";\nimport getRuntimePath, { resolveFSPath } from \"./get-runtime-path/index.ts\";\nimport { createBasePolyfillsPlugin } from \"./polyfills.ts\";\n\nfunction supportsStaticESM(caller: CallerMetadata | undefined) {\n // @ts-expect-error TS does not narrow down optional chaining\n return !!caller?.supportsStaticESM;\n}\n\nexport interface Options {\n absoluteRuntime?: boolean;\n corejs?: string | number | { version: string | number; proposals?: boolean };\n helpers?: boolean;\n regenerator?: boolean;\n useESModules?: boolean | \"auto\";\n version?: string;\n}\n\nexport default declare((api, options: Options, dirname) => {\n api.assertVersion(7);\n\n const {\n helpers: useRuntimeHelpers = true,\n useESModules = false,\n version: runtimeVersion = \"7.0.0-beta.0\",\n absoluteRuntime = false,\n } = options;\n\n if (typeof useRuntimeHelpers !== \"boolean\") {\n throw new Error(\"The 'helpers' option must be undefined, or a boolean.\");\n }\n\n if (typeof useESModules !== \"boolean\" && useESModules !== \"auto\") {\n throw new Error(\n \"The 'useESModules' option must be undefined, or a boolean, or 'auto'.\",\n );\n }\n\n if (\n typeof absoluteRuntime !== \"boolean\" &&\n typeof absoluteRuntime !== \"string\"\n ) {\n throw new Error(\n \"The 'absoluteRuntime' option must be undefined, a boolean, or a string.\",\n );\n }\n\n if (typeof runtimeVersion !== \"string\") {\n throw new Error(`The 'version' option must be a version string.`);\n }\n\n if (!process.env.BABEL_8_BREAKING) {\n // In recent @babel/runtime versions, we can use require(\"helper\").default\n // instead of require(\"helper\") so that it has the same interface as the\n // ESM helper, and bundlers can better exchange one format for the other.\n const DUAL_MODE_RUNTIME = \"7.13.0\";\n // eslint-disable-next-line no-var\n var supportsCJSDefault = hasMinVersion(DUAL_MODE_RUNTIME, runtimeVersion);\n }\n\n function has(obj: {}, key: string) {\n return Object.prototype.hasOwnProperty.call(obj, key);\n }\n\n if (has(options, \"useBuiltIns\")) {\n // @ts-expect-error deprecated options\n if (options[\"useBuiltIns\"]) {\n throw new Error(\n \"The 'useBuiltIns' option has been removed. The @babel/runtime \" +\n \"module now uses builtins by default.\",\n );\n } else {\n throw new Error(\n \"The 'useBuiltIns' option has been removed. Use the 'corejs'\" +\n \"option to polyfill with `core-js` via @babel/runtime.\",\n );\n }\n }\n\n if (has(options, \"polyfill\")) {\n // @ts-expect-error deprecated options\n if (options[\"polyfill\"] === false) {\n throw new Error(\n \"The 'polyfill' option has been removed. The @babel/runtime \" +\n \"module now skips polyfilling by default.\",\n );\n } else {\
|