Repository navigation
fix(vite): keep HMR after a new source file is created - #4078
Open
Adebesin-Cell wants to merge 1 commit into
Open
Adebesin-Cell wants to merge 1 commit into
Adebesin-Cell wants to merge 1 commit into
Conversation
Vite replaces a CSS file's watch list with the files registered in each pass, so registering only new files cut every other source off and the next edit fell back to a full reload. Register the full list each pass.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@Adebesin-Cell is attempting to deploy a commit to the Chakra UI Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: d39500a The changes in this PR will be included in the next version bump. This PR includes changesets to release 21 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This branch was successfully deployed
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.
Closes #4077
📝 Description
Keeps HMR working after you create a new source file while the Vite dev server runs.
⛳️ Current behavior (updates)
Once you create a new file matched by
include, every later edit to an existing source file triggers a full page reload instead of an HMR update. This lasts until you restart the dev server. The CSS stays correct.The plugin registered each source file with Vite only once. Vite replaces the CSS file's watch list with whatever is registered in each pass, so a pass that only registered the new file cut every other source off. The next edit to one of them had nowhere to go, and Vite reloaded the page.
🚀 New behavior
Every pass registers the full list of source files, so edits keep using HMR after a file is created. Each Vite environment (client and SSR) now gets its own full list too.
💣 Is this a breaking change (Yes/No):
No
📝 Additional Information
pnpm test packages/vite: 38 passing. The new test fails onv2with['update', 'full-reload'].sandbox/vite-tsdev server with the real file watcher: edit, create a file, edit again. It was a full reload before this change and is an HMR update after.tsc --noEmit, eslint, prettier