fix(plugin-client-redirects): redirect before hydration - #3555
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5acfdde4c3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Rsdoctor Bundle Diff AnalysisFound 5 projects in monorepo, 3 projects with changes. 📊 Quick Summary
📋 Detailed Reports (Click to expand)📁 website_jsPath:
📦 Download Diff Report: website_js Bundle Diff 📁 website_htmlPath:
📦 Download Diff Report: website_html Bundle Diff 📁 website_mdPath:
📦 Download Diff Report: website_md Bundle Diff Generated by Rsdoctor GitHub Action |
There was a problem hiding this comment.
Pull request overview
This PR updates @rspress/plugin-client-redirects to perform redirects via a production-only inline <script> injected into the HTML head so redirects can happen before React hydration (reducing the visible “flash” of the source page). It removes the previous runtime React component implementation, trims React-related dependencies, and updates docs/tests to reflect the new production-only behavior.
Changes:
- Replace the runtime
Redirect.tsxglobal UI component with a generated inline head script (production only). - Add unit tests for the inline script generator and update e2e coverage to validate production behavior and dev inactivity.
- Update English/Chinese docs to clearly state the plugin is production-only and depends on build output.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| website/docs/zh/plugin/official-plugins/client-redirects.mdx | Clarifies production-only behavior and guidance for redirects (ZH). |
| website/docs/en/plugin/official-plugins/client-redirects.mdx | Clarifies production-only behavior and guidance for redirects (EN). |
| pnpm-lock.yaml | Removes React-related dependencies from the plugin’s dependency graph. |
| packages/plugin-client-redirects/tests/inlineRedirect.test.ts | Adds unit tests for inline redirect script generation and prod-only injection. |
| packages/plugin-client-redirects/static/Redirect.tsx | Removes the previous React runtime redirect component implementation. |
| packages/plugin-client-redirects/src/inlineRedirect.ts | Introduces inline redirect script generator used for head injection. |
| packages/plugin-client-redirects/src/index.ts | Switches plugin behavior to inject inline head script only in production. |
| packages/plugin-client-redirects/package.json | Drops static/ from published files and removes React-related devDependencies. |
| e2e/fixtures/client-redirects/index.test.ts | Updates e2e to validate production redirects via preview build and adds dev inactivity test. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5acfdde to
f09905d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f09905da4f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Deploying rspress-v2 with
|
| Latest commit: |
c1a7d24
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c1512d27.rspress-v2.pages.dev |
| Branch Preview URL: | https://fix-client-redirect-before-h.rspress-v2.pages.dev |
f09905d to
c1a7d24
Compare
Summary
This PR runs initial client redirects from a production-only inline head script so they happen before hydration without flashing the source page.
It also keeps the production runtime redirect component for SPA navigation and as a fallback when a strict CSP blocks inline scripts. The inline path now handles
basecorrectly, is isolated in an IIFE, and coordinates with the built-in locale redirect to avoid competing navigations. The English and Chinese docs describe the production-only behavior and server-redirect recommendation.Related PR
route.localeRedirect#3534Checklist