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

WIP: Triggers HMR for server-only components #3118

Closed
wants to merge 1 commit into from

Conversation

tony-sull
Copy link
Contributor

Changes

Closes #3069 and #3097

For server-only components (i.e. components not using client: directives) we never ship the JS to the browser and HMR is never aware of those module dependencies

This updates our HMR script to watch for Vite's HMR events and force a page reload when only astro pages are updated

Testing

None, would be excellent to find a clean way to test HMR though

Docs

None, bug fix only

@changeset-bot
Copy link

changeset-bot bot commented Apr 15, 2022

⚠️ No Changeset found

Latest commit: f698887

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Apr 15, 2022
@tony-sull tony-sull changed the title WIP: Triggers HMR for server-only components fix: Triggers HMR for server-only components Apr 15, 2022
await onUpdate(file);
});
import.meta.hot.on('vite:beforeUpdate', async ({ updates }) => {
const astroUpdate = Array.from(updates)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updates to server-only components trigger this event for the current astro page

vite-plugin-astro will never trigger the custom astro:update since it wasn't a .astro file that triggered the event. I didn't see any way to know whether the component was client hydrated or not unfortunately, would be a cleaner fix if we could still trigger astro:update there

@tony-sull tony-sull changed the title fix: Triggers HMR for server-only components WIP: Triggers HMR for server-only components Apr 15, 2022
@tony-sull tony-sull marked this pull request as draft April 15, 2022 12:49
@tony-sull
Copy link
Contributor Author

Closing this in favor of #3138

@tony-sull tony-sull closed this Apr 19, 2022
@bluwy bluwy deleted the fix/hmr-server-components branch October 8, 2024 05:56
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: Svelte components aren't reloaded without client property
1 participant