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

fix(#9216): fix style HMR in certain cases #9219

Merged
merged 2 commits into from
Nov 29, 2023
Merged

fix(#9216): fix style HMR in certain cases #9219

merged 2 commits into from
Nov 29, 2023

Conversation

natemoo-re
Copy link
Member

Changes

  • Closes PLT-1261
  • Adjusts our style HMR logic so that style only changes will only treat the effected style modules as HMR candidates
  • This fixes an edge case where updates inside of Astro files referenced by the main page file would cause a full reload because pages/index.astro would remain in the module graph.
  • This should close CSS changes do not always correctly update using HMR #9216, which is a report about this specific edge case. As reported, if the style inside of src/layouts/Layout.astro was updated, the whole index page would reload. With this fix, updating the style inside of src/layouts/Layout.astro does not reload the index page but swaps the new styles in seamlessly.

Testing

Tested manually, our existing HMR tests aren't capable of catching this problem

Docs

Bug fix only

Copy link

changeset-bot bot commented Nov 28, 2023

🦋 Changeset detected

Latest commit: d6e27e1

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: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review labels Nov 28, 2023
@natemoo-re
Copy link
Member Author

Would love a @bluwy gut check on this one! The goal is to filter the HMR modules down to just the style that actually changed. We previously only discarded a module if it was known to be irrelevant but this swaps the logic so that we discard everything we don't recognize as relevant.

Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me 👍

@natemoo-re natemoo-re merged commit 067a65f into main Nov 29, 2023
13 checks passed
@natemoo-re natemoo-re deleted the fix/9216 branch November 29, 2023 15:12
@astrobot-houston astrobot-houston mentioned this pull request Nov 29, 2023
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) pr: docs A PR that includes documentation for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CSS changes do not always correctly update using HMR
3 participants