@@ -213,19 +213,15 @@ export const IsolatedDecl: UnpluginInstance<Options | undefined, false> =
213213 const { inputBase, entryMap } = resolveEntry ( input , options . inputBase )
214214 debug ( '[rollup] input base:' , inputBase )
215215
216- let { entryFileNames = '[name].js' , dir : outDir } = outputOptions
216+ const { entryFileNames = '[name].js' , dir : outDir } = outputOptions
217217 if ( typeof entryFileNames !== 'string' ) {
218218 return this . error ( 'entryFileNames must be a string' )
219219 }
220220
221- if ( options . extraOutdir ) {
222- entryFileNames = path . join ( options . extraOutdir , entryFileNames )
223- }
224-
225221 for ( const [ srcFilename , { s, imports, map, ext } ] of Object . entries (
226222 outputFiles ,
227223 ) ) {
228- const emitName = rewriteImports (
224+ let emitName = rewriteImports (
229225 s ,
230226 options ,
231227 imports ,
@@ -240,6 +236,9 @@ export const IsolatedDecl: UnpluginInstance<Options | undefined, false> =
240236 source = patchCjsDefaultExport ( source )
241237 }
242238
239+ if ( options . extraOutdir ) {
240+ emitName = path . join ( options . extraOutdir || '' , emitName )
241+ }
243242 debug ( '[rollup] emit dts file:' , emitName )
244243 if ( options . sourceMap && map && outDir ) {
245244 source = appendMapUrl ( source , emitName )
@@ -288,14 +287,11 @@ export const IsolatedDecl: UnpluginInstance<Options | undefined, false> =
288287 extFormatMap . get ( output . format || 'esm' ) || 'js' ,
289288 )
290289
291- let entryFileNames = output . entryFilename
292- if ( options . extraOutdir ) {
293- entryFileNames = path . join ( options . extraOutdir , entryFileNames )
294- }
290+ const entryFileNames = output . entryFilename
295291 for ( const [ srcFilename , { s, imports, map, ext } ] of Object . entries (
296292 outputFiles ,
297293 ) ) {
298- const emitName = rewriteImports (
294+ let emitName = rewriteImports (
299295 s ,
300296 options ,
301297 imports ,
@@ -310,6 +306,10 @@ export const IsolatedDecl: UnpluginInstance<Options | undefined, false> =
310306 source = patchCjsDefaultExport ( source )
311307 }
312308
309+ if ( options . extraOutdir ) {
310+ emitName = path . join ( options . extraOutdir || '' , emitName )
311+ }
312+
313313 debug ( '[farm] emit dts file:' , emitName )
314314 const outDir = output . path
315315 if ( options . sourceMap && map && outDir ) {
0 commit comments