supercat666's picture
fixed igv
1df763a
raw
history blame
3.5 kB
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import defineProvider from \"@babel/helper-define-polyfill-provider\";\nimport type { PluginPass } from \"@babel/core\";\n\nconst runtimeCompat = \"#__secret_key__@babel/runtime__compatibility\";\n\ntype Options = {\n \"#__secret_key__@babel/runtime__compatibility\": void | {\n useBabelRuntime: string;\n };\n};\n\nexport default defineProvider<Options>(({ debug, targets, babel }, options) => {\n if (!shallowEqual(targets, babel.targets())) {\n throw new Error(\n \"This plugin does not use the targets option. Only preset-env's targets\" +\n \" or top-level targets need to be configured for this plugin to work.\" +\n \" See https://github.com/babel/babel-polyfills/issues/36 for more\" +\n \" details.\",\n );\n }\n\n const { [runtimeCompat]: { useBabelRuntime = false } = {} } = options;\n\n return {\n name: \"regenerator\",\n\n polyfills: [\"regenerator-runtime\"],\n\n usageGlobal(meta, utils) {\n if (isRegenerator(meta)) {\n debug(\"regenerator-runtime\");\n utils.injectGlobalImport(\"regenerator-runtime/runtime.js\");\n }\n },\n usagePure(meta, utils, path) {\n if (isRegenerator(meta)) {\n let pureName = \"regenerator-runtime\";\n if (useBabelRuntime) {\n const runtimeName =\n ((path.hub as any).file as PluginPass).get(\n \"runtimeHelpersModuleName\",\n ) ?? \"@babel/runtime\";\n pureName = `${runtimeName}/regenerator`;\n }\n\n path.replaceWith(\n utils.injectDefaultImport(pureName, \"regenerator-runtime\"),\n );\n }\n },\n };\n});\n\nconst isRegenerator = meta =>\n meta.kind === \"global\" && meta.name === \"regeneratorRuntime\";\n\nfunction shallowEqual(obj1: any, obj2: any) {\n return JSON.stringify(obj1) === JSON.stringify(obj2);\n}\n"],"names":["runtimeCompat","defineProvider","debug","targets","babel","options","shallowEqual","Error","useBabelRuntime","name","polyfills","usageGlobal","meta","utils","isRegenerator","injectGlobalImport","usagePure","path","pureName","_get","runtimeName","hub","file","get","replaceWith","injectDefaultImport","kind","obj1","obj2","JSON","stringify"],"mappings":";;AAGA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