@@ -35,7 +35,7 @@ const loadDependencies = (c, withNestedDependencies, recursionDepth) => {
35
35
const importNodes = parse ( fileContent , { range : true } ) . body
36
36
. filter ( n => ( n . type === 'ExportDefaultDeclaration' || n . type === 'ExportNamedDeclaration' ) && n . declaration ?. decorators ) ?. flatMap ( n => n
37
37
. declaration . decorators . filter ( d => d . expression . callee ?. name === 'Component' ) ?. [ 0 ]
38
- ?. expression . arguments [ 0 ] . properties . filter ( n => n . key . name === 'imports' ) ?. [ 0 ]
38
+ ?. expression . arguments [ 0 ] . properties . filter ( n => n . key . name === 'imports' || n . key . name === 'hostDirectives' ) ?. [ 0 ]
39
39
?. value . elements ) ;
40
40
41
41
// ToDo: add tests for this
@@ -45,16 +45,29 @@ const loadDependencies = (c, withNestedDependencies, recursionDepth) => {
45
45
return [ c , ...components ] ;
46
46
}
47
47
48
- const identifierNodes = importNodes . filter ( n => n ?. type === 'Identifier' ) ;
48
+ // Extract both direct identifiers and hostDirective property expressions
49
+ const identifierNodes = importNodes . filter ( n =>
50
+ n ?. type === 'Identifier' ||
51
+ ( n ?. type === 'ObjectExpression' && n . properties . some ( p => p . key . name === 'directive' ) )
52
+ ) ;
49
53
50
54
if ( identifierNodes ?. length ) {
51
55
try {
52
- const importsContent = identifierNodes . map ( e => e . name ) ;
56
+ // Extract component names from both regular imports and hostDirectives
57
+ const importsContent = identifierNodes . map ( e => {
58
+ if ( e . type === 'Identifier' ) {
59
+ return e . name ;
60
+ } else if ( e . type === 'ObjectExpression' ) {
61
+ const directiveProp = e . properties . find ( p => p . key . name === 'directive' ) ;
62
+ return directiveProp ?. value ?. name ;
63
+ }
64
+ return null ;
65
+ } ) . filter ( Boolean ) ;
53
66
54
67
importsContent . forEach ( componentName => {
55
68
const comp = handleComponent ( componentName , fileContent , c . componentName , path . relative ( cwd , p ) ) ;
56
69
if ( comp ) {
57
- components . push ( comp )
70
+ components . push ( comp ) ;
58
71
}
59
72
} ) ;
60
73
0 commit comments