1 line
3.1 KiB
Plaintext
1 line
3.1 KiB
Plaintext
|
{"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;AAAEC,EAAAA,KAAF;AAASC,EAAAA,OAAT;AAAkBC,EA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