Skip to content

Commit b6bcf72

Browse files
brenelzclaude
andcommitted
fix(vite): clear module runner cache before dev worker reload
The dev worker's ViteEnvRunner.reload() re-imports the environment entry without clearing the ModuleRunner's evaluatedModules cache. When a module's transform is already populated on the Vite side at fetch time (for example re-transformed by an assets crawl during the reload itself), fetchModule answers {cache: true} and the runner reuses the stale evaluation, so the server keeps executing old code until the dev server is restarted. Vite's own full-reload handler clears evaluatedModules before re-importing; do the same here. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 77b77ff commit b6bcf72

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/runtime/internal/vite/dev-worker.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ class ViteEnvRunner {
5555

5656
async reload() {
5757
try {
58+
// Drop stale evaluations so the re-import walks the whole graph.
59+
// Without this, any module whose transform is already populated on the
60+
// Vite side is answered with `{cache: true}` and its old evaluation is
61+
// reused. Vite's own full-reload handler clears the cache the same way.
62+
this.runner.evaluatedModules.clear();
5863
this.entry = await this.runner.import(this.entryPath);
5964
this.entryError = undefined;
6065
} catch (error) {

0 commit comments

Comments
 (0)