@@ -20,6 +20,8 @@ async function grabFile() {
2020 // console.log('ast', ast);
2121 const result = await traverseAST ( ast ) ;
2222 console . log ( 'res' , result ) ;
23+ // const tokens = ast.tokens;
24+ // console.log('tokens are:', tokens);
2325 } catch ( error ) {
2426 console . error ( `Error processing file: ${ error } ` )
2527 }
@@ -31,15 +33,16 @@ const processedNodes = new Set();
3133// traverse the ast nodes, passing in node
3234async function traverseAST ( node ) {
3335 // identify which are jsx elements type and then extract info about them (like the component name) and store it in var
34- if ( node . type === 'JSXElement ' && ! processedNodes . has ( node ) ) {
36+ if ( node . type === 'ImportDeclaration ' && ! processedNodes . has ( node ) ) {
3537 processedNodes . add ( node ) ;
3638 // console.log('JSX Node', node);
3739
3840 // im guessing that jsx elements will never contain the use client or hook declaration, so i wouldnt need to call the functions here
3941
4042 // property on node to obtain component name (could be tag or component name)
41- const elementName = node . openingElement . name . name ;
42- // console.log('JSX Name', elementName);
43+ const elementName = node . source . value ;
44+ if ( elementName . startsWith ( './' ) || elementName . startsWith ( '../' ) ) console . log ( 'file path:' , elementName ) ;
45+
4346
4447 if ( node . children ) {
4548 // if node children exist, then recursively call the child nodes with this func
@@ -51,8 +54,8 @@ async function traverseAST(node) {
5154 processedNodes . add ( node ) ;
5255
5356 // call the function to determine if it is a client component and store it in var
54- const isClientComp = await checkForClientString ( node ) ;
55- const isReactHook = await checkReactHooks ( node ) ;
57+ // const isClientComp = await checkForClientString(node);
58+ // const isReactHook = await checkReactHooks(node);
5659
5760 // recursively iterate through the other non-jsx types if the jsx node children doesnt exist
5861 for ( const key in node ) {
0 commit comments