-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: add isServer #4648
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
feat: add isServer #4648
Conversation
|
View your CI Pipeline Execution ↗ for commit fabb267
☁️ Nx Cloud last updated this comment at |
|
Is there a way to override this in the router config? |
|
@nick-potts no. what would you need this for? |
451a556 to
5140f74
Compare
📝 WalkthroughWalkthroughAdds a new package Changes
Sequence Diagram(s)sequenceDiagram
participant Component
participant isServerModule as isServer (module)
participant Router
participant Env as Server/Browser
Component->>isServerModule: import isServer
Component->>Router: read router.isServer
Component->>isServerModule: evaluate (isServer ?? router.isServer)
alt resolved true
Component->>Env: run server-branch (SSR render)
else resolved false
Component->>Env: run client-branch (hydrate/mount)
else resolved undefined
Component->>Router: fallback to router.isServer decision
Router->>Env: run appropriate branch
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
5140f74 to
b465d43
Compare
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/react-router/vite.config.ts`:
- Around line 8-12: The Vite config currently unconditionally sets
resolve.conditions to an empty array when VITEST is unset, which overrides
Vite's defaults; change the resolve block so that the conditions property is
only added when process.env.VITEST is truthy (use ['development'] then) and omit
or leave conditions undefined for non-test builds so Vite's default resolution
is preserved; update the resolve object where "conditions" is set in the vite
config (refer to resolve.conditions and process.env.VITEST) to only supply the
conditions key during test runs.
| define: { | ||
| // Replace __TSR_IS_SERVER__ with false for client builds | ||
| // This enables tree-shaking of server-only code branches | ||
| __TSR_IS_SERVER__: 'false', | ||
| }, |
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.
I don't think I saw this variable anywhere, it is a remainder of a previous attempt?
b465d43 to
2941924
Compare
eae4e68 to
16d8f81
Compare
4355b76 to
c6e587a
Compare
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.