From 9cc93a577581820b29fa929e27d49f52b805fd4f Mon Sep 17 00:00:00 2001 From: Dominik G Date: Thu, 20 Apr 2023 21:40:08 +0200 Subject: [PATCH] fix: revert ensure module in graph before transforming (#12774) (#12929) --- packages/vite/src/node/server/transformRequest.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/vite/src/node/server/transformRequest.ts b/packages/vite/src/node/server/transformRequest.ts index 2b74b25b526f06..b08a01e5d01b9e 100644 --- a/packages/vite/src/node/server/transformRequest.ts +++ b/packages/vite/src/node/server/transformRequest.ts @@ -172,11 +172,6 @@ async function loadAndTransform( let code: string | null = null let map: SourceDescription['map'] = null - // Ensure that the module is in the graph before it is loaded and the file is checked. - // This prevents errors from occurring during the load process and interrupting the watching process at its inception. - const mod = await moduleGraph.ensureEntryFromUrl(url, ssr) - ensureWatchedFile(watcher, mod.file, root) - // load const loadStart = debugLoad ? performance.now() : 0 const loadResult = await pluginContainer.load(id, { ssr }) @@ -247,6 +242,9 @@ async function loadAndTransform( err.code = isPublicFile ? ERR_LOAD_PUBLIC_URL : ERR_LOAD_URL throw err } + // ensure module in graph after successful load + const mod = await moduleGraph.ensureEntryFromUrl(url, ssr) + ensureWatchedFile(watcher, mod.file, root) // transform const transformStart = debugTransform ? performance.now() : 0