|
1
|
import { parse, type ParseResult, type ParserOptions } from "@babel/parser" |
|
2
|
import _traverse, { type NodePath } from "@babel/traverse" |
|
3
|
import { |
|
4
|
ExportDefaultDeclaration, |
|
5
|
ExportNamedDeclaration, |
|
6
|
File, |
|
7
|
isArrayExpression, |
|
8
|
isCallExpression, |
|
9
|
isFunctionDeclaration, |
|
10
|
isIdentifier, |
|
11
|
isJSXElement, |
|
12
|
isJSXFragment, |
|
13
|
isMemberExpression, |
|
14
|
isNumericLiteral, |
|
15
|
isObjectExpression, |
|
16
|
isObjectProperty, |
|
17
|
isStringLiteral, |
|
18
|
isTemplateLiteral, |
|
19
|
isVariableDeclaration, |
|
20
|
isVariableDeclarator, |
|
21
|
Node, |
|
22
|
ObjectExpression, |
|
23
|
ObjectMethod, |
|
24
|
ObjectProperty, |
|
25
|
SpreadElement, |
|
26
|
StringLiteral, |
|
27
|
VariableDeclarator, |
|
28
|
} from "@babel/types" |
|
29
|
|
|
30
|
/** |
|
31
|
* Depending on whether we are running the CJS or ESM build of the plugin, we |
|
32
|
* need to import the default export of the `@babel/traverse` package in |
|
33
|
* different ways. |
|
34
|
*/ |
|
35
|
let traverse: typeof _traverse |
|
36
|
|
|
37
|
if (typeof _traverse === "function") { |
|
38
|
traverse = _traverse |
|
39
|
} else { |
|
40
|
traverse = (_traverse as any).default |
|
41
|
} |
|
42
|
|
|
43
|
export { |
|
44
|
isArrayExpression, |
|
45
|
isCallExpression, |
|
46
|
isFunctionDeclaration, |
|
47
|
isIdentifier, |
|
48
|
isJSXElement, |
|
49
|
isJSXFragment, |
|
50
|
isMemberExpression, |
|
51
|
isNumericLiteral, |
|
52
|
isObjectExpression, |
|
53
|
isObjectProperty, |
|
54
|
isStringLiteral, |
|
55
|
isTemplateLiteral, |
|
56
|
isVariableDeclaration, |
|
57
|
isVariableDeclarator, |
|
58
|
parse, |
|
59
|
traverse, |
|
60
|
} |
|
61
|
export type { |
|
62
|
ExportDefaultDeclaration, |
|
63
|
ExportNamedDeclaration, |
|
64
|
File, |
|
65
|
Node, |
|
66
|
NodePath, |
|
67
|
ObjectExpression, |
|
68
|
ObjectMethod, |
|
69
|
ObjectProperty, |
|
70
|
ParseResult, |
|
71
|
ParserOptions, |
|
72
|
SpreadElement, |
|
73
|
StringLiteral, |
|
74
|
VariableDeclarator, |
|
75
|
} |