@@ -119,11 +119,11 @@ export class ViteNodeServer {
119119 return this . fetchPromiseMap . get ( id ) !
120120 }
121121
122- async transformRequest ( id : string ) {
122+ async transformRequest ( id : string , filepath = id ) {
123123 // reuse transform for concurrent requests
124124 if ( ! this . transformPromiseMap . has ( id ) ) {
125125 this . transformPromiseMap . set ( id ,
126- this . _transformRequest ( id )
126+ this . _transformRequest ( id , filepath )
127127 . finally ( ( ) => {
128128 this . transformPromiseMap . delete ( id )
129129 } ) ,
@@ -177,7 +177,7 @@ export class ViteNodeServer {
177177 }
178178 else {
179179 const start = performance . now ( )
180- const r = await this . _transformRequest ( id , transformMode )
180+ const r = await this . _transformRequest ( id , filePath , transformMode )
181181 duration = performance . now ( ) - start
182182 result = { code : r ?. code , map : r ?. map as any }
183183 }
@@ -191,15 +191,15 @@ export class ViteNodeServer {
191191 return result
192192 }
193193
194- protected async processTransformResult ( id : string , result : TransformResult ) {
195- const mod = this . server . moduleGraph . getModuleById ( id )
194+ protected async processTransformResult ( filepath : string , result : TransformResult ) {
195+ const mod = this . server . moduleGraph . getModuleById ( filepath )
196196 return withInlineSourcemap ( result , {
197- filepath : mod ?. file || id ,
197+ filepath : mod ?. file || filepath ,
198198 root : this . server . config . root ,
199199 } )
200200 }
201201
202- private async _transformRequest ( id : string , customTransformMode ?: 'web' | 'ssr' ) {
202+ private async _transformRequest ( id : string , filepath : string , customTransformMode ?: 'web' | 'ssr' ) {
203203 debugRequest ( id )
204204
205205 let result : TransformResult | null = null
@@ -225,7 +225,7 @@ export class ViteNodeServer {
225225
226226 const sourcemap = this . options . sourcemap ?? 'inline'
227227 if ( sourcemap === 'inline' && result && ! id . includes ( 'node_modules' ) )
228- result = await this . processTransformResult ( id , result )
228+ result = await this . processTransformResult ( filepath , result )
229229
230230 if ( this . options . debug ?. dumpModules )
231231 await this . debugger ?. dumpFile ( id , result )
0 commit comments