-
Notifications
You must be signed in to change notification settings - Fork 10
fix: serve the SPA shell for ssr:false apps in rsbuild dev #76
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
Merged
+125
−27
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7d2914b
fix: migrate dev middleware registration to server.setup
ScriptedAlchemy 7ce1f3e
fix: serve the SPA shell for ssr:false apps in rsbuild dev
ScriptedAlchemy dbc0977
refactor: dedupe SPA dev test scaffolding and drop dead bench override
ScriptedAlchemy b3fce8d
refactor: wait on explicit dev environments in the bench harness
ScriptedAlchemy 1f0c95f
Merge remote-tracking branch 'origin/main' into codex/pr-77-babysit
ScriptedAlchemy 28076b0
test: wait for SPA dev compilers before e2e
ScriptedAlchemy 1b18a5e
Merge remote-tracking branch 'origin/claude/peaceful-benz-6eae2b' int…
ScriptedAlchemy 19888ec
test: split SPA dev deep-link coverage
ScriptedAlchemy 479565b
Merge remote-tracking branch 'origin/main' into codex/pr-77-babysit
ScriptedAlchemy 3a9fbda
Merge remote-tracking branch 'origin/claude/peaceful-benz-6eae2b' int…
ScriptedAlchemy 619864f
chore: add dev server setup changeset
ScriptedAlchemy d9721e3
Merge remote-tracking branch 'origin/claude/peaceful-benz-6eae2b' int…
ScriptedAlchemy dd8688b
chore: add spa dev changeset
ScriptedAlchemy 1a3c99f
Merge remote-tracking branch 'origin/main' into codex/pr76-changeset
ScriptedAlchemy 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 hidden or 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 @@ | ||
| --- | ||
| 'rsbuild-plugin-react-router': patch | ||
| --- | ||
|
|
||
| Serve the React Router SPA shell during `rsbuild dev` when `ssr` is disabled. |
This file contains hidden or 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 hidden or 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 hidden or 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,24 @@ | ||
| import { defineConfig } from '@playwright/test'; | ||
| import baseConfig from './playwright.config'; | ||
|
|
||
| // Dev-mode config — runs the SPA against `rsbuild dev` instead of the | ||
| // prerendered static build. Kept separate from playwright.config.ts because | ||
| // the dev server writes to the same build directory the static suite asserts | ||
| // against, so the two servers cannot run side by side. | ||
| export default defineConfig({ | ||
| ...baseConfig, | ||
| testDir: './tests/e2e-dev', | ||
| use: { | ||
| ...baseConfig.use, | ||
| baseURL: 'http://localhost:3002', | ||
| }, | ||
| webServer: { | ||
| ...baseConfig.webServer, | ||
| command: 'pnpm run dev --port 3002', | ||
| url: undefined, | ||
| wait: { | ||
| stdout: | ||
| /ready[\s\S]*?\(web\)[\s\S]*?ready[\s\S]*?\(node\)|ready[\s\S]*?\(node\)[\s\S]*?ready[\s\S]*?\(web\)/, | ||
| }, | ||
| }, | ||
| }); | ||
This file contains hidden or 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,48 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
|
|
||
| // Regression coverage for SPA mode (`ssr: false`) under `rsbuild dev`. | ||
| // The dev server used to return 404 for every path because no dev middleware | ||
| // was registered and no HTML entry existed; these tests hit the dev server | ||
| // directly (see playwright.dev.config.ts), unlike the static-build suite. | ||
| test.describe('SPA Mode dev server', () => { | ||
| test('serves the SPA shell at /', async ({ page }) => { | ||
| const response = await page.goto('/'); | ||
|
|
||
| expect(response?.status()).toBe(200); | ||
| expect(response?.headers()['content-type']).toContain('text/html'); | ||
|
|
||
| // The shell carries the SPA hydration payload. | ||
| const html = (await response?.text()) ?? ''; | ||
| expect(html).toContain('window.__reactRouterContext'); | ||
| expect(html).toContain('"isSpaMode":true'); | ||
| expect(html).toContain('"ssr":false'); | ||
| expect(html).toContain('entry.client.js'); | ||
|
|
||
| // The page hydrates and renders the home route client-side. | ||
| await expect( | ||
| page.locator('h1:has-text("Welcome to React Router")') | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| test('serves the SPA shell for deep links', async ({ page }) => { | ||
| const response = await page.goto('/about'); | ||
|
|
||
| expect(response?.status()).toBe(200); | ||
| await expect(page.locator('h1:has-text("About This Demo")')).toBeVisible(); | ||
| }); | ||
|
|
||
| test('serves the SPA shell for nested routes', async ({ page }) => { | ||
| await page.goto('/docs/getting-started'); | ||
| await expect( | ||
| page.locator('h1:has-text("Getting Started")') | ||
| ).toBeVisible(); | ||
| }); | ||
|
|
||
| test('performs client-side navigation after hydration', async ({ page }) => { | ||
| await page.goto('/'); | ||
|
|
||
| await page.locator('a[href="/about"]').first().click(); | ||
| await expect(page).toHaveURL('/about'); | ||
| await expect(page.locator('h1:has-text("About This Demo")')).toBeVisible(); | ||
| }); | ||
| }); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.