@@ -12,29 +12,29 @@ export function parseDeclaration(code: string): Record<string, string> {
12
12
}
13
13
14
14
export 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
+ ]
15
22
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
30
30
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
+ } )
38
38
. filter ( notNullish ) ,
39
39
)
40
40
@@ -50,7 +50,7 @@ export async function generateDeclaration(ctx: Context, root: string, filepath:
50
50
...imports ,
51
51
} )
52
52
. 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 )
54
54
. map ( ( [ name , v ] ) => {
55
55
if ( ! / ^ \w + $ / . test ( name ) )
56
56
name = `'${ name } '`
0 commit comments