Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #23527.
When a module file (e.g.
src/dep.ts) is renamed (e.g. tosrc/dep.tsx) or deleted while the dev server is running, any importer statically importing that module (e.g.import { value } from "./dep") was being soft-invalidated instead of hard-invalidated.Because
importer.staticImportedUrls?.has(mod.url)evaluated totrue, Vite soft-invalidated the importer, preserving its cached transformed code with the old resolved URL (/src/dep.ts) and appending an HMR timestamp (/src/dep.ts?t=...). Requesting that stale URL failed with a pre-transform error (Does the file exist?).This PR:
isDeletedinonFileDeleteand ensures they are invalidated in the module graph.!mod.isDeleted). Importers are now hard-invalidated so that their import specifiers are re-transformed and re-resolved against the filesystem.propagateUpdate, ensures deleted modules cannot self-accept or be accepted viaacceptedHmrDeps, propagating to importers and falling back to a full reload.isDeleted = falseon file creation/change or when re-ensuring the entry in the module graph.