Skip to content

Commit 2a8edcd

Browse files
committed
fix(dts): only remove unused dts on build
1 parent 40fb687 commit 2a8edcd

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/core/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export class Context {
252252
return
253253

254254
debug.decleration('generating')
255-
generateDeclaration(this, this.options.root, this.options.dts)
255+
generateDeclaration(this, this.options.root, this.options.dts, !this._server)
256256
}
257257

258258
get componentNameMap() {

src/core/declaration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function parseDeclaration(code: string): Record<string, string> {
1010
return Object.fromEntries(Array.from(code.matchAll(/(?<!\/\/)\s+\s+['"]?(.+?)['"]?:\s(.+?)\n/g)).map(i => [i[1], i[2]]))
1111
}
1212

13-
export async function generateDeclaration(ctx: Context, root: string, filepath: string) {
13+
export async function generateDeclaration(ctx: Context, root: string, filepath: string, removeUnused = false): Promise<void> {
1414
const imports: Record<string, string> = Object.fromEntries(
1515
Object.values({
1616
...ctx.componentNameMap,
@@ -46,7 +46,7 @@ export async function generateDeclaration(ctx: Context, root: string, filepath:
4646
...imports,
4747
})
4848
.sort((a, b) => a[0].localeCompare(b[0]))
49-
.filter(([name]) => ctx.componentCustomMap[name] || ctx.componentNameMap[name])
49+
.filter(([name]) => removeUnused ? ctx.componentCustomMap[name] || ctx.componentNameMap[name] : true)
5050
.map(([name, v]) => {
5151
if (!/^\w+$/.test(name))
5252
name = `'${name}'`

0 commit comments

Comments
 (0)