Skip to content

Commit

Permalink
fix: revert ensure module in graph before transforming (#12774) (#12929)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikg committed Apr 20, 2023
1 parent 6a14463 commit 9cc93a5
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/vite/src/node/server/transformRequest.ts
Expand Up @@ -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 })
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9cc93a5

Please sign in to comment.