Skip to content

Commit ab8082b

Browse files
fix(vite): return non-zero exit code for type declaration errors (#163)
1 parent ba3c6bc commit ab8082b

File tree

2 files changed

+590
-355
lines changed

2 files changed

+590
-355
lines changed

packages/config/src/vite/index.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ export const tanstackViteConfig = (options) => {
5353
filePath,
5454
content: ensureImportFileExtension({ content, extension: 'js' }),
5555
}),
56+
afterDiagnostic: (diagnostics) => {
57+
if (diagnostics.length > 0) {
58+
console.error('Please fix the above type errors')
59+
process.exit(1)
60+
}
61+
},
5662
}),
5763
dts({
5864
outDir: `${outDir}/cjs`,
@@ -64,11 +70,15 @@ export const tanstackViteConfig = (options) => {
6470
module: 1, // CommonJS
6571
declarationMap: false,
6672
},
67-
beforeWriteFile: (filePath, content) => {
68-
content = ensureImportFileExtension({ content, extension: 'cjs' })
69-
filePath = filePath.replace('.d.ts', '.d.cts')
70-
71-
return { filePath, content }
73+
beforeWriteFile: (filePath, content) => ({
74+
filePath: filePath.replace('.d.ts', '.d.cts'),
75+
content: ensureImportFileExtension({ content, extension: 'cjs' }),
76+
}),
77+
afterDiagnostic: (diagnostics) => {
78+
if (diagnostics.length > 0) {
79+
console.error('Please fix the above type errors')
80+
process.exit(1)
81+
}
7282
},
7383
}),
7484
],

0 commit comments

Comments
 (0)