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

Preoptimize renderers and hydration directives #3568

Merged
merged 3 commits into from
Jun 10, 2022
Merged

Conversation

matthewp
Copy link
Contributor

@matthewp matthewp commented Jun 10, 2022

Changes

  • Adds all of the hydration directive scripts and renderer client entrypoints to optimized deps.
  • This prevents a race condition where Vite assigns a unique hash for all of the deps it has optimized. When it encounters an unknown dep that hash changes. The changing of the hash causes it to need to rebuild some modules, and any modules that are in the process of being loaded are in a unexpected state at the point.
  • The fix is to tell Vite about things that it will need to optimize later, which is everything in runtime/hydration.ts, so just the renderers and client directives.
  • Discussed with @patak-dev (thanks!) here: https://discord.com/channels/804011606160703521/831456449632534538/984795370955616287

Testing

  • Tested manually, this is a race condition that's hard to capture in a unit test.

Docs

N/A, bug fix.

@changeset-bot
Copy link

changeset-bot bot commented Jun 10, 2022

🦋 Changeset detected

Latest commit: 5849931

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
astro Patch

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 Jun 10, 2022
@matthewp
Copy link
Contributor Author

@patak-dev is going to add a guard to fix the underlying issue: https://discord.com/channels/804011606160703521/831456449632534538/984799269728976967

We do still want this change so that the deps are preoptimized and no browser refreshes occur on cold start.

@patak-dev
Copy link

@matthewp the race condition should be fixed after [email protected]

@matthewp matthewp merged commit 614769a into main Jun 10, 2022
@matthewp matthewp deleted the i-am-self-accepting branch June 10, 2022 16:38
@github-actions github-actions bot mentioned this pull request Jun 10, 2022
SiriousHunter pushed a commit to SiriousHunter/astro that referenced this pull request Feb 3, 2023
* Preoptimize renderers and hydration directives

* Adds a changeset

* Upgrade to Vite 2.9.12
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.

2 participants