{"version":3,"file":"index.node.mjs","sources":["../src/utils.ts","../src/imports-cache.ts","../src/debug-utils.ts","../src/normalize-options.ts","../src/visitors/usage.ts","../src/visitors/entry.ts","../src/node/dependencies.ts","../src/meta-resolver.ts","../src/index.ts"],"sourcesContent":["import { types as t, template } from \"@babel/core\";\nimport type { NodePath } from \"@babel/traverse\";\nimport type { Utils } from \"./types\";\nimport type ImportsCache from \"./imports-cache\";\n\nexport function intersection(a: Set, b: Set): Set {\n const result = new Set();\n a.forEach(v => b.has(v) && result.add(v));\n return result;\n}\n\nexport function has(object: any, key: string) {\n return Object.prototype.hasOwnProperty.call(object, key);\n}\n\nfunction getType(target: any): string {\n return Object.prototype.toString.call(target).slice(8, -1);\n}\n\nfunction resolveId(path): string {\n if (\n path.isIdentifier() &&\n !path.scope.hasBinding(path.node.name, /* noGlobals */ true)\n ) {\n return path.node.name;\n }\n\n const { deopt } = path.evaluate();\n if (deopt && deopt.isIdentifier()) {\n return deopt.node.name;\n }\n}\n\nexport function resolveKey(\n path: NodePath,\n computed: boolean = false,\n) {\n const { scope } = path;\n if (path.isStringLiteral()) return path.node.value;\n const isIdentifier = path.isIdentifier();\n if (\n isIdentifier &&\n !(computed || (path.parent as t.MemberExpression).computed)\n ) {\n return path.node.name;\n }\n\n if (\n computed &&\n path.isMemberExpression() &&\n path.get(\"object\").isIdentifier({ name: \"Symbol\" }) &&\n !scope.hasBinding(\"Symbol\", /* noGlobals */ true)\n ) {\n const sym = resolveKey(path.get(\"property\"), path.node.computed);\n if (sym) return \"Symbol.\" + sym;\n }\n\n if (!isIdentifier || scope.hasBinding(path.node.name, /* noGlobals */ true)) {\n const { value } = path.evaluate();\n if (typeof value === \"string\") return value;\n }\n}\n\nexport function resolveSource(obj: NodePath): {\n id: string | null;\n placement: \"prototype\" | \"static\" | null;\n} {\n if (\n obj.isMemberExpression() &&\n obj.get(\"property\").isIdentifier({ name: \"prototype\" })\n ) {\n const id = resolveId(obj.get(\"object\"));\n\n if (id) {\n return { id, placement: \"prototype\" };\n }\n return { id: null, placement: null };\n }\n\n const id = resolveId(obj);\n if (id) {\n return { id, placement: \"static\" };\n }\n\n const { value } = obj.evaluate();\n if (value !== undefined) {\n return { id: getType(value), placement: \"prototype\" };\n } else if (obj.isRegExpLiteral()) {\n return { id: \"RegExp\", placement: \"prototype\" };\n } else if (obj.isFunction()) {\n return { id: \"Function\", placement: \"prototype\" };\n }\n\n return { id: null, placement: null };\n}\n\nexport function getImportSource({ node }: NodePath) {\n if (node.specifiers.length === 0) return node.source.value;\n}\n\nexport function getRequireSource({ node }: NodePath) {\n if (!t.isExpressionStatement(node)) return;\n const { expression } = node;\n if (\n t.isCallExpression(expression) &&\n t.isIdentifier(expression.callee) &&\n expression.callee.name === \"require\" &&\n expression.arguments.length === 1 &&\n t.isStringLiteral(expression.arguments[0])\n ) {\n return expression.arguments[0].value;\n }\n}\n\nfunction hoist(node: t.Node) {\n // @ts-expect-error\n node._blockHoist = 3;\n return node;\n}\n\nexport function createUtilsGetter(cache: ImportsCache) {\n return (path: NodePath): Utils => {\n const prog = path.findParent(p => p.isProgram()) as NodePath;\n\n return {\n injectGlobalImport(url) {\n cache.storeAnonymous(prog, url, (isScript, source) => {\n return isScript\n ? template.statement.ast`require(${source})`\n : t.importDeclaration([], source);\n });\n },\n injectNamedImport(url, name, hint = name) {\n return cache.storeNamed(prog, url, name, (isScript, source, name) => {\n const id = prog.scope.generateUidIdentifier(hint);\n return {\n node: isScript\n ? hoist(template.statement.ast`\n var ${id} = require(${source}).${name}\n `)\n : t.importDeclaration([t.importSpecifier(id, name)], source),\n name: id.name,\n };\n });\n },\n injectDefaultImport(url, hint = url) {\n return cache.storeNamed(prog, url, \"default\", (isScript, source) => {\n const id = prog.scope.generateUidIdentifier(hint);\n return {\n node: isScript\n ? hoist(template.statement.ast`var ${id} = require(${source})`)\n : t.importDeclaration([t.importDefaultSpecifier(id)], source),\n name: id.name,\n };\n });\n },\n };\n };\n}\n","import type { NodePath } from \"@babel/traverse\";\nimport { types as t } from \"@babel/core\";\n\ntype StrMap = Map;\n\nexport default class ImportsCache {\n _imports: WeakMap, StrMap>;\n _anonymousImports: WeakMap, Set>;\n _lastImports: WeakMap, NodePath>;\n _resolver: (url: string) => string;\n\n constructor(resolver: (url: string) => string) {\n this._imports = new WeakMap();\n this._anonymousImports = new WeakMap();\n this._lastImports = new WeakMap();\n this._resolver = resolver;\n }\n\n storeAnonymous(\n programPath: NodePath,\n url: string,\n // eslint-disable-next-line no-undef\n getVal: (isScript: boolean, source: t.StringLiteral) => t.Node,\n ) {\n const key = this._normalizeKey(programPath, url);\n const imports = this._ensure>(\n this._anonymousImports,\n programPath,\n Set,\n );\n\n if (imports.has(key)) return;\n\n const node = getVal(\n programPath.node.sourceType === \"script\",\n t.stringLiteral(this._resolver(url)),\n );\n imports.add(key);\n this._injectImport(programPath, node);\n }\n\n storeNamed(\n programPath: NodePath,\n url: string,\n name: string,\n getVal: (\n isScript: boolean,\n // eslint-disable-next-line no-undef\n source: t.StringLiteral,\n // eslint-disable-next-line no-undef\n name: t.Identifier,\n ) => { node: t.Node; name: string },\n ) {\n const key = this._normalizeKey(programPath, url, name);\n const imports = this._ensure>(\n this._imports,\n programPath,\n Map,\n );\n\n if (!imports.has(key)) {\n const { node, name: id } = getVal(\n programPath.node.sourceType === \"script\",\n t.stringLiteral(this._resolver(url)),\n t.identifier(name),\n );\n imports.set(key, id);\n this._injectImport(programPath, node);\n }\n\n return t.identifier(imports.get(key));\n }\n\n _injectImport(programPath: NodePath, node: t.Node) {\n const lastImport = this._lastImports.get(programPath);\n let newNodes: [NodePath];\n if (\n lastImport &&\n lastImport.node &&\n // Sometimes the AST is modified and the \"last import\"\n // we have has been replaced\n lastImport.parent === programPath.node &&\n lastImport.container === programPath.node.body\n ) {\n newNodes = lastImport.insertAfter(node);\n } else {\n newNodes = programPath.unshiftContainer(\"body\", node);\n }\n const newNode = newNodes[newNodes.length - 1];\n this._lastImports.set(programPath, newNode);\n\n /*\n let lastImport;\n\n programPath.get(\"body\").forEach(path => {\n if (path.isImportDeclaration()) lastImport = path;\n if (\n path.isExpressionStatement() &&\n isRequireCall(path.get(\"expression\"))\n ) {\n lastImport = path;\n }\n if (\n path.isVariableDeclaration() &&\n path.get(\"declarations\").length === 1 &&\n (isRequireCall(path.get(\"declarations.0.init\")) ||\n (path.get(\"declarations.0.init\").isMemberExpression() &&\n isRequireCall(path.get(\"declarations.0.init.object\"))))\n ) {\n lastImport = path;\n }\n });*/\n }\n\n _ensure | Set>(\n map: WeakMap, C>,\n programPath: NodePath,\n Collection: { new (...args: any): C },\n ): C {\n let collection = map.get(programPath);\n if (!collection) {\n collection = new Collection();\n map.set(programPath, collection);\n }\n return collection;\n }\n\n _normalizeKey(\n programPath: NodePath,\n url: string,\n name: string = \"\",\n ): string {\n const { sourceType } = programPath.node;\n\n // If we rely on the imported binding (the \"name\" parameter), we also need to cache\n // based on the sourceType. This is because the module transforms change the names\n // of the import variables.\n return `${name && sourceType}::${url}::${name}`;\n }\n}\n","import { prettifyTargets } from \"@babel/helper-compilation-targets\";\n\nimport type { Targets } from \"./types\";\n\nexport const presetEnvSilentDebugHeader =\n \"#__secret_key__@babel/preset-env__don't_log_debug_header_and_resolved_targets\";\n\nexport function stringifyTargetsMultiline(targets: Targets): string {\n return JSON.stringify(prettifyTargets(targets), null, 2);\n}\n\nexport function stringifyTargets(targets: Targets): string {\n return JSON.stringify(targets)\n .replace(/,/g, \", \")\n .replace(/^\\{\"/, '{ \"')\n .replace(/\"\\}$/, '\" }');\n}\n","import { intersection } from \"./utils\";\nimport type {\n Pattern,\n PluginOptions,\n MissingDependenciesOption,\n} from \"./types\";\n\nfunction patternToRegExp(pattern: Pattern): RegExp | null {\n if (pattern instanceof RegExp) return pattern;\n\n try {\n return new RegExp(`^${pattern}$`);\n } catch {\n return null;\n }\n}\n\nfunction buildUnusedError(label, unused) {\n if (!unused.length) return \"\";\n return (\n ` - The following \"${label}\" patterns didn't match any polyfill:\\n` +\n unused.map(original => ` ${String(original)}\\n`).join(\"\")\n );\n}\n\nfunction buldDuplicatesError(duplicates) {\n if (!duplicates.size) return \"\";\n return (\n ` - The following polyfills were matched both by \"include\" and \"exclude\" patterns:\\n` +\n Array.from(duplicates, name => ` ${name}\\n`).join(\"\")\n );\n}\n\nexport function validateIncludeExclude(\n provider: string,\n polyfills: Set,\n includePatterns: Pattern[],\n excludePatterns: Pattern[],\n) {\n let current;\n const filter = pattern => {\n const regexp = patternToRegExp(pattern);\n if (!regexp) return false;\n\n let matched = false;\n for (const polyfill of polyfills) {\n if (regexp.test(polyfill)) {\n matched = true;\n current.add(polyfill);\n }\n }\n return !matched;\n };\n\n // prettier-ignore\n const include = current = new Set ();\n const unusedInclude = Array.from(includePatterns).filter(filter);\n\n // prettier-ignore\n const exclude = current = new Set ();\n const unusedExclude = Array.from(excludePatterns).filter(filter);\n\n const duplicates = intersection(include, exclude);\n\n if (\n duplicates.size > 0 ||\n unusedInclude.length > 0 ||\n unusedExclude.length > 0\n ) {\n throw new Error(\n `Error while validating the \"${provider}\" provider options:\\n` +\n buildUnusedError(\"include\", unusedInclude) +\n buildUnusedError(\"exclude\", unusedExclude) +\n buldDuplicatesError(duplicates),\n );\n }\n\n return { include, exclude };\n}\n\nexport function applyMissingDependenciesDefaults(\n options: PluginOptions,\n babelApi: any,\n): MissingDependenciesOption {\n const { missingDependencies = {} } = options;\n if (missingDependencies === false) return false;\n\n const caller = babelApi.caller(caller => caller?.name);\n\n const {\n log = \"deferred\",\n inject = caller === \"rollup-plugin-babel\" ? \"throw\" : \"import\",\n all = false,\n } = missingDependencies;\n\n return { log, inject, all };\n}\n","import type { NodePath } from \"@babel/traverse\";\nimport { types as t } from \"@babel/core\";\nimport type { MetaDescriptor } from \"../types\";\n\nimport { resolveKey, resolveSource } from \"../utils\";\n\nexport default (\n callProvider: (payload: MetaDescriptor, path: NodePath) => void,\n) => {\n function property(object, key, placement, path) {\n return callProvider({ kind: \"property\", object, key, placement }, path);\n }\n\n return {\n // Symbol(), new Promise\n ReferencedIdentifier(path: NodePath) {\n const {\n node: { name },\n scope,\n } = path;\n if (scope.getBindingIdentifier(name)) return;\n\n callProvider({ kind: \"global\", name }, path);\n },\n\n MemberExpression(path: NodePath) {\n const key = resolveKey(path.get(\"property\"), path.node.computed);\n if (!key || key === \"prototype\") return;\n\n const object = path.get(\"object\");\n if (object.isIdentifier()) {\n const binding = object.scope.getBinding(object.node.name);\n if (binding && binding.path.isImportNamespaceSpecifier()) return;\n }\n\n const source = resolveSource(object);\n return property(source.id, key, source.placement, path);\n },\n\n ObjectPattern(path: NodePath) {\n const { parentPath, parent } = path;\n let obj;\n\n // const { keys, values } = Object\n if (parentPath.isVariableDeclarator()) {\n obj = parentPath.get(\"init\");\n // ({ keys, values } = Object)\n } else if (parentPath.isAssignmentExpression()) {\n obj = parentPath.get(\"right\");\n // !function ({ keys, values }) {...} (Object)\n // resolution does not work after properties transform :-(\n } else if (parentPath.isFunction()) {\n const grand = parentPath.parentPath;\n if (grand.isCallExpression() || grand.isNewExpression()) {\n if (grand.node.callee === parent) {\n obj = grand.get(\"arguments\")[path.key];\n }\n }\n }\n\n let id = null;\n let placement = null;\n if (obj) ({ id, placement } = resolveSource(obj));\n\n for (const prop of path.get(\"properties\")) {\n if (prop.isObjectProperty()) {\n const key = resolveKey(prop.get(\"key\"));\n if (key) property(id, key, placement, prop);\n }\n }\n },\n\n BinaryExpression(path: NodePath) {\n if (path.node.operator !== \"in\") return;\n\n const source = resolveSource(path.get(\"right\"));\n const key = resolveKey(path.get(\"left\"), true);\n\n if (!key) return;\n\n callProvider(\n {\n kind: \"in\",\n object: source.id,\n key,\n placement: source.placement,\n },\n path,\n );\n },\n };\n};\n","import type { NodePath } from \"@babel/traverse\";\nimport { types as t } from \"@babel/core\";\nimport type { MetaDescriptor } from \"../types\";\n\nimport { getImportSource, getRequireSource } from \"../utils\";\n\nexport default (\n callProvider: (payload: MetaDescriptor, path: NodePath) => void,\n) => ({\n ImportDeclaration(path: NodePath) {\n const source = getImportSource(path);\n if (!source) return;\n callProvider({ kind: \"import\", source }, path);\n },\n Program(path: NodePath) {\n path.get(\"body\").forEach(bodyPath => {\n const source = getRequireSource(bodyPath);\n if (!source) return;\n callProvider({ kind: \"import\", source }, bodyPath);\n });\n },\n});\n","import path from \"path\";\nimport debounce from \"lodash.debounce\";\nimport requireResolve from \"resolve\";\n\nconst nativeRequireResolve = parseFloat(process.versions.node) >= 8.9;\n\nimport { createRequire } from \"module\";\nconst require = createRequire(import/*::(_)*/.meta.url); // eslint-disable-line\n\nexport function resolve(\n dirname: string,\n moduleName: string,\n absoluteImports: boolean | string,\n): string {\n if (absoluteImports === false) return moduleName;\n\n let basedir = dirname;\n if (typeof absoluteImports === \"string\") {\n basedir = path.resolve(basedir, absoluteImports);\n }\n\n try {\n if (nativeRequireResolve) {\n return require.resolve(moduleName, {\n paths: [basedir],\n });\n } else {\n return requireResolve.sync(moduleName, { basedir });\n }\n } catch (err) {\n if (err.code !== \"MODULE_NOT_FOUND\") throw err;\n\n throw Object.assign(\n new Error(`Failed to resolve \"${moduleName}\" relative to \"${dirname}\"`),\n {\n code: \"BABEL_POLYFILL_NOT_FOUND\",\n polyfill: moduleName,\n dirname,\n },\n );\n }\n}\n\nexport function has(basedir: string, name: string) {\n try {\n if (nativeRequireResolve) {\n require.resolve(name, { paths: [basedir] });\n } else {\n requireResolve.sync(name, { basedir });\n }\n return true;\n } catch {\n return false;\n }\n}\n\nexport function logMissing(missingDeps: Set) {\n if (missingDeps.size === 0) return;\n\n const deps = Array.from(missingDeps).sort().join(\" \");\n\n console.warn(\n \"\\nSome polyfills have been added but are not present in your dependencies.\\n\" +\n \"Please run one of the following commands:\\n\" +\n `\\tnpm install --save ${deps}\\n` +\n `\\tyarn add ${deps}\\n`,\n );\n\n process.exitCode = 1;\n}\n\nlet allMissingDeps = new Set();\n\nconst laterLogMissingDependencies = debounce(() => {\n logMissing(allMissingDeps);\n allMissingDeps = new Set();\n}, 100);\n\nexport function laterLogMissing(missingDeps: Set) {\n if (missingDeps.size === 0) return;\n\n missingDeps.forEach(name => allMissingDeps.add(name));\n laterLogMissingDependencies();\n}\n","import type {\n MetaDescriptor,\n ResolverPolyfills,\n ResolvedPolyfill,\n} from \"./types\";\n\nimport { has } from \"./utils\";\n\ntype ResolverFn = (meta: MetaDescriptor) => void | ResolvedPolyfill;\n\nconst PossibleGlobalObjects = new Set([\n \"global\",\n \"globalThis\",\n \"self\",\n \"window\",\n]);\n\nexport default function createMetaResolver(\n polyfills: ResolverPolyfills,\n): ResolverFn {\n const { static: staticP, instance: instanceP, global: globalP } = polyfills;\n\n return meta => {\n if (meta.kind === \"global\" && globalP && has(globalP, meta.name)) {\n return { kind: \"global\", desc: globalP[meta.name], name: meta.name };\n }\n\n if (meta.kind === \"property\" || meta.kind === \"in\") {\n const { placement, object, key } = meta;\n\n if (object && placement === \"static\") {\n if (globalP && PossibleGlobalObjects.has(object) && has(globalP, key)) {\n return { kind: \"global\", desc: globalP[key], name: key };\n }\n\n if (staticP && has(staticP, object) && has(staticP[object], key)) {\n return {\n kind: \"static\",\n desc: staticP[object][key],\n name: `${object}$${key}`,\n };\n }\n }\n\n if (instanceP && has(instanceP, key)) {\n return { kind: \"instance\", desc: instanceP[key], name: `${key}` };\n }\n }\n };\n}\n","import { declare } from \"@babel/helper-plugin-utils\";\nimport type { NodePath } from \"@babel/traverse\";\n\nimport _getTargets, {\n isRequired,\n getInclusionReasons,\n} from \"@babel/helper-compilation-targets\";\nconst getTargets = _getTargets.default || _getTargets;\n\nimport { createUtilsGetter } from \"./utils\";\nimport ImportsCache from \"./imports-cache\";\nimport {\n stringifyTargetsMultiline,\n presetEnvSilentDebugHeader,\n} from \"./debug-utils\";\nimport {\n validateIncludeExclude,\n applyMissingDependenciesDefaults,\n} from \"./normalize-options\";\n\nimport type {\n ProviderApi,\n MethodString,\n Targets,\n MetaDescriptor,\n PolyfillProvider,\n PluginOptions,\n ProviderOptions,\n} from \"./types\";\n\nimport * as v from \"./visitors\";\nimport * as deps from \"./node/dependencies\";\n\nimport createMetaResolver from \"./meta-resolver\";\n\nexport type { PolyfillProvider, MetaDescriptor, Utils, Targets } from \"./types\";\n\nfunction resolveOptions(\n options: PluginOptions,\n babelApi,\n): {\n method: MethodString;\n methodName: \"usageGlobal\" | \"entryGlobal\" | \"usagePure\";\n targets: Targets;\n debug: boolean | typeof presetEnvSilentDebugHeader;\n shouldInjectPolyfill:\n | ((name: string, shouldInject: boolean) => boolean)\n | undefined;\n providerOptions: ProviderOptions;\n absoluteImports: string | boolean;\n} {\n const {\n method,\n targets: targetsOption,\n ignoreBrowserslistConfig,\n configPath,\n debug,\n shouldInjectPolyfill,\n absoluteImports,\n ...providerOptions\n } = options;\n\n if (isEmpty(options)) {\n throw new Error(\n `\\\nThis plugin requires options, for example:\n {\n \"plugins\": [\n [\"\", { method: \"usage-pure\" }]\n ]\n }\n\nSee more options at https://github.com/babel/babel-polyfills/blob/main/docs/usage.md`,\n );\n }\n\n let methodName;\n if (method === \"usage-global\") methodName = \"usageGlobal\";\n else if (method === \"entry-global\") methodName = \"entryGlobal\";\n else if (method === \"usage-pure\") methodName = \"usagePure\";\n else if (typeof method !== \"string\") {\n throw new Error(\".method must be a string\");\n } else {\n throw new Error(\n `.method must be one of \"entry-global\", \"usage-global\"` +\n ` or \"usage-pure\" (received ${JSON.stringify(method)})`,\n );\n }\n\n if (typeof shouldInjectPolyfill === \"function\") {\n if (options.include || options.exclude) {\n throw new Error(\n `.include and .exclude are not supported when using the` +\n ` .shouldInjectPolyfill function.`,\n );\n }\n } else if (shouldInjectPolyfill != null) {\n throw new Error(\n `.shouldInjectPolyfill must be a function, or undefined` +\n ` (received ${JSON.stringify(shouldInjectPolyfill)})`,\n );\n }\n\n if (\n absoluteImports != null &&\n typeof absoluteImports !== \"boolean\" &&\n typeof absoluteImports !== \"string\"\n ) {\n throw new Error(\n `.absoluteImports must be a boolean, a string, or undefined` +\n ` (received ${JSON.stringify(absoluteImports)})`,\n );\n }\n\n let targets;\n\n if (\n // If any browserslist-related option is specified, fallback to the old\n // behavior of not using the targets specified in the top-level options.\n targetsOption ||\n configPath ||\n ignoreBrowserslistConfig\n ) {\n const targetsObj =\n typeof targetsOption === \"string\" || Array.isArray(targetsOption)\n ? { browsers: targetsOption }\n : targetsOption;\n\n targets = getTargets(targetsObj, {\n ignoreBrowserslistConfig,\n configPath,\n });\n } else {\n targets = babelApi.targets();\n }\n\n return {\n method,\n methodName,\n targets,\n absoluteImports: absoluteImports ?? false,\n shouldInjectPolyfill,\n debug: !!debug,\n providerOptions: providerOptions as any as ProviderOptions,\n };\n}\n\nfunction instantiateProvider(\n factory: PolyfillProvider,\n options: PluginOptions,\n missingDependencies,\n dirname,\n debugLog,\n babelApi,\n) {\n const {\n method,\n methodName,\n targets,\n debug,\n shouldInjectPolyfill,\n providerOptions,\n absoluteImports,\n } = resolveOptions(options, babelApi);\n\n const getUtils = createUtilsGetter(\n new ImportsCache(moduleName =>\n deps.resolve(dirname, moduleName, absoluteImports),\n ),\n );\n\n // eslint-disable-next-line prefer-const\n let include, exclude;\n let polyfillsSupport;\n let polyfillsNames;\n let filterPolyfills;\n\n const depsCache = new Map();\n\n const api: ProviderApi = {\n babel: babelApi,\n getUtils,\n method: options.method,\n targets,\n createMetaResolver,\n shouldInjectPolyfill(name) {\n if (polyfillsNames === undefined) {\n throw new Error(\n `Internal error in the ${factory.name} provider: ` +\n `shouldInjectPolyfill() can't be called during initialization.`,\n );\n }\n if (!polyfillsNames.has(name)) {\n console.warn(\n `Internal error in the ${provider.name} provider: ` +\n `unknown polyfill \"${name}\".`,\n );\n }\n\n if (filterPolyfills && !filterPolyfills(name)) return false;\n\n let shouldInject = isRequired(name, targets, {\n compatData: polyfillsSupport,\n includes: include,\n excludes: exclude,\n });\n\n if (shouldInjectPolyfill) {\n shouldInject = shouldInjectPolyfill(name, shouldInject);\n if (typeof shouldInject !== \"boolean\") {\n throw new Error(`.shouldInjectPolyfill must return a boolean.`);\n }\n }\n\n return shouldInject;\n },\n debug(name) {\n debugLog().found = true;\n\n if (!debug || !name) return;\n\n if (debugLog().polyfills.has(provider.name)) return;\n debugLog().polyfills.set(\n name,\n polyfillsSupport && name && polyfillsSupport[name],\n );\n },\n assertDependency(name, version = \"*\") {\n if (missingDependencies === false) return;\n if (absoluteImports) {\n // If absoluteImports is not false, we will try resolving\n // the dependency and throw if it's not possible. We can\n // skip the check here.\n return;\n }\n\n const dep = version === \"*\" ? name : `${name}@^${version}`;\n\n const found = missingDependencies.all\n ? false\n : mapGetOr(depsCache, `${name} :: ${dirname}`, () =>\n deps.has(dirname, name),\n );\n\n if (!found) {\n debugLog().missingDeps.add(dep);\n }\n },\n };\n\n const provider = factory(api, providerOptions, dirname);\n\n if (typeof provider[methodName] !== \"function\") {\n throw new Error(\n `The \"${provider.name || factory.name}\" provider doesn't ` +\n `support the \"${method}\" polyfilling method.`,\n );\n }\n\n if (Array.isArray(provider.polyfills)) {\n polyfillsNames = new Set(provider.polyfills);\n filterPolyfills = provider.filterPolyfills;\n } else if (provider.polyfills) {\n polyfillsNames = new Set(Object.keys(provider.polyfills));\n polyfillsSupport = provider.polyfills;\n filterPolyfills = provider.filterPolyfills;\n } else {\n polyfillsNames = new Set();\n }\n\n ({ include, exclude } = validateIncludeExclude(\n provider.name || factory.name,\n polyfillsNames,\n providerOptions.include || [],\n providerOptions.exclude || [],\n ));\n\n return {\n debug,\n method,\n targets,\n provider,\n callProvider(payload: MetaDescriptor, path: NodePath) {\n const utils = getUtils(path);\n provider[methodName](payload, utils, path);\n },\n };\n}\n\nexport default function definePolyfillProvider(\n factory: PolyfillProvider,\n) {\n return declare((babelApi, options: PluginOptions, dirname: string) => {\n babelApi.assertVersion(7);\n const { traverse } = babelApi;\n\n let debugLog;\n\n const missingDependencies = applyMissingDependenciesDefaults(\n options,\n babelApi,\n );\n\n const { debug, method, targets, provider, callProvider } =\n instantiateProvider(\n factory,\n options,\n missingDependencies,\n dirname,\n () => debugLog,\n babelApi,\n );\n\n const createVisitor = method === \"entry-global\" ? v.entry : v.usage;\n\n const visitor = provider.visitor\n ? traverse.visitors.merge([createVisitor(callProvider), provider.visitor])\n : createVisitor(callProvider);\n\n if (debug && debug !== presetEnvSilentDebugHeader) {\n console.log(`${provider.name}: \\`DEBUG\\` option`);\n console.log(`\\nUsing targets: ${stringifyTargetsMultiline(targets)}`);\n console.log(`\\nUsing polyfills with \\`${method}\\` method:`);\n }\n\n return {\n name: \"inject-polyfills\",\n visitor,\n\n pre() {\n debugLog = {\n polyfills: new Map(),\n found: false,\n providers: new Set(),\n missingDeps: new Set(),\n };\n\n provider.pre?.apply(this, arguments);\n },\n post() {\n provider.post?.apply(this, arguments);\n\n if (missingDependencies !== false) {\n if (missingDependencies.log === \"per-file\") {\n deps.logMissing(debugLog.missingDeps);\n } else {\n deps.laterLogMissing(debugLog.missingDeps);\n }\n }\n\n if (!debug) return;\n\n if (this.filename) console.log(`\\n[${this.filename}]`);\n\n if (debugLog.polyfills.size === 0) {\n console.log(\n method === \"entry-global\"\n ? debugLog.found\n ? `Based on your targets, the ${provider.name} polyfill did not add any polyfill.`\n : `The entry point for the ${provider.name} polyfill has not been found.`\n : `Based on your code and targets, the ${provider.name} polyfill did not add any polyfill.`,\n );\n\n return;\n }\n\n if (method === \"entry-global\") {\n console.log(\n `The ${provider.name} polyfill entry has been replaced with ` +\n `the following polyfills:`,\n );\n } else {\n console.log(\n `The ${provider.name} polyfill added the following polyfills:`,\n );\n }\n\n for (const [name, support] of debugLog.polyfills) {\n if (support) {\n const filteredTargets = getInclusionReasons(name, targets, support);\n\n const formattedTargets = JSON.stringify(filteredTargets)\n .replace(/,/g, \", \")\n .replace(/^\\{\"/, '{ \"')\n .replace(/\"\\}$/, '\" }');\n\n console.log(` ${name} ${formattedTargets}`);\n } else {\n console.log(` ${name}`);\n }\n }\n },\n };\n });\n}\n\nfunction mapGetOr(map, key, getDefault) {\n let val = map.get(key);\n if (val === undefined) {\n val = getDefault();\n map.set(key, val);\n }\n return val;\n}\n\nfunction isEmpty(obj) {\n return Object.keys(obj).length === 0;\n}\n"],"names":["types","t","template","intersection","a","b","result","Set","forEach","v","has","add","object","key","Object","prototype","hasOwnProperty","call","getType","target","toString","slice","resolveId","path","isIdentifier","scope","hasBinding","node","name","deopt","evaluate","resolveKey","computed","isStringLiteral","value","parent","isMemberExpression","get","sym","resolveSource","obj","id","placement","undefined","isRegExpLiteral","isFunction","getImportSource","specifiers","length","source","getRequireSource","isExpressionStatement","expression","isCallExpression","callee","arguments","hoist","_blockHoist","createUtilsGetter","cache","prog","findParent","p","isProgram","injectGlobalImport","url","storeAnonymous","isScript","statement","ast","importDeclaration","injectNamedImport","hint","storeNamed","generateUidIdentifier","importSpecifier","injectDefaultImport","importDefaultSpecifier","ImportsCache","constructor","resolver","_imports","WeakMap","_anonymousImports","_lastImports","_resolver","programPath","getVal","_normalizeKey","imports","_ensure","sourceType","stringLiteral","_injectImport","Map","identifier","set","lastImport","newNodes","container","body","insertAfter","unshiftContainer","newNode","map","Collection","collection","presetEnvSilentDebugHeader","stringifyTargetsMultiline","targets","JSON","stringify","prettifyTargets","patternToRegExp","pattern","RegExp","buildUnusedError","label","unused","original","String","join","buldDuplicatesError","duplicates","size","Array","from","validateIncludeExclude","provider","polyfills","includePatterns","excludePatterns","current","filter","regexp","matched","polyfill","test","include","unusedInclude","exclude","unusedExclude","Error","applyMissingDependenciesDefaults","options","babelApi","missingDependencies","caller","log","inject","all","callProvider","property","kind","ReferencedIdentifier","getBindingIdentifier","MemberExpression","binding","getBinding","isImportNamespaceSpecifier","ObjectPattern","parentPath","isVariableDeclarator","isAssignmentExpression","grand","isNewExpression","prop","isObjectProperty","BinaryExpression","operator","ImportDeclaration","Program","bodyPath","nativeRequireResolve","parseFloat","process","versions","require","createRequire","import","meta","resolve","dirname","moduleName","absoluteImports","basedir","paths","requireResolve","sync","err","code","assign","logMissing","missingDeps","deps","sort","console","warn","exitCode","allMissingDeps","laterLogMissingDependencies","debounce","laterLogMissing","PossibleGlobalObjects","createMetaResolver","static","staticP","instance","instanceP","global","globalP","desc","getTargets","_getTargets","default","resolveOptions","method","targetsOption","ignoreBrowserslistConfig","configPath","debug","shouldInjectPolyfill","providerOptions","isEmpty","methodName","targetsObj","isArray","browsers","instantiateProvider","factory","debugLog","getUtils","polyfillsSupport","polyfillsNames","filterPolyfills","depsCache","api","babel","shouldInject","isRequired","compatData","includes","excludes","found","assertDependency","version","dep","mapGetOr","keys","payload","utils","definePolyfillProvider","declare","assertVersion","traverse","createVisitor","visitor","visitors","merge","pre","providers","apply","post","filename","support","filteredTargets","getInclusionReasons","formattedTargets","replace","getDefault","val"],"mappings":";;;;;;;;;AAASA,EAAAA,OAASC;AAAGC,EAAAA,UAAAA;;AAKd,SAASC,YAAT,CAAyBC,CAAzB,EAAoCC,CAApC,EAAuD;AAC5D,QAAMC,MAAM,GAAG,IAAIC,GAAJ,EAAf;AACAH,EAAAA,CAAC,CAACI,OAAF,CAAUC,CAAC,IAAIJ,CAAC,CAACK,GAAF,CAAMD,CAAN,KAAYH,MAAM,CAACK,GAAP,CAAWF,CAAX,CAA3B;AACA,SAAOH,MAAP;AACD;AAEM,SAASI,KAAT,CAAaE,MAAb,EAA0BC,GAA1B,EAAuC;AAC5C,SAAOC,MAAM,CAACC,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCL,MAArC,EAA6CC,GAA7C,CAAP;AACD;;AAED,SAASK,OAAT,CAAiBC,MAAjB,EAAsC;AACpC,SAAOL,MAAM,CAACC,SAAP,CAAiBK,QAAjB,CAA0BH,IAA1B,CAA+BE,MAA/B,EAAuCE,KAAvC,CAA6C,CAA7C,EAAgD,CAAC,CAAjD,CAAP;AACD;;AAED,SAASC,SAAT,CAAmBC,IAAnB,EAAiC;AAC/B,MACEA,IAAI,CAACC,YAAL,MACA,CAACD,IAAI,CAACE,KAAL,CAAWC,UAAX,CAAsBH,IAAI,CAACI,IAAL,CAAUC,IAAhC;AAAsC;AAAgB,MAAtD,CAFH,EAGE;A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