Skip to content

Commit 05f0dcd

Browse files
author
spark
committed
fix(unplugin-dts): resolve tsconfig globs relative to tsconfig dir
TypeScript resolves include/exclude/files patterns relative to the tsconfig file location, but unplugin-dts passes them to createFilter() which resolves globs relative to plugin root. When tsconfig is not in the project root, this mismatch can exclude valid sources and break dts generation. Convert tsconfig globs to root-relative patterns before creating the filter. Update vue-vite example to use a solution tsconfig with references.
1 parent 1070f46 commit 05f0dcd

File tree

4 files changed

+145
-124
lines changed

4 files changed

+145
-124
lines changed

examples/vue-vite/tsconfig.json

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,7 @@
11
{
22
// test comment
3-
"compilerOptions": {
4-
"target": "esnext",
5-
"module": "esnext",
6-
"moduleResolution": "node",
7-
"importHelpers": true,
8-
"outDir": "dist",
9-
"strict": true,
10-
"jsx": "preserve",
11-
"jsxImportSource": "vue",
12-
"allowJs": true,
13-
"sourceMap": true,
14-
"resolveJsonModule": true,
15-
"esModuleInterop": true,
16-
"skipLibCheck": true,
17-
"experimentalDecorators": true,
18-
"types": [
19-
"node",
20-
"vite/client"
21-
],
22-
"baseUrl": ".",
23-
"paths": {
24-
"@/*": ["./*"],
25-
"@components/*": ["./src/components/*"],
26-
"$alias/*": ["./alias/*"]
27-
},
28-
"lib": ["esnext", "dom"]
29-
},
30-
"include": ["src", "components", "alias", "*.d.ts"]
3+
"files": [],
4+
"references": [
5+
{ "path": "./tsconfig/tsconfig.app.json" }
6+
]
317
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"compilerOptions": {
3+
"target": "esnext",
4+
"module": "esnext",
5+
"moduleResolution": "node",
6+
"importHelpers": true,
7+
"outDir": "dist",
8+
"strict": true,
9+
"jsx": "preserve",
10+
"jsxImportSource": "vue",
11+
"allowJs": true,
12+
"sourceMap": true,
13+
"resolveJsonModule": true,
14+
"esModuleInterop": true,
15+
"skipLibCheck": true,
16+
"experimentalDecorators": true,
17+
"types": [
18+
"node",
19+
"vite/client"
20+
],
21+
"baseUrl": "..",
22+
"paths": {
23+
"@/*": ["./*"],
24+
"@components/*": ["./src/components/*"],
25+
"$alias/*": ["./alias/*"]
26+
},
27+
"lib": ["esnext", "dom"]
28+
},
29+
"include": ["../src", "../components", "../alias", "../*.d.ts"]
30+
}

examples/vue-vite/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export default defineConfig({
3434
plugins: [
3535
// @ts-ignore
3636
dts({
37+
tsconfigPath: resolve('./tsconfig/tsconfig.app.json'),
3738
processor: 'vue',
3839
copyDtsFiles: true,
3940
outDirs: [

0 commit comments

Comments
 (0)