Skip to content

Commit f1fad1e

Browse files
committed
fix(dts): inconsistent in dev and build
1 parent 13647ed commit f1fad1e

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/core/declaration.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,29 @@ export function parseDeclaration(code: string): Record<string, string> {
1212
}
1313

1414
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+
]
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

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy