-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Refactor style-only HMR cache and performance #9712
Conversation
🦋 Changeset detectedLatest commit: cace49b 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 |
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.
Very clean refactor! Big fan of this approach and reducing the complexity of our previous caching system.
Co-authored-by: Nate Moore <[email protected]>
Changes
Supersedes and closes #9356
This PR changes how we detect if only the styles are changed in an Astro file, so we can only apply HMR on those styles. In contrary to #9356, this uses regexes to perform the comparisons, which is technically a bit brittle, but I think covers a fair amount of cases enough that it's worth the perf gain.
It also simplifies our caching, so it's less about caching but more of recording additional metadata from the compilation result. This way we use lesser data and memory, and avoid unintentional invalidation causing scripts and styles virtual modules to fail.
@natemoo-re Would love your thoughts on the regex approach for style-change detection. I'm happy to refactor that to something else if anyone doesn't feel comfortable about it 😄
Testing
The existing tests should pass as it's a refactor.
Docs
n/a. internal refactor.