Skip to content

Commit

Permalink
fix(vite): return non-zero exit code for type declaration errors (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlancollins authored Sep 16, 2024
1 parent ba3c6bc commit ab8082b
Show file tree
Hide file tree
Showing 2 changed files with 590 additions and 355 deletions.
20 changes: 15 additions & 5 deletions packages/config/src/vite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ export const tanstackViteConfig = (options) => {
filePath,
content: ensureImportFileExtension({ content, extension: 'js' }),
}),
afterDiagnostic: (diagnostics) => {
if (diagnostics.length > 0) {
console.error('Please fix the above type errors')
process.exit(1)
}
},
}),
dts({
outDir: `${outDir}/cjs`,
Expand All @@ -64,11 +70,15 @@ export const tanstackViteConfig = (options) => {
module: 1, // CommonJS
declarationMap: false,
},
beforeWriteFile: (filePath, content) => {
content = ensureImportFileExtension({ content, extension: 'cjs' })
filePath = filePath.replace('.d.ts', '.d.cts')

return { filePath, content }
beforeWriteFile: (filePath, content) => ({
filePath: filePath.replace('.d.ts', '.d.cts'),
content: ensureImportFileExtension({ content, extension: 'cjs' }),
}),
afterDiagnostic: (diagnostics) => {
if (diagnostics.length > 0) {
console.error('Please fix the above type errors')
process.exit(1)
}
},
}),
],
Expand Down
Loading

0 comments on commit ab8082b

Please sign in to comment.