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: rebuilds don't happen in watch mode after the first rebuild throws an error during the load function #11605

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 6 additions & 3 deletions packages/vite/src/node/server/transformRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,14 @@ 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 = isDebug ? performance.now() : 0

const loadResult = await pluginContainer.load(id, { ssr })
if (loadResult == null) {
// if this is an html request and there is no load result, skip ahead to
Expand Down Expand Up @@ -233,9 +239,6 @@ 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 = isDebug ? performance.now() : 0
Expand Down