You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
1.6 KiB
Plaintext
1 line
1.6 KiB
Plaintext
12 months ago
|
{"version":3,"names":["_helperEnvironmentVisitor","require","_core","numericLiteral","unaryExpression","t","rewriteThisVisitor","traverse","visitors","merge","environmentVisitor","ThisExpression","path","replaceWith","rewriteThis","programPath","node","Object","assign","noScope"],"sources":["../src/rewrite-this.ts"],"sourcesContent":["import environmentVisitor from \"@babel/helper-environment-visitor\";\nimport { traverse, types as t } from \"@babel/core\";\nconst { numericLiteral, unaryExpression } = t;\n\nimport type { NodePath, Visitor } from \"@babel/traverse\";\n\n/**\n * A visitor to walk the tree, rewriting all `this` references in the top-level scope to be\n * `void 0` (undefined).\n */\nconst rewriteThisVisitor: Visitor = traverse.visitors.merge([\n environmentVisitor,\n {\n ThisExpression(path) {\n path.replaceWith(unaryExpression(\"void\", numericLiteral(0), true));\n },\n },\n]);\n\nexport default function rewriteThis(programPath: NodePath) {\n // Rewrite \"this\" to be \"undefined\".\n traverse(programPath.node, { ...rewriteThisVisitor, noScope: true });\n}\n"],"mappings":";;;;;;AAAA,IAAAA,yBAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,MAAM;EAAEE,cAAc;EAAEC;AAAgB,CAAC,GAAGC,WAAC;AAQ7C,MAAMC,kBAA2B,GAAGC,cAAQ,CAACC,QAAQ,CAACC,KAAK,CAAC,CAC1DC,iCAAkB,EAClB;EACEC,cAAcA,CAACC,IAAI,EAAE;IACnBA,IAAI,CAACC,WAAW,CAACT,eAAe,CAAC,MAAM,EAAED,cAAc,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;EACpE;AACF,CAAC,CACF,CAAC;AAEa,SAASW,WAAWA,CAACC,WAAqB,EAAE;EAEzD,IAAAR,cAAQ,EAACQ,WAAW,CAACC,IAAI,EAAAC,MAAA,CAAAC,MAAA,KAAOZ,kBAAkB;IAAEa,OAAO,EAAE;EAAI,EAAE,CAAC;AACtE"}
|