Skip to content

Commit

Permalink
fix: invalidate import globs upon new/removed files (fix vitejs#3499)
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed May 20, 2021
1 parent 06b9935 commit 5511107
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/vite/src/node/server/hmr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ export async function handleFileAddUnlink(
const relative = path.relative(base, file)
if (match(relative, pattern)) {
modules.push(module)
// We use `onFileChange` to invalidate `module.file` so that subsequent `ssrLoadModule()`
// calls get fresh glob import results with(out) the newly added(/removed) `file`.
server.moduleGraph.onFileChange(module.file!)
}
}
}
Expand Down

0 comments on commit 5511107

Please sign in to comment.