Skip to content

Commit fdb1e46

Browse files
committed
fix: correctly invalidate browser modules when watcher triggers
1 parent a453637 commit fdb1e46

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/vitest/src/node/core.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -596,11 +596,13 @@ export class Vitest {
596596
const updateLastChanged = (id: string) => {
597597
const projects = this.getModuleProjects(id)
598598
projects.forEach(({ server, browser }) => {
599-
const mods = server.moduleGraph.getModulesByFile(id)
600-
mods?.forEach((mod) => {
601-
server.moduleGraph.invalidateModule(mod)
602-
browser?.moduleGraph.invalidateModule(mod)
603-
})
599+
const serverMods = server.moduleGraph.getModulesByFile(id)
600+
serverMods?.forEach(mod => server.moduleGraph.invalidateModule(mod))
601+
602+
if (browser) {
603+
const browserMods = browser.moduleGraph.getModulesByFile(id)
604+
browserMods?.forEach(mod => browser.moduleGraph.invalidateModule(mod))
605+
}
604606
})
605607
}
606608

0 commit comments

Comments
 (0)