index.mjs.map
2.99 KB
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import defineProvider from \"@babel/helper-define-polyfill-provider\";\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 } = { useBabelRuntime: \"\" } } =\n options;\n\n const pureName = useBabelRuntime\n ? `${useBabelRuntime}/regenerator`\n : \"regenerator-runtime\";\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 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","pureName","name","polyfills","usageGlobal","meta","utils","isRegenerator","injectGlobalImport","usagePure","path","replaceWith","injectDefaultImport","kind","obj1","obj2","JSON","stringify"],"mappings":";;AAEA,MAAMA,aAAa,GAAG,8CAAtB;AAQA,YAAeC,cAAc,CAAU,CAAC;EAAEC,KAAF;EAASC,OAAT;EAAkBC;AAAlB,CAAD,EAA4BC,OAA5B,KAAwC;EAC7E,I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