-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Astro style HMR for imported styles #10166
Conversation
🦋 Changeset detectedLatest commit: 1848080 The changes in this PR will be included in the next version bump. 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 |
@ematipico I added some comments since your last review explaining some things better. Appreciate if you can take another look! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding more context to how hmr internally works!
Changes
Fixes #9262
This PR removes some hacks needed before Vite 5.1. Now with Vite 5.1, we can register style dependencies directly to the Astro style virtual module instead, e.g.
/src/pages/index.astro?astro&type=style&index=0&lang.css
. We can more better prevent circular deps that caused vitejs/vite#15585 and some tailwind issues.The result is that CSS HMR should be more granular and simpler, but in this PR I had to leverage
astroFileToCompileMetadata
still in HMR to invalidate the metadata correctly, so that the Astro style virtual module can re-compile the new CSS.Testing
Added a new test and made sure HMR don't refresh for styles.
Docs
m/a. bug fix.