@@ -65,7 +65,7 @@ function resolveComponentDependencies(
6565 * Detect components used in the project by scanning source files
6666 */
6767export async function detectUsedComponents (
68- rootDir : string ,
68+ dirs : string [ ] ,
6969 prefix : string ,
7070 componentDir : string ,
7171 includeComponents ?: string [ ]
@@ -79,33 +79,35 @@ export async function detectUsedComponents(
7979 }
8080 }
8181
82- // Scan all source files for component usage
83- const appFiles = globSync ( [ '**/*.{vue,ts,js,tsx,jsx}' ] , {
84- cwd : rootDir ,
85- ignore : [ 'node_modules/**' , '.nuxt/**' , 'dist/**' ]
86- } )
87-
8882 // Pattern to match:
8983 // - <UButton in templates
9084 // - UButton in script (imports, usage)
9185 // - <LazyUButton (lazy components)
9286 // - LazyUButton in script
9387 const componentPattern = new RegExp ( `<(?:Lazy)?${ prefix } ([A-Z][a-zA-Z]+)|\\b(?:Lazy)?${ prefix } ([A-Z][a-zA-Z]+)\\b` , 'g' )
9488
95- for ( const file of appFiles ) {
96- try {
97- const filePath = join ( rootDir , file )
98- const content = await readFile ( filePath , 'utf-8' )
99- const matches = content . matchAll ( componentPattern )
100-
101- for ( const match of matches ) {
102- const componentName = match [ 1 ] || match [ 2 ]
103- if ( componentName ) {
104- detectedComponents . add ( componentName )
89+ // Scan all source files for component usage across all layers
90+ for ( const dir of dirs ) {
91+ const appFiles = globSync ( [ '**/*.{vue,ts,js,tsx,jsx}' ] , {
92+ cwd : dir ,
93+ ignore : [ 'node_modules/**' , '.nuxt/**' , 'dist/**' ]
94+ } )
95+
96+ for ( const file of appFiles ) {
97+ try {
98+ const filePath = join ( dir , file )
99+ const content = await readFile ( filePath , 'utf-8' )
100+ const matches = content . matchAll ( componentPattern )
101+
102+ for ( const match of matches ) {
103+ const componentName = match [ 1 ] || match [ 2 ]
104+ if ( componentName ) {
105+ detectedComponents . add ( componentName )
106+ }
105107 }
108+ } catch {
109+ // Ignore files that can't be read
106110 }
107- } catch {
108- // Ignore files that can't be read
109111 }
110112 }
111113
0 commit comments