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

perf(vite): fix LiveReload proxy bailout logic #7883

Merged
merged 3 commits into from
Nov 3, 2023

Conversation

markdalgleish
Copy link
Member

@markdalgleish markdalgleish commented Nov 2, 2023

This fixes an issue raised by @dmarkow in #7868 (comment).

In the Vite dev server, we use a Babel transform to replace usage of @remix-run/react with a proxy module so that we can replace the LiveReload component with a Vite-specific implementation. Since this transformation doesn't come for free, we first check whether the file contains references to @remix-run/react and LiveReload. This should mean that, even if the transformation could be faster, it's only applied to a single file in your app.

However, there was an error in the boolean logic for this check that meant we were processing any file containing @remix-run/react, even if it was missing a reference to LiveReload. This PR fixes the logic so that both strings need to be present, as intended.

Copy link

changeset-bot bot commented Nov 2, 2023

🦋 Changeset detected

Latest commit: e4d410c

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
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/react Patch
@remix-run/serve Patch
@remix-run/server-runtime Patch
@remix-run/testing 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

import "./styles-bundled.css";
import linkedStyles from "./styles-linked.css?url";
import cssModulesStyles from "./styles.module.css";
"app/routes/_index.tsx": js`
Copy link
Member Author

Choose a reason for hiding this comment

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

This is fixing an unrelated issue with the test while I'm here. The template already contains app/routes/_index.tsx, so we were adding a conflicting route with app/routes/_index/route.tsx.

@@ -36,6 +36,9 @@ test.describe("Vite CSS dev", () => {
port: ${devPort},
strictPort: true,
},
optimizeDeps: {
include: ["react", "react-dom/client", "@remix-run/react"],
Copy link
Member Author

Choose a reason for hiding this comment

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

We need this array defined so that we don't have multiple copies of these dependencies due to our project structure.

@markdalgleish markdalgleish merged commit 3aa8b00 into dev Nov 3, 2023
9 checks passed
@markdalgleish markdalgleish deleted the markdalgleish/vite-livereload-proxy-perf branch November 3, 2023 03:13
@github-actions github-actions bot added the awaiting release This issue has been fixed and will be released soon label Nov 3, 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.

None yet

2 participants