Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revert ensure module in graph before transforming (#12774) #12929

Merged
merged 1 commit into from Apr 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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