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

Prevent overcaching of astro components for HMR #5293

Merged
merged 4 commits into from
Nov 3, 2022
Merged

Conversation

matthewp
Copy link
Contributor

@matthewp matthewp commented Nov 3, 2022

Changes

Testing

  • Test case added
  • Update the mock file system fallback plugin to account for HMR. This plugin only runs in tests.

Docs

N/A, bug fix

@changeset-bot
Copy link

changeset-bot bot commented Nov 3, 2022

🦋 Changeset detected

Latest commit: 15652f0

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 the pkg: astro Related to the core `astro` package (scope) label Nov 3, 2022
@matthewp matthewp marked this pull request as ready for review November 3, 2022 19:44
@@ -24,7 +24,7 @@ export async function handleHotUpdate(
{ config, logging, compile }: HandleHotUpdateOptions
) {
let isStyleOnlyChange = false;
if (ctx.file.endsWith('.astro')) {
if (ctx.file.endsWith('.astro') && isCached(config, ctx.file)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the only change. If the file is not cached then there's no reason to attempt this short-circuit path which will always cause false-positives.

Copy link
Member

Choose a reason for hiding this comment

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

👍🏻 Makes total sense, nice catch!

Comment on lines +73 to +76
fs.writeFileFromRootSync('/src/components/Header.astro', `
<h1>{Astro.props.title}</h1>
`);
triggerFSEvent(container, fs, '/src/components/Header.astro', 'change');
Copy link
Member

Choose a reason for hiding this comment

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

I love seeing these tests inline 🥇

@@ -24,7 +24,7 @@ export async function handleHotUpdate(
{ config, logging, compile }: HandleHotUpdateOptions
) {
let isStyleOnlyChange = false;
if (ctx.file.endsWith('.astro')) {
if (ctx.file.endsWith('.astro') && isCached(config, ctx.file)) {
Copy link
Member

Choose a reason for hiding this comment

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

👍🏻 Makes total sense, nice catch!

@natemoo-re
Copy link
Member

Needs a changeset (maybe?) but LGTM!

@matthewp
Copy link
Contributor Author

matthewp commented Nov 3, 2022

oh yeah, i'll add a changeset

@matthewp matthewp merged commit 4af4d8f into main Nov 3, 2022
@matthewp matthewp deleted the overcaching-hmr-astro branch November 3, 2022 20:38
@astrobot-houston astrobot-houston mentioned this pull request Nov 3, 2022
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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: TailwindCSS + Svelte: Hot Reload shows erratic behavior
2 participants