Skip to content
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

Simplify HMR for circular imports and CSS #9706

Merged
merged 3 commits into from
Jan 17, 2024
Merged

Simplify HMR for circular imports and CSS #9706

merged 3 commits into from
Jan 17, 2024

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Jan 16, 2024

Changes

This PR removes a good portion of the HMR code with an approach that lets Vite invalidates the modules accordingly instead. The highlights are:

  1. Simplify handleHotUpdate. It now only does two things: "check style-only updates" and "handle circular dep edge case" (latter can be removed in the future)
  2. Simplify Astro compilation caching and invalidation.
  3. Remove redundant import.meta.hot.decline() calls. They don't work in Vite.

Testing

Added a test from #9370

While this should fix it #9370, I'd like to further improve HMR more noted in the TODOs, including:

  • Refactoring away Astro compilation cache. Vite already has its own cache and we can rely on that instead. (Saves on memory)
  • Fine-grained CSS updates (When the Vite PR lands)

Docs

n/a. should be internal refactor and HMR will work as expected

Copy link

changeset-bot bot commented Jan 16, 2024

🦋 Changeset detected

Latest commit: 7577b16

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

@github-actions github-actions bot added pkg: integration Related to any renderer integration (scope) pkg: astro Related to the core `astro` package (scope) labels Jan 16, 2024
@bluwy bluwy merged commit 1539e04 into main Jan 17, 2024
13 checks passed
@bluwy bluwy deleted the hmr-part-1 branch January 17, 2024 03:27
@astrobot-houston astrobot-houston mentioned this pull request Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants