From aa773172311dcada759dfbaac485f4bc6e00bc21 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sat, 14 Oct 2023 15:31:11 +0800 Subject: added babel --- .../preset-env/lib/polyfills/babel-polyfill.js | 70 ++++++++++++++++++++++ .../preset-env/lib/polyfills/babel-polyfill.js.map | 1 + .../@babel/preset-env/lib/polyfills/regenerator.js | 46 ++++++++++++++ .../preset-env/lib/polyfills/regenerator.js.map | 1 + .../@babel/preset-env/lib/polyfills/utils.js | 36 +++++++++++ .../@babel/preset-env/lib/polyfills/utils.js.map | 1 + 6 files changed, 155 insertions(+) create mode 100644 node_modules/@babel/preset-env/lib/polyfills/babel-polyfill.js create mode 100644 node_modules/@babel/preset-env/lib/polyfills/babel-polyfill.js.map create mode 100644 node_modules/@babel/preset-env/lib/polyfills/regenerator.js create mode 100644 node_modules/@babel/preset-env/lib/polyfills/regenerator.js.map create mode 100644 node_modules/@babel/preset-env/lib/polyfills/utils.js create mode 100644 node_modules/@babel/preset-env/lib/polyfills/utils.js.map (limited to 'node_modules/@babel/preset-env/lib/polyfills') diff --git a/node_modules/@babel/preset-env/lib/polyfills/babel-polyfill.js b/node_modules/@babel/preset-env/lib/polyfills/babel-polyfill.js new file mode 100644 index 00000000..bc9f0082 --- /dev/null +++ b/node_modules/@babel/preset-env/lib/polyfills/babel-polyfill.js @@ -0,0 +1,70 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = _default; +var _utils = require("./utils.js"); +const BABEL_POLYFILL_DEPRECATION = ` + \`@babel/polyfill\` is deprecated. Please, use required parts of \`core-js\` + and \`regenerator-runtime/runtime\` separately`; +const NO_DIRECT_POLYFILL_IMPORT = ` + When setting \`useBuiltIns: 'usage'\`, polyfills are automatically imported when needed. + Please remove the direct import of \`SPECIFIER\` or use \`useBuiltIns: 'entry'\` instead.`; +function _default({ + template +}, { + regenerator, + deprecated, + usage +}) { + return { + name: "preset-env/replace-babel-polyfill", + visitor: { + ImportDeclaration(path) { + const src = (0, _utils.getImportSource)(path); + if (usage && (0, _utils.isPolyfillSource)(src)) { + console.warn(NO_DIRECT_POLYFILL_IMPORT.replace("SPECIFIER", src)); + if (!deprecated) path.remove(); + } else if (src === "@babel/polyfill") { + if (deprecated) { + console.warn(BABEL_POLYFILL_DEPRECATION); + } else if (regenerator) { + path.replaceWithMultiple(template.ast` + import "core-js"; + import "regenerator-runtime/runtime.js"; + `); + } else { + path.replaceWith(template.ast` + import "core-js"; + `); + } + } + }, + Program(path) { + path.get("body").forEach(bodyPath => { + const src = (0, _utils.getRequireSource)(bodyPath); + if (usage && (0, _utils.isPolyfillSource)(src)) { + console.warn(NO_DIRECT_POLYFILL_IMPORT.replace("SPECIFIER", src)); + if (!deprecated) bodyPath.remove(); + } else if (src === "@babel/polyfill") { + if (deprecated) { + console.warn(BABEL_POLYFILL_DEPRECATION); + } else if (regenerator) { + bodyPath.replaceWithMultiple(template.ast` + require("core-js"); + require("regenerator-runtime/runtime.js"); + `); + } else { + bodyPath.replaceWith(template.ast` + require("core-js"); + `); + } + } + }); + } + } + }; +} + +//# sourceMappingURL=babel-polyfill.js.map diff --git a/node_modules/@babel/preset-env/lib/polyfills/babel-polyfill.js.map b/node_modules/@babel/preset-env/lib/polyfills/babel-polyfill.js.map new file mode 100644 index 00000000..b4029aec --- /dev/null +++ b/node_modules/@babel/preset-env/lib/polyfills/babel-polyfill.js.map @@ -0,0 +1 @@ +{"version":3,"names":["_utils","require","BABEL_POLYFILL_DEPRECATION","NO_DIRECT_POLYFILL_IMPORT","_default","template","regenerator","deprecated","usage","name","visitor","ImportDeclaration","path","src","getImportSource","isPolyfillSource","console","warn","replace","remove","replaceWithMultiple","ast","replaceWith","Program","get","forEach","bodyPath","getRequireSource"],"sources":["../../src/polyfills/babel-polyfill.ts"],"sourcesContent":["import {\n getImportSource,\n getRequireSource,\n isPolyfillSource,\n} from \"./utils.ts\";\n\nimport type { NodePath } from \"@babel/traverse\";\nimport type * as t from \"@babel/types\";\n\nconst BABEL_POLYFILL_DEPRECATION = `\n \\`@babel/polyfill\\` is deprecated. Please, use required parts of \\`core-js\\`\n and \\`regenerator-runtime/runtime\\` separately`;\n\nconst NO_DIRECT_POLYFILL_IMPORT = `\n When setting \\`useBuiltIns: 'usage'\\`, polyfills are automatically imported when needed.\n Please remove the direct import of \\`SPECIFIER\\` or use \\`useBuiltIns: 'entry'\\` instead.`;\n\nexport default function (\n { template }: any,\n { regenerator, deprecated, usage }: any,\n) {\n return {\n name: \"preset-env/replace-babel-polyfill\",\n visitor: {\n ImportDeclaration(path: NodePath) {\n const src = getImportSource(path);\n if (usage && isPolyfillSource(src)) {\n console.warn(NO_DIRECT_POLYFILL_IMPORT.replace(\"SPECIFIER\", src));\n if (!deprecated) path.remove();\n } else if (src === \"@babel/polyfill\") {\n if (deprecated) {\n console.warn(BABEL_POLYFILL_DEPRECATION);\n } else if (regenerator) {\n path.replaceWithMultiple(template.ast`\n import \"core-js\";\n import \"regenerator-runtime/runtime.js\";\n `);\n } else {\n path.replaceWith(template.ast`\n import \"core-js\";\n `);\n }\n }\n },\n Program(path: NodePath) {\n path.get(\"body\").forEach(bodyPath => {\n const src = getRequireSource(bodyPath);\n if (usage && isPolyfillSource(src)) {\n console.warn(NO_DIRECT_POLYFILL_IMPORT.replace(\"SPECIFIER\", src));\n if (!deprecated) bodyPath.remove();\n } else if (src === \"@babel/polyfill\") {\n if (deprecated) {\n console.warn(BABEL_POLYFILL_DEPRECATION);\n } else if (regenerator) {\n bodyPath.replaceWithMultiple(template.ast`\n require(\"core-js\");\n require(\"regenerator-runtime/runtime.js\");\n `);\n } else {\n bodyPath.replaceWith(template.ast`\n require(\"core-js\");\n `);\n }\n }\n });\n },\n },\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AASA,MAAMC,0BAA0B,GAAI;AACpC;AACA,iDAAiD;AAEjD,MAAMC,yBAAyB,GAAI;AACnC;AACA,4FAA4F;AAE7E,SAAAC,SACb;EAAEC;AA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C,IAAIN,UAAU,EAAE;cACdS,OAAO,CAACC,IAAI,CAACf,0BAA0B,CAAC;YAC1C,CAAC,MAAM,IAAII,WAAW,EAAE;cACtBoB,QAAQ,CAACN,mBAAmB,CAACf,QAAQ,CAACgB,GAAI;AACxD;AACA;AACA,eAAe,CAAC;YACJ,CAAC,MAAM;cACLK,QAAQ,CAACJ,WAAW,CAACjB,QAAQ,CAACgB,GAAI;AAChD;AACA,eAAe,CAAC;YACJ;UACF;QACF,CAAC,CAAC;MACJ;IACF;EACF,CAAC;AACH"} \ No newline at end of file diff --git a/node_modules/@babel/preset-env/lib/polyfills/regenerator.js b/node_modules/@babel/preset-env/lib/polyfills/regenerator.js new file mode 100644 index 00000000..c02846fa --- /dev/null +++ b/node_modules/@babel/preset-env/lib/polyfills/regenerator.js @@ -0,0 +1,46 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = _default; +var _utils = require("./utils.js"); +function isRegeneratorSource(source) { + return source === "regenerator-runtime/runtime" || source === "regenerator-runtime/runtime.js"; +} +function _default() { + const visitor = { + ImportDeclaration(path) { + if (isRegeneratorSource((0, _utils.getImportSource)(path))) { + this.regeneratorImportExcluded = true; + path.remove(); + } + }, + Program(path) { + path.get("body").forEach(bodyPath => { + if (isRegeneratorSource((0, _utils.getRequireSource)(bodyPath))) { + this.regeneratorImportExcluded = true; + bodyPath.remove(); + } + }); + } + }; + return { + name: "preset-env/remove-regenerator", + visitor, + pre() { + this.regeneratorImportExcluded = false; + }, + post() { + if (this.opts.debug && this.regeneratorImportExcluded) { + let filename = this.file.opts.filename; + if (process.env.BABEL_ENV === "test") { + filename = filename.replace(/\\/g, "/"); + } + console.log(`\n[${filename}] Based on your targets, regenerator-runtime import excluded.`); + } + } + }; +} + +//# sourceMappingURL=regenerator.js.map diff --git a/node_modules/@babel/preset-env/lib/polyfills/regenerator.js.map b/node_modules/@babel/preset-env/lib/polyfills/regenerator.js.map new file mode 100644 index 00000000..680dd912 --- /dev/null +++ b/node_modules/@babel/preset-env/lib/polyfills/regenerator.js.map @@ -0,0 +1 @@ +{"version":3,"names":["_utils","require","isRegeneratorSource","source","_default","visitor","ImportDeclaration","path","getImportSource","regeneratorImportExcluded","remove","Program","get","forEach","bodyPath","getRequireSource","name","pre","post","opts","debug","filename","file","process","env","BABEL_ENV","replace","console","log"],"sources":["../../src/polyfills/regenerator.ts"],"sourcesContent":["import { getImportSource, getRequireSource } from \"./utils.ts\";\nimport type { Visitor } from \"@babel/traverse\";\nimport type { PluginObject, PluginPass } from \"@babel/core\";\nimport type { Options } from \"../types.ts\";\n\nfunction isRegeneratorSource(source: string) {\n return (\n source === \"regenerator-runtime/runtime\" ||\n source === \"regenerator-runtime/runtime.js\"\n );\n}\n\ntype State = {\n regeneratorImportExcluded: boolean;\n};\n\nexport default function (): PluginObject> {\n const visitor: Visitor = {\n ImportDeclaration(path) {\n if (isRegeneratorSource(getImportSource(path))) {\n this.regeneratorImportExcluded = true;\n path.remove();\n }\n },\n Program(path) {\n path.get(\"body\").forEach(bodyPath => {\n if (isRegeneratorSource(getRequireSource(bodyPath))) {\n this.regeneratorImportExcluded = true;\n bodyPath.remove();\n }\n });\n },\n };\n\n return {\n name: \"preset-env/remove-regenerator\",\n visitor,\n pre() {\n this.regeneratorImportExcluded = false;\n },\n post() {\n if (this.opts.debug && this.regeneratorImportExcluded) {\n let filename = this.file.opts.filename;\n // normalize filename to generate consistent preset-env test fixtures\n if (process.env.BABEL_ENV === \"test\") {\n filename = filename.replace(/\\\\/g, \"/\");\n }\n console.log(\n `\\n[${filename}] Based on your targets, regenerator-runtime import excluded.`,\n );\n }\n },\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAKA,SAASC,mBAAmBA,CAACC,MAAc,EAAE;EAC3C,OACEA,MAAM,KAAK,6BAA6B,IACxCA,MAAM,KAAK,gCAAgC;AAE/C;AAMe,SAAAC,SAAA,EAAuD;EACpE,MAAMC,OAAoC,GAAG;IAC3CC,iBAAiBA,CAACC,IAAI,EAAE;MACtB,IAAIL,mBAAmB,CAAC,IAAAM,sBAAe,EAACD,IAAI,CAAC,CAAC,EAAE;QAC9C,IAAI,CAACE,yBAAyB,GAAG,IAAI;QACrCF,IAAI,CAACG,MAAM,CAAC,CAAC;MACf;IACF,CAAC;IACDC,OAAOA,CAACJ,IAAI,EAAE;MACZA,IAAI,CAACK,GAAG,CAAC,MAAM,CAAC,CAACC,OAAO,CAACC,QAAQ,IAAI;QACnC,IAAIZ,mBAAmB,CAAC,IAAAa,uBAAgB,EAACD,QAAQ,CAAC,CAAC,EAAE;UACnD,IAAI,CAACL,yBAAyB,GAAG,IAAI;UACrCK,QAAQ,CAACJ,MAAM,CAAC,CAAC;QACnB;MACF,CAAC,CAAC;IACJ;EACF,CAAC;EAED,OAAO;IACLM,IAAI,EAAE,+BAA+B;IACrCX,OAAO;IACPY,GAAGA,CAAA,EAAG;MACJ,IAAI,CAACR,yBAAyB,GAAG,KAAK;IACxC,CAAC;IACDS,IAAIA,CAAA,EAAG;MACL,IAAI,IAAI,CAACC,IAAI,CAACC,KAAK,IAAI,IAAI,CAACX,yBAAyB,EAAE;QACrD,IAAIY,QAAQ,GAAG,IAAI,CAACC,IAAI,CAACH,IAAI,CAACE,QAAQ;QAEtC,IAAIE,OAAO,CAACC,GAAG,CAACC,SAAS,KAAK,MAAM,EAAE;UACpCJ,QAAQ,GAAGA,QAAQ,CAACK,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;QACzC;QACAC,OAAO,CAACC,GAAG,CACR,MAAKP,QAAS,+DACjB,CAAC;MACH;IACF;EACF,CAAC;AACH"} \ No newline at end of file diff --git a/node_modules/@babel/preset-env/lib/polyfills/utils.js b/node_modules/@babel/preset-env/lib/polyfills/utils.js new file mode 100644 index 00000000..338e8860 --- /dev/null +++ b/node_modules/@babel/preset-env/lib/polyfills/utils.js @@ -0,0 +1,36 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getImportSource = getImportSource; +exports.getRequireSource = getRequireSource; +exports.isPolyfillSource = isPolyfillSource; +var _t = require("@babel/types"); +const { + isCallExpression, + isExpressionStatement, + isIdentifier, + isStringLiteral +} = _t; +function getImportSource({ + node +}) { + if (node.specifiers.length === 0) return node.source.value; +} +function getRequireSource({ + node +}) { + if (!isExpressionStatement(node)) return; + const { + expression + } = node; + if (isCallExpression(expression) && isIdentifier(expression.callee) && expression.callee.name === "require" && expression.arguments.length === 1 && isStringLiteral(expression.arguments[0])) { + return expression.arguments[0].value; + } +} +function isPolyfillSource(source) { + return source === "@babel/polyfill" || source === "core-js"; +} + +//# sourceMappingURL=utils.js.map diff --git a/node_modules/@babel/preset-env/lib/polyfills/utils.js.map b/node_modules/@babel/preset-env/lib/polyfills/utils.js.map new file mode 100644 index 00000000..92f693e8 --- /dev/null +++ b/node_modules/@babel/preset-env/lib/polyfills/utils.js.map @@ -0,0 +1 @@ +{"version":3,"names":["_t","require","isCallExpression","isExpressionStatement","isIdentifier","isStringLiteral","getImportSource","node","specifiers","length","source","value","getRequireSource","expression","callee","name","arguments","isPolyfillSource"],"sources":["../../src/polyfills/utils.ts"],"sourcesContent":["import {\n isCallExpression,\n isExpressionStatement,\n isIdentifier,\n isStringLiteral,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport type { NodePath } from \"@babel/traverse\";\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 (!isExpressionStatement(node)) return;\n const { expression } = node;\n if (\n isCallExpression(expression) &&\n isIdentifier(expression.callee) &&\n expression.callee.name === \"require\" &&\n expression.arguments.length === 1 &&\n isStringLiteral(expression.arguments[0])\n ) {\n return expression.arguments[0].value;\n }\n}\n\nexport function isPolyfillSource(source?: string | null): boolean {\n return source === \"@babel/polyfill\" || source === \"core-js\";\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,EAAA,GAAAC,OAAA;AAKsB;EAJpBC,gBAAgB;EAChBC,qBAAqB;EACrBC,YAAY;EACZC;AAAe,IAAAL,EAAA;AAKV,SAASM,eAAeA,CAAC;EAAEC;AAAoC,CAAC,EAAE;EACvE,IAAIA,IAAI,CAACC,UAAU,CAACC,MAAM,KAAK,CAAC,EAAE,OAAOF,IAAI,CAACG,MAAM,CAACC,KAAK;AAC5D;AAEO,SAASC,gBAAgBA,CAAC;EAAEL;AAAe,CAAC,EAAE;EACnD,IAAI,CAACJ,qBAAqB,CAACI,IAAI,CAAC,EAAE;EAClC,MAAM;IAAEM;EAAW,CAAC,GAAGN,IAAI;EAC3B,IACEL,gBAAgB,CAACW,UAAU,CAAC,IAC5BT,YAAY,CAACS,UAAU,CAACC,MAAM,CAAC,IAC/BD,UAAU,CAACC,MAAM,CAACC,IAAI,KAAK,SAAS,IACpCF,UAAU,CAACG,SAAS,CAACP,MAAM,KAAK,CAAC,IACjCJ,eAAe,CAACQ,UAAU,CAACG,SAAS,CAAC,CAAC,CAAC,CAAC,EACxC;IACA,OAAOH,UAAU,CAACG,SAAS,CAAC,CAAC,CAAC,CAACL,KAAK;EACtC;AACF;AAEO,SAASM,gBAAgBA,CAACP,MAAsB,EAAW;EAChE,OAAOA,MAAM,KAAK,iBAAiB,IAAIA,MAAM,KAAK,SAAS;AAC7D"} \ No newline at end of file -- cgit v1.2.3