-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@remix-run/dev": patch | ||
--- | ||
|
||
Improve performance of LiveReload proxy in Vite dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,9 @@ test.describe("Vite CSS dev", () => { | |
port: ${devPort}, | ||
strictPort: true, | ||
}, | ||
optimizeDeps: { | ||
include: ["react", "react-dom/client", "@remix-run/react"], | ||
}, | ||
plugins: [remix()], | ||
}); | ||
`, | ||
|
@@ -60,28 +63,28 @@ test.describe("Vite CSS dev", () => { | |
); | ||
} | ||
`, | ||
"app/routes/_index/styles-bundled.css": css` | ||
"app/styles-bundled.css": css` | ||
.index_bundled { | ||
background: papayawhip; | ||
padding: ${TEST_PADDING_VALUE}; | ||
} | ||
`, | ||
"app/routes/_index/styles-linked.css": css` | ||
"app/styles-linked.css": css` | ||
.index_linked { | ||
background: salmon; | ||
padding: ${TEST_PADDING_VALUE}; | ||
} | ||
`, | ||
"app/routes/_index/styles.module.css": css` | ||
"app/styles.module.css": css` | ||
.index { | ||
background: peachpuff; | ||
padding: ${TEST_PADDING_VALUE}; | ||
} | ||
`, | ||
"app/routes/_index/route.tsx": js` | ||
import "./styles-bundled.css"; | ||
import linkedStyles from "./styles-linked.css?url"; | ||
import cssModulesStyles from "./styles.module.css"; | ||
"app/routes/_index.tsx": js` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
import "../styles-bundled.css"; | ||
import linkedStyles from "../styles-linked.css?url"; | ||
import cssModulesStyles from "../styles.module.css"; | ||
|
||
export function links() { | ||
return [{ rel: "stylesheet", href: linkedStyles }]; | ||
|
@@ -160,9 +163,16 @@ test.describe("Vite CSS dev", () => { | |
test.describe("with JS", () => { | ||
test.use({ javaScriptEnabled: true }); | ||
test("updates CSS", async ({ page }) => { | ||
let pageErrors: unknown[] = []; | ||
page.on("pageerror", (error) => pageErrors.push(error)); | ||
|
||
await page.goto(`http://localhost:${devPort}/`, { | ||
waitUntil: "networkidle", | ||
}); | ||
|
||
// Ensure no errors on page load | ||
expect(pageErrors).toEqual([]); | ||
|
||
await expect(page.locator("#index [data-css-modules]")).toHaveCSS( | ||
"padding", | ||
TEST_PADDING_VALUE | ||
|
@@ -177,11 +187,11 @@ test.describe("Vite CSS dev", () => { | |
); | ||
|
||
let bundledCssContents = await fs.readFile( | ||
path.join(projectDir, "app/routes/_index/styles-bundled.css"), | ||
path.join(projectDir, "app/styles-bundled.css"), | ||
"utf8" | ||
); | ||
await fs.writeFile( | ||
path.join(projectDir, "app/routes/_index/styles-bundled.css"), | ||
path.join(projectDir, "app/styles-bundled.css"), | ||
bundledCssContents.replace( | ||
TEST_PADDING_VALUE, | ||
UPDATED_TEST_PADDING_VALUE | ||
|
@@ -190,11 +200,11 @@ test.describe("Vite CSS dev", () => { | |
); | ||
|
||
let linkedCssContents = await fs.readFile( | ||
path.join(projectDir, "app/routes/_index/styles-linked.css"), | ||
path.join(projectDir, "app/styles-linked.css"), | ||
"utf8" | ||
); | ||
await fs.writeFile( | ||
path.join(projectDir, "app/routes/_index/styles-linked.css"), | ||
path.join(projectDir, "app/styles-linked.css"), | ||
linkedCssContents.replace( | ||
TEST_PADDING_VALUE, | ||
UPDATED_TEST_PADDING_VALUE | ||
|
@@ -203,11 +213,11 @@ test.describe("Vite CSS dev", () => { | |
); | ||
|
||
let cssModuleContents = await fs.readFile( | ||
path.join(projectDir, "app/routes/_index/styles.module.css"), | ||
path.join(projectDir, "app/styles.module.css"), | ||
"utf8" | ||
); | ||
await fs.writeFile( | ||
path.join(projectDir, "app/routes/_index/styles.module.css"), | ||
path.join(projectDir, "app/styles.module.css"), | ||
cssModuleContents.replace( | ||
TEST_PADDING_VALUE, | ||
UPDATED_TEST_PADDING_VALUE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.