@@ -3,7 +3,7 @@ import path from 'node:path'
3
3
import { performance } from 'node:perf_hooks'
4
4
import getEtag from 'etag'
5
5
import convertSourceMap from 'convert-source-map'
6
- import type { SourceDescription , SourceMap } from 'rollup'
6
+ import type { PartialResolvedId , SourceDescription , SourceMap } from 'rollup'
7
7
import colors from 'picocolors'
8
8
import type { ModuleNode , ViteDevServer } from '..'
9
9
import {
@@ -141,13 +141,22 @@ async function doTransform(
141
141
return cached
142
142
}
143
143
144
+ const resolved = module
145
+ ? undefined
146
+ : ( await pluginContainer . resolveId ( url , undefined , { ssr } ) ) ?? undefined
147
+
144
148
// resolve
145
- const id =
146
- module ?. id ??
147
- ( await pluginContainer . resolveId ( url , undefined , { ssr } ) ) ?. id ??
148
- url
149
+ const id = module ?. id ?? resolved ?. id ?? url
149
150
150
- const result = loadAndTransform ( id , url , server , options , timestamp )
151
+ const result = loadAndTransform (
152
+ id ,
153
+ url ,
154
+ server ,
155
+ options ,
156
+ timestamp ,
157
+ module ,
158
+ resolved ,
159
+ )
151
160
152
161
getDepsOptimizer ( config , ssr ) ?. delayDepsOptimizerUntil ( id , ( ) => result )
153
162
@@ -160,6 +169,8 @@ async function loadAndTransform(
160
169
server : ViteDevServer ,
161
170
options : TransformOptions ,
162
171
timestamp : number ,
172
+ mod ?: ModuleNode ,
173
+ resolved ?: PartialResolvedId ,
163
174
) {
164
175
const { config, pluginContainer, moduleGraph, watcher } = server
165
176
const { root, logger } = config
@@ -243,7 +254,7 @@ async function loadAndTransform(
243
254
throw err
244
255
}
245
256
// ensure module in graph after successful load
246
- const mod = await moduleGraph . ensureEntryFromUrl ( url , ssr )
257
+ mod ?? = await moduleGraph . _ensureEntryFromUrl ( url , ssr , undefined , resolved )
247
258
ensureWatchedFile ( watcher , mod . file , root )
248
259
249
260
// transform
0 commit comments