Skip to content

fix(vite): encode virtual IDs in global HMR updates - #5298

Merged
zyyv merged 1 commit into
mainfrom
codex/fix-vite-lazy-module-hmr
Sep 1, 2026
Merged

zyyv merged 1 commit into
mainfrom
codex/fix-vite-lazy-module-hmr

Conversation

@zyyv

@zyyv zyyv commented Sep 1, 2026

Copy link
Copy Markdown
Member

Description

Global mode stores UnoCSS entries as Vite internal virtual module IDs after #5284, but its HMR payload still sent the internal \0-prefixed URL directly to the browser.

Keep the internal ID for moduleGraph.getModuleById() and invalidation, then encode null-byte IDs as Vite's public /@id/__x00__/... client path when sending the HMR update. Normal module URLs are preserved.

This is a follow-up to #5284.

Fixes #5293

Validation

  • vitest run test/virtual-modules.test.ts
  • ESLint on the changed files
  • tsgo --noEmit
  • Manual Vite 8.2.2 browser reproduction with a dynamically imported TSX module; utilities applied without a page reload

@zyyv
zyyv requested a review from antfu as a code owner September 1, 2026 08:53
@netlify

netlify Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for unocss ready!

Name Link
🔨 Latest commit cae7da2
🔍 Latest deploy log https://app.netlify.com/projects/unocss/deploys/6a9692a1ad27f400080f88ef
😎 Deploy Preview https://deploy-preview-5298--unocss.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Sep 1, 2026

Copy link
Copy Markdown

Open in StackBlitz

commit: cae7da2

@zyyv
zyyv merged commit 199c1ba into main Sep 1, 2026
12 checks passed
@zyyv
zyyv deleted the codex/fix-vite-lazy-module-hmr branch September 1, 2026 10:23
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.

[vite] Global CSS HMR misses utilities discovered in lazy modules in 66.9.1

1 participant

Sponsor
SponsoredKunjungi sekarang
Promo