@@ -50,10 +50,14 @@ export const tanstackViteConfig = (options) => {
5050 module : 99 , // ESNext
5151 declarationMap : false ,
5252 } ,
53- beforeWriteFile : ( filePath , content ) => ( {
54- filePath,
55- content : ensureImportFileExtension ( { content, extension : 'js' } ) ,
56- } ) ,
53+ beforeWriteFile : ( filePath , content ) => {
54+ content =
55+ options . beforeWriteDeclarationFile ?. ( filePath , content ) || content
56+ return {
57+ filePath,
58+ content : ensureImportFileExtension ( { content, extension : 'js' } ) ,
59+ }
60+ } ,
5761 afterDiagnostic : ( diagnostics ) => {
5862 if ( diagnostics . length > 0 ) {
5963 console . error ( 'Please fix the above type errors' )
@@ -72,10 +76,18 @@ export const tanstackViteConfig = (options) => {
7276 module : 1 , // CommonJS
7377 declarationMap : false ,
7478 } ,
75- beforeWriteFile : ( filePath , content ) => ( {
76- filePath : filePath . replace ( '.d.ts' , '.d.cts' ) ,
77- content : ensureImportFileExtension ( { content, extension : 'cjs' } ) ,
78- } ) ,
79+ beforeWriteFile : ( filePath , content ) => {
80+ content =
81+ options . beforeWriteDeclarationFile ?. ( filePath , content ) ||
82+ content
83+ return {
84+ filePath : filePath . replace ( '.d.ts' , '.d.cts' ) ,
85+ content : ensureImportFileExtension ( {
86+ content,
87+ extension : 'cjs' ,
88+ } ) ,
89+ }
90+ } ,
7991 afterDiagnostic : ( diagnostics ) => {
8092 if ( diagnostics . length > 0 ) {
8193 console . error ( 'Please fix the above type errors' )
0 commit comments