Debian Codegraph @

packages/babel-preset-env/src/polyfills/babel-polyfill.ts

raw symbols SCIP
1 import { getImportSourcescip-typescript npm @babel/preset-env 7.20.2 src/polyfills/`utils.ts`/getImportSource()., getRequireSourcescip-typescript npm @babel/preset-env 7.20.2 src/polyfills/`utils.ts`/getRequireSource()., isPolyfillSourcescip-typescript npm @babel/preset-env 7.20.2 src/polyfills/`utils.ts`/isPolyfillSource(). } from "./utils"scip-typescript npm @babel/preset-env 7.20.2 src/polyfills/`utils.ts`/;
2
3 import type { NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath# } from "@babel/traverse"scip-typescript npm @babel/traverse 7.20.13 src/`index.ts`/;
4 import type * as tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/ from "@babel/types"scip-typescript npm @babel/types 7.20.7 src/`index.ts`/;
5
6 const BABEL_POLYFILL_DEPRECATIONscip-typescript npm @babel/preset-env 7.20.2 src/polyfills/`babel-polyfill.ts`/BABEL_POLYFILL_DEPRECATION. = `
7 \`@babel/polyfill\` is deprecated. Please, use required parts of \`core-js\`
8 and \`regenerator-runtime/runtime\` separately`;
9
10 const NO_DIRECT_POLYFILL_IMPORTscip-typescript npm @babel/preset-env 7.20.2 src/polyfills/`babel-polyfill.ts`/NO_DIRECT_POLYFILL_IMPORT. = `
11 When setting \`useBuiltIns: 'usage'\`, polyfills are automatically imported when needed.
12 Please remove the direct import of \`SPECIFIER\` or use \`useBuiltIns: 'entry'\` instead.`;
13
14 export default function (
15 { template }: any,
16 { regenerator, deprecated, usage }: any,
17 ) {
18 return {
19 namescip-typescript npm @babel/preset-env 7.20.2 src/polyfills/`babel-polyfill.ts`/name0:: "preset-env/replace-babel-polyfill",
20 visitorscip-typescript npm @babel/preset-env 7.20.2 src/polyfills/`babel-polyfill.ts`/visitor0:: {
21 ImportDeclaration(path: NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#<tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.ImportDeclarationscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/ImportDeclaration#>) {
22 const src = getImportSourcescip-typescript npm @babel/preset-env 7.20.2 src/polyfills/`utils.ts`/getImportSource().(path);
23 if (usage && isPolyfillSourcescip-typescript npm @babel/preset-env 7.20.2 src/polyfills/`utils.ts`/isPolyfillSource().(src)) {
24 consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console..warnscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/Console#warn().(NO_DIRECT_POLYFILL_IMPORTscip-typescript npm @babel/preset-env 7.20.2 src/polyfills/`babel-polyfill.ts`/NO_DIRECT_POLYFILL_IMPORT..replacescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/String#replace().("SPECIFIER", src));
25 if (!deprecated) path.removescip-typescript npm @babel/traverse 7.20.13 src/path/`removal.ts`/remove().();
26 } else if (src === "@babel/polyfill") {
27 if (deprecated) {
28 consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console..warnscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/Console#warn().(BABEL_POLYFILL_DEPRECATIONscip-typescript npm @babel/preset-env 7.20.2 src/polyfills/`babel-polyfill.ts`/BABEL_POLYFILL_DEPRECATION.);
29 } else if (regenerator) {
30 path.replaceWithMultiplescip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWithMultiple().(template.ast`
31 import "core-js";
32 import "regenerator-runtime/runtime.js";
33 `);
34 } else {
35 path.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(template.ast`
36 import "core-js";
37 `);
38 }
39 }
40 },
41 Program(path: NodePathscip-typescript npm @babel/traverse 7.20.13 src/path/`index.ts`/NodePath#<tscip-typescript npm @babel/types 7.20.7 src/`index.ts`/.Programscip-typescript npm @babel/types 7.20.7 src/ast-types/generated/`index.ts`/Program#>) {
42 path.get("body").forEachscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#forEach().(bodyPath => {
43 const src = getRequireSourcescip-typescript npm @babel/preset-env 7.20.2 src/polyfills/`utils.ts`/getRequireSource().(bodyPath);
44 if (usage && isPolyfillSourcescip-typescript npm @babel/preset-env 7.20.2 src/polyfills/`utils.ts`/isPolyfillSource().(src)) {
45 consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console..warnscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/Console#warn().(NO_DIRECT_POLYFILL_IMPORTscip-typescript npm @babel/preset-env 7.20.2 src/polyfills/`babel-polyfill.ts`/NO_DIRECT_POLYFILL_IMPORT..replacescip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/String#replace().("SPECIFIER", src));
46 if (!deprecated) bodyPath.removescip-typescript npm @babel/traverse 7.20.13 src/path/`removal.ts`/remove().();
47 } else if (src === "@babel/polyfill") {
48 if (deprecated) {
49 consolescip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/console..warnscip-typescript npm typescript 5.9.3 lib/`lib.dom.d.ts`/Console#warn().(BABEL_POLYFILL_DEPRECATIONscip-typescript npm @babel/preset-env 7.20.2 src/polyfills/`babel-polyfill.ts`/BABEL_POLYFILL_DEPRECATION.);
50 } else if (regenerator) {
51 bodyPath.replaceWithMultiplescip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWithMultiple().(template.ast`
52 require("core-js");
53 require("regenerator-runtime/runtime.js");
54 `);
55 } else {
56 bodyPath.replaceWithscip-typescript npm @babel/traverse 7.20.13 src/path/`replacement.ts`/replaceWith().(template.ast`
57 require("core-js");
58 `);
59 }
60 }
61 });
62 },
63 },
64 };
65 }