Fix style crawling logic for CSS HMR #7565
Merged
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.
Changes
Fix #7529
Used the not-so-performant technique initially used in the first commit of #7381 to fix the issue for now.
The issue seems to be that UnoCSS is invalidating the Astro files at https://github.com/unocss/unocss/blob/757b7f18b060f32387689545c878aea1e63203b4/packages/vite/src/modes/global/dev.ts#L59. This breaks our expectations where they are already loaded and exist as
ssrTransformResult
. The invalidation clears outssrTransformResult
, causing the issue.A fix I intially thought is to force
loader.import()
on all modules while we're traversing the graph to counteract UnoCSS, but that feels more non-performant than the initial PR idea, so I went with the initial PR idea instead.Testing
Existing tests should pass. Also tested the repro locally. Unfortunately time is a bit tight for me now to add a real test with unocss.
Docs
n/a.