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(vite): fix HMR preamble race condition #7919

Merged
merged 3 commits into from
Nov 6, 2023

Conversation

markdalgleish
Copy link
Member

Closes #7863.

This PR fixes a couple issues:

  • Resolves a race condition between the React Refresh preamble script and the app code by ensuring that the preamble is imported first in the same script tag as the app code.
  • Allows the LiveReload component to behave the same as the existing Remix compiler from a consumer perspective. You can now choose not to render it, forcing you to perform a full refresh to see changes, and you can also render it after Scripts. I've updated the ordering of LiveReload and Scripts in the Vite tests to show this is the case.

Copy link

changeset-bot bot commented Nov 6, 2023

🦋 Changeset detected

Latest commit: 463fb74

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

This PR includes changesets to release 16 packages
Name Type
@remix-run/dev Patch
@remix-run/react Patch
@remix-run/testing Patch
create-remix Patch
remix Patch
@remix-run/architect Patch
@remix-run/cloudflare Patch
@remix-run/cloudflare-pages Patch
@remix-run/cloudflare-workers Patch
@remix-run/css-bundle Patch
@remix-run/deno Patch
@remix-run/eslint-config Patch
@remix-run/express Patch
@remix-run/node Patch
@remix-run/serve Patch
@remix-run/server-runtime 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

Copy link
Contributor

@pcattori pcattori left a comment

Choose a reason for hiding this comment

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

LGTM

Longterm, I'd like an API that decouples dev-only scripts from prod scripts. For example, I may want to use HMR in development but not ship any JS assets in production.

@pcattori
Copy link
Contributor

pcattori commented Nov 6, 2023

Also, I could have sworn that using <LiveReload /> without <Scripts /> worked for HMR in esbuild-based compiler, but I guess not. So this would get us parity (and then some) with the current Remix compiler.

@pcattori pcattori merged commit 22869fe into dev Nov 6, 2023
9 checks passed
@pcattori pcattori deleted the markdalgleish/fix-vite-hmr-race-condition branch November 6, 2023 20:59
@github-actions github-actions bot added the awaiting release This issue has been fixed and will be released soon label Nov 6, 2023
Copy link
Contributor

🤖 Hello there,

We just published version 2.3.0-pre.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Copy link
Contributor

🤖 Hello there,

We just published version 2.3.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@github-actions github-actions bot removed the awaiting release This issue has been fixed and will be released soon label Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants