@@ -12,29 +12,29 @@ export function parseDeclaration(code: string): Record<string, string> {
1212}
1313
1414export async function generateDeclaration ( ctx : Context , root : string , filepath : string , removeUnused = false ) : Promise < void > {
15+ const items = [
16+ ...Object . values ( {
17+ ...ctx . componentNameMap ,
18+ ...ctx . componentCustomMap ,
19+ } ) ,
20+ ...resolveTypeImports ( ctx . options . types ) ,
21+ ]
1522 const imports : Record < string , string > = Object . fromEntries (
16- [
17- ...Object . values ( {
18- ...ctx . componentNameMap ,
19- ...ctx . componentCustomMap ,
20- } ) ,
21- ...resolveTypeImports ( ctx . options . types ) ,
22- ]
23- . map ( ( { from : path , as : name , name : importName } ) => {
24- if ( ! name )
25- return undefined
26- path = getTransformedPath ( path , ctx )
27- const related = isAbsolute ( path )
28- ? `./${ relative ( dirname ( filepath ) , path ) } `
29- : path
23+ items . map ( ( { from : path , as : name , name : importName } ) => {
24+ if ( ! name )
25+ return undefined
26+ path = getTransformedPath ( path , ctx )
27+ const related = isAbsolute ( path )
28+ ? `./${ relative ( dirname ( filepath ) , path ) } `
29+ : path
3030
31- let entry = `typeof import('${ slash ( related ) } ')`
32- if ( importName )
33- entry += `['${ importName } ']`
34- else
35- entry += '[\'default\']'
36- return [ name , entry ]
37- } )
31+ let entry = `typeof import('${ slash ( related ) } ')`
32+ if ( importName )
33+ entry += `['${ importName } ']`
34+ else
35+ entry += '[\'default\']'
36+ return [ name , entry ]
37+ } )
3838 . filter ( notNullish ) ,
3939 )
4040
@@ -50,7 +50,7 @@ export async function generateDeclaration(ctx: Context, root: string, filepath:
5050 ...imports ,
5151 } )
5252 . sort ( ( a , b ) => a [ 0 ] . localeCompare ( b [ 0 ] ) )
53- . filter ( ( [ name ] ) => removeUnused ? ctx . componentCustomMap [ name ] || ctx . componentNameMap [ name ] : true )
53+ . filter ( ( [ name ] ) => removeUnused ? items . find ( i => i . as === name ) : true )
5454 . map ( ( [ name , v ] ) => {
5555 if ( ! / ^ \w + $ / . test ( name ) )
5656 name = `'${ name } '`
0 commit comments