-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-traverse.js
More file actions
30 lines (25 loc) · 816 Bytes
/
debug-traverse.js
File metadata and controls
30 lines (25 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { parse } from '@babel/parser';
import * as traverseModule from '@babel/traverse';
import generate from '@babel/generator';
// Log the traverse module to see what's available
console.log('traverseModule:', traverseModule);
// Try to access the default export
const traverse = traverseModule.default;
console.log('traverse from default:', traverse);
// Try to use the module directly
console.log('Using module directly:', typeof traverseModule === 'function');
// Create a simple AST
const ast = parse('const x = 1;', {
sourceType: 'module',
});
// Try to use traverse
if (typeof traverse === 'function') {
console.log('Using traverse as function');
traverse(ast, {
enter(path) {
console.log('Entered node:', path.type);
},
});
} else {
console.log('traverse is not a function');
}