fix(qwik-router): hot-reload CSS imported by route files#8725
Open
briancarbone wants to merge 1 commit into
Open
fix(qwik-router): hot-reload CSS imported by route files#8725briancarbone wants to merge 1 commit into
briancarbone wants to merge 1 commit into
Conversation
CSS imported by route files (index/layout) is resolved by Qwik and injected as a <link>, so it only lives in the SSR module graph. Vite watches its own client graph plus the route source-file globs, never this CSS, so edits produced no HMR event and styles stayed stale until a dev server restart. CSS imported by client-loaded components was unaffected because Vite handles those natively. Register the injected CSS files with the watcher and, on change, emit a css-update so Vite's client swaps the <link> in place. CSS already in the client graph is left to Vite's native HMR.
🦋 Changeset detectedLatest commit: 73a6b5d The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 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 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.
What is it?
Description
In dev, editing CSS imported by a route file (index.tsx / layout.tsx) had no effect. The dev server had to be restarted to see the change. CSS imported by a component updated instantly, as expected.
Qwik resolves these route CSS imports itself and injects them as tags, so the module only exists in the SSR module graph. Vite watches its own client module graph plus the route source-file globs, so it never watched these files, and a change fired no HMR event at all. Component CSS worked because Vite tracks and handles it natively.
The fix:
Scoped to route-injected CSS in dev mode. Production builds and component CSS are unaffected.
Checklist
Fixes #8724