1 line
No EOL
3.1 KiB
Text
Executable file
1 line
No EOL
3.1 KiB
Text
Executable file
{"version":3,"names":["exports","skipAllButComputedKey","path","skip","node","computed","context","maybeQueue","get","requeueComputedKeyAndDecorators","decorators","decorator","visitor","FunctionParent","isArrowFunctionExpression","isMethod","Property","isObjectProperty","_default","default"],"sources":["../src/index.ts"],"sourcesContent":["import type { NodePath, Visitor } from \"@babel/traverse\";\nimport type * as t from \"@babel/types\";\n\nif (!process.env.BABEL_8_BREAKING && !USE_ESM && !IS_STANDALONE) {\n // eslint-disable-next-line no-restricted-globals\n exports.skipAllButComputedKey = function skipAllButComputedKey(\n path: NodePath<t.Method | t.ClassProperty>,\n ) {\n path.skip();\n if (path.node.computed) {\n // requeue the computed key\n path.context.maybeQueue(path.get(\"key\"));\n }\n };\n}\n\nexport function requeueComputedKeyAndDecorators(\n path: NodePath<t.Method | t.Property>,\n) {\n const { context, node } = path;\n // @ts-expect-error ClassPrivateProperty does not have computed\n if (node.computed) {\n // requeue the computed key\n context.maybeQueue(path.get(\"key\"));\n }\n if (node.decorators) {\n for (const decorator of path.get(\"decorators\")) {\n // requeue the decorators\n context.maybeQueue(decorator);\n }\n }\n}\n\n// environmentVisitor should be used when traversing the whole class and not for specific class elements/methods.\n// For perf reasons, the environmentVisitor might be traversed with `{ noScope: true }`, which means `path.scope` is undefined.\n// Avoid using `path.scope` here\nconst visitor: Visitor = {\n FunctionParent(path) {\n if (path.isArrowFunctionExpression()) {\n // arrows are not skipped because they inherit the context.\n return;\n } else {\n path.skip();\n if (path.isMethod()) {\n requeueComputedKeyAndDecorators(path);\n }\n }\n },\n Property(path) {\n if (path.isObjectProperty()) {\n return;\n }\n path.skip();\n requeueComputedKeyAndDecorators(path);\n },\n};\n\nexport default visitor;\n"],"mappings":";;;;;;;AAGiE;EAE/DA,OAAO,CAACC,qBAAqB,GAAG,SAASA,qBAAqBA,CAC5DC,IAA0C,EAC1C;IACAA,IAAI,CAACC,IAAI,CAAC,CAAC;IACX,IAA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