babel-plugin-polyfill-regenerator 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.mjs +36 -0
- package/esm/index.mjs.map +1 -0
- package/package.json +14 -4
package/esm/index.mjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import defineProvider from '@babel/helper-define-polyfill-provider';
|
|
2
|
+
|
|
3
|
+
const runtimeCompat = "#__secret_key__@babel/runtime__compatibility";
|
|
4
|
+
var index = defineProvider(({
|
|
5
|
+
debug
|
|
6
|
+
}, options) => {
|
|
7
|
+
const {
|
|
8
|
+
[runtimeCompat]: {
|
|
9
|
+
useBabelRuntime
|
|
10
|
+
} = {}
|
|
11
|
+
} = options;
|
|
12
|
+
const pureName = useBabelRuntime ? `${useBabelRuntime}/regenerator` : "regenerator-runtime";
|
|
13
|
+
return {
|
|
14
|
+
name: "regenerator",
|
|
15
|
+
polyfills: ["regenerator-runtime"],
|
|
16
|
+
|
|
17
|
+
usageGlobal(meta, utils) {
|
|
18
|
+
if (isRegenerator(meta)) {
|
|
19
|
+
debug("regenerator-runtime");
|
|
20
|
+
utils.injectGlobalImport("regenerator-runtime/runtime.js");
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
usagePure(meta, utils, path) {
|
|
25
|
+
if (isRegenerator(meta)) {
|
|
26
|
+
path.replaceWith(utils.injectDefaultImport(pureName, "regenerator-runtime"));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const isRegenerator = meta => meta.kind === "global" && meta.name === "regeneratorRuntime";
|
|
34
|
+
|
|
35
|
+
export default index;
|
|
36
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.js"],"sourcesContent":["// @flow\n\nimport defineProvider from \"@babel/helper-define-polyfill-provider\";\n\nconst runtimeCompat = \"#__secret_key__@babel/runtime__compatibility\";\n\nexport default defineProvider(({ debug }, options) => {\n const { [runtimeCompat]: { useBabelRuntime } = {} } = 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"],"names":["runtimeCompat","defineProvider","debug","options","useBabelRuntime","pureName","name","polyfills","usageGlobal","meta","utils","isRegenerator","injectGlobalImport","usagePure","path","replaceWith","injectDefaultImport","kind"],"mappings":";;AAIA,MAAMA,aAAa,GAAG,8CAAtB;AAEA,YAAeC,cAAc,CAAC,CAAC;AAAEC,EAAAA;AAAF,CAAD,EAAYC,OAAZ,KAAwB;AACpD,QAAM;AAAE,KAACH,aAAD,GAAiB;AAAEI,MAAAA;AAAF,QAAsB;AAAzC,MAAgDD,OAAtD;AAEA,QAAME,QAAQ,GAAGD,eAAe,GAC3B,GAAEA,eAAgB,cADS,GAE5B,qBAFJ;AAIA,SAAO;AACLE,IAAAA,IAAI,EAAE,aADD;AAGLC,IAAAA,SAAS,EAAE,CAAC,qBAAD,CAHN;;AAKLC,IAAAA,WAAW,CAACC,IAAD,EAAOC,KAAP,EAAc;AACvB,UAAIC,aAAa,CAACF,IAAD,CAAjB,EAAyB;AACvBP,QAAAA,KAAK,CAAC,qBAAD,CAAL;AACAQ,QAAAA,KAAK,CAACE,kBAAN,CAAyB,gCAAzB;AACD;AACF,KAVI;;AAWLC,IAAAA,SAAS,CAACJ,IAAD,EAAOC,KAAP,EAAcI,IAAd,EAAoB;AAC3B,UAAIH,aAAa,CAACF,IAAD,CAAjB,EAAyB;AACvBK,QAAAA,IAAI,CAACC,WAAL,CACEL,KAAK,CAACM,mBAAN,CAA0BX,QAA1B,EAAoC,qBAApC,CADF;AAGD;AACF;;AAjBI,GAAP;AAmBD,CA1B4B,CAA7B;;AA4BA,MAAMM,aAAa,GAAGF,IAAI,IACxBA,IAAI,CAACQ,IAAL,KAAc,QAAd,IAA0BR,IAAI,CAACH,IAAL,KAAc,oBAD1C;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-plugin-polyfill-regenerator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "A Babel plugin to inject imports to regenerator-runtime",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,11 +12,21 @@
|
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
14
|
"main": "lib/index.js",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": [
|
|
17
|
+
{
|
|
18
|
+
"import": "./esm/index.mjs",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./lib/index.js"
|
|
22
|
+
],
|
|
23
|
+
"./package.json": "./package.json"
|
|
24
|
+
},
|
|
15
25
|
"keywords": [
|
|
16
26
|
"babel-plugin"
|
|
17
27
|
],
|
|
18
28
|
"dependencies": {
|
|
19
|
-
"@babel/helper-define-polyfill-provider": "^0.
|
|
29
|
+
"@babel/helper-define-polyfill-provider": "^0.2.0"
|
|
20
30
|
},
|
|
21
31
|
"devDependencies": {
|
|
22
32
|
"@babel/core": "^7.13.0",
|
|
@@ -25,5 +35,5 @@
|
|
|
25
35
|
"peerDependencies": {
|
|
26
36
|
"@babel/core": "^7.0.0-0"
|
|
27
37
|
},
|
|
28
|
-
"gitHead": "
|
|
29
|
-
}
|
|
38
|
+
"gitHead": "841e713e0002eb8aa167553fc43840e526fa2d8c"
|
|
39
|
+
}
|