-
-
Notifications
You must be signed in to change notification settings - Fork 160
Expand file tree
/
Copy pathtsdown.config.ts
More file actions
33 lines (31 loc) · 955 Bytes
/
tsdown.config.ts
File metadata and controls
33 lines (31 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import * as fsPromises from 'node:fs/promises'
import { defineConfig } from 'tsdown'
export default defineConfig({
entry: ['src/*.ts'],
dts: true,
external: ['vue', 'vite', 'rollup', '@iconify/json/package.json'],
inlineOnly: ['@antfu/utils'],
exports: {
async customExports(exp) {
// replace this for await with `import { glob } from 'node:fs/promises'
// requires node v22.14.0+ => https://nodejs.org/api/fs.html
for await (const [key, types] of getDtsTypesFiles()) {
if (!exp[key]) {
exp[key] = { types }
}
}
return exp
},
},
})
async function* getDtsTypesFiles(): AsyncGenerator<[
key: string,
types: string,
], undefined, void> {
const files = await fsPromises.readdir('./types/')
for (const file of files) {
if (file.endsWith('.d.ts') && file !== 'index.d.ts') {
yield [`./types/${file.replace(/\.d\.ts$/, '')}`, `./types/${file}`] as const
}
}
}