File tree 1 file changed +5
-3
lines changed
packages/vite/src/node/server
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,11 @@ async function loadAndTransform(
172
172
let code : string | null = null
173
173
let map : SourceDescription [ 'map' ] = null
174
174
175
+ // Ensure that the module is in the graph before it is loaded and the file is checked.
176
+ // This prevents errors from occurring during the load process and interrupting the watching process at its inception.
177
+ const mod = await moduleGraph . ensureEntryFromUrl ( url , ssr )
178
+ ensureWatchedFile ( watcher , mod . file , root )
179
+
175
180
// load
176
181
const loadStart = debugLoad ? performance . now ( ) : 0
177
182
const loadResult = await pluginContainer . load ( id , { ssr } )
@@ -242,9 +247,6 @@ async function loadAndTransform(
242
247
err . code = isPublicFile ? ERR_LOAD_PUBLIC_URL : ERR_LOAD_URL
243
248
throw err
244
249
}
245
- // ensure module in graph after successful load
246
- const mod = await moduleGraph . ensureEntryFromUrl ( url , ssr )
247
- ensureWatchedFile ( watcher , mod . file , root )
248
250
249
251
// transform
250
252
const transformStart = debugTransform ? performance . now ( ) : 0
You can’t perform that action at this time.
0 commit comments