@@ -54,35 +54,34 @@ export default defineNuxtModule<ModuleOptions>({
54
54
55
55
// Manually scan `componentsDir` for components and register them for auto imports
56
56
try {
57
- readdirSync ( componentsPath )
58
- . forEach ( async ( dir ) => {
59
- try {
60
- const filePath = await resolvePath ( join ( COMPONENT_DIR_PATH , dir , 'index' ) , { extensions : [ '.ts' , '.js' ] } )
61
- const content = readFileSync ( filePath , { encoding : 'utf8' } )
62
- const ast = parseSync ( filePath , content , {
63
- sourceType : 'module' ,
64
- } )
57
+ await Promise . all ( readdirSync ( componentsPath ) . map ( async ( dir ) => {
58
+ try {
59
+ const filePath = await resolvePath ( join ( COMPONENT_DIR_PATH , dir , 'index' ) , { extensions : [ '.ts' , '.js' ] } )
60
+ const content = readFileSync ( filePath , { encoding : 'utf8' } )
61
+ const ast = parseSync ( filePath , content , {
62
+ sourceType : 'module' ,
63
+ } )
65
64
66
- const exportedKeys : string [ ] = ast . program . body
67
- . filter ( node => node . type === 'ExportNamedDeclaration' )
68
- // @ts -expect-error parse return any
69
- . flatMap ( node => node . specifiers ?. map ( specifier => specifier . exported ?. name ) || [ ] )
70
- . filter ( ( key : string ) => / ^ [ A - Z ] / . test ( key ) )
65
+ const exportedKeys : string [ ] = ast . program . body
66
+ . filter ( node => node . type === 'ExportNamedDeclaration' )
67
+ // @ts -expect-error parse return any
68
+ . flatMap ( node => node . specifiers ?. map ( specifier => specifier . exported ?. name ) || [ ] )
69
+ . filter ( ( key : string ) => / ^ [ A - Z ] / . test ( key ) )
71
70
72
- exportedKeys . forEach ( ( key ) => {
73
- addComponent ( {
74
- name : `${ prefix } ${ key } ` , // name of the component to be used in vue templates
75
- export : key , // (optional) if the component is a named (rather than default) export
76
- filePath : resolve ( filePath ) ,
77
- priority : 1 ,
78
- } )
71
+ exportedKeys . forEach ( ( key ) => {
72
+ addComponent ( {
73
+ name : `${ prefix } ${ key } ` , // name of the component to be used in vue templates
74
+ export : key , // (optional) if the component is a named (rather than default) export
75
+ filePath : resolve ( filePath ) ,
76
+ priority : 1 ,
79
77
} )
80
- }
81
- catch ( err ) {
82
- if ( err instanceof Error )
83
- console . warn ( 'Module error: ' , err . message )
84
- }
85
- } )
78
+ } )
79
+ }
80
+ catch ( err ) {
81
+ if ( err instanceof Error )
82
+ console . warn ( 'Module error: ' , err . message )
83
+ }
84
+ } ) )
86
85
}
87
86
catch ( err ) {
88
87
if ( err instanceof Error )
0 commit comments