Skip to content

Commit 9cc93a5

Browse files
authoredApr 20, 2023
fix: revert ensure module in graph before transforming (#12774) (#12929)
1 parent 6a14463 commit 9cc93a5

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed
 

‎packages/vite/src/node/server/transformRequest.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,6 @@ async function loadAndTransform(
172172
let code: string | null = null
173173
let map: SourceDescription['map'] = null
174174

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-
180175
// load
181176
const loadStart = debugLoad ? performance.now() : 0
182177
const loadResult = await pluginContainer.load(id, { ssr })
@@ -247,6 +242,9 @@ async function loadAndTransform(
247242
err.code = isPublicFile ? ERR_LOAD_PUBLIC_URL : ERR_LOAD_URL
248243
throw err
249244
}
245+
// ensure module in graph after successful load
246+
const mod = await moduleGraph.ensureEntryFromUrl(url, ssr)
247+
ensureWatchedFile(watcher, mod.file, root)
250248

251249
// transform
252250
const transformStart = debugTransform ? performance.now() : 0

0 commit comments

Comments
 (0)
Please sign in to comment.