@@ -17,6 +17,7 @@ import {
17
17
} from '../utils'
18
18
import { checkPublicFile } from '../plugins/asset'
19
19
import { ssrTransform } from '../ssr/ssrTransform'
20
+ import { getDepsOptimizer } from '../optimizer'
20
21
import { injectSourcesContent } from './sourcemap'
21
22
import { isFileServingAllowed } from './middlewares/static'
22
23
@@ -118,9 +119,8 @@ async function doTransform(
118
119
) {
119
120
url = removeTimestampQuery ( url )
120
121
121
- const { config, pluginContainer, moduleGraph, watcher } = server
122
- const { root, logger } = config
123
- const prettyUrl = isDebug ? prettifyUrl ( url , root ) : ''
122
+ const { config, pluginContainer } = server
123
+ const prettyUrl = isDebug ? prettifyUrl ( url , config . root ) : ''
124
124
const ssr = ! ! options . ssr
125
125
126
126
const module = await server . moduleGraph . getModuleByUrl ( url , ssr )
@@ -142,6 +142,29 @@ async function doTransform(
142
142
// resolve
143
143
const id =
144
144
( await pluginContainer . resolveId ( url , undefined , { ssr } ) ) ?. id || url
145
+
146
+ const result = loadAndTransform ( id , url , server , options , timestamp )
147
+
148
+ const depsOptimizer = getDepsOptimizer ( config )
149
+ if ( depsOptimizer && ! config . legacy ?. devDepsScanner ) {
150
+ depsOptimizer . delayDepsOptimizerUntil ( id , ( ) => result )
151
+ }
152
+
153
+ return result
154
+ }
155
+
156
+ async function loadAndTransform (
157
+ id : string ,
158
+ url : string ,
159
+ server : ViteDevServer ,
160
+ options : TransformOptions ,
161
+ timestamp : number
162
+ ) {
163
+ const { config, pluginContainer, moduleGraph, watcher } = server
164
+ const { root, logger } = config
165
+ const prettyUrl = isDebug ? prettifyUrl ( url , config . root ) : ''
166
+ const ssr = ! ! options . ssr
167
+
145
168
const file = cleanUrl ( id )
146
169
147
170
let code : string | null = null
0 commit comments