Skip to content

fix(vite): keep HMR after a new source file is created - #4078

Open
Adebesin-Cell wants to merge 1 commit into
chakra-ui:v2from
Adebesin-Cell:fix/vite-hmr-after-new-source
Open

Adebesin-Cell wants to merge 1 commit into
chakra-ui:v2from
Adebesin-Cell:fix/vite-hmr-after-new-source

Conversation

@Adebesin-Cell

Copy link
Copy Markdown
Collaborator

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

  • Each source edit now registers every file again. With 3,000 source files that adds about 3 ms per edit (4.9 ms → 7.8 ms median).
  • Thanks @Zero-1016 for the detailed root cause and the regression test.
  • Test plan:
    • pnpm test packages/vite: 38 passing. The new test fails on v2 with ['update', 'full-reload'].
    • sandbox/vite-ts dev 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

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.
@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
panda-docs-v2 Ready Ready Preview Nov 5, 2026 2:03pm UTC
panda-studio-v2 Ready Ready Preview Nov 5, 2026 2:03pm UTC

Request Review

@vercel

vercel Bot commented Nov 5, 2026

Copy link
Copy Markdown

@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-bot

changeset-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d39500a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 21 packages
Name Type
@pandacss/vite Patch
@pandacss/bun Patch
@pandacss/cli Patch
@pandacss/compiler-shared Patch
@pandacss/compiler-wasm Patch
@pandacss/compiler Patch
@pandacss/config Patch
@pandacss/dev Patch
@pandacss/eslint-plugin Patch
@pandacss/mcp Patch
@pandacss/postcss Patch
@pandacss/preset-base Patch
@pandacss/preset-panda Patch
@pandacss/preset-typography Patch
@pandacss/rollup Patch
@pandacss/transformer Patch
@pandacss/types Patch
@pandacss/webpack Patch
studio Patch
playground Patch
website Patch

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

2 active deployments
Preview – panda-docs-v2 — d39500ac Deployed Nov 5, 2026 by vercel[bot]
Preview – panda-studio-v2 — d39500ac Deployed Nov 5, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[@pandacss/vite] Adding a new source file turns every later edit to existing files into a full page reload (HMR lost until restart)

1 participant