-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: serverfn abstraction #5040
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
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughAdds a new /factory route with UI and E2E tests to exercise server-function factories and middleware chaining. Implements multi-middleware, non-mutating, callable builder support in createServerFn. Introduces a dedicated ServerFnCompiler and Vite plugin pipeline for server-function transformation, shifting responsibilities from the start-compiler-plugin. Minor type export additions in router-utils. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant UI as /factory Route UI
participant Builder as createServerFn Builder
participant MW as Middlewares
participant Handler as ServerFn Handler
User->>UI: Click "Invoke" button
UI->>Builder: builder({ method? / response? })
Note over Builder: Returns callable builder with chainable API
UI->>Builder: .middleware([mw1, mw2]).handler(fn)
Builder->>MW: compose(mw1, mw2) (non-mutating)
UI->>Handler: call with { context, data?, signal }
MW->>Handler: next({ context: augmented })
Handler-->>UI: { name, context }
UI-->>User: Render result & comparison
sequenceDiagram
autonumber
participant Vite as Vite (dev/build)
participant Plugin as createServerFnPlugin
participant Compiler as ServerFnCompiler
participant Loader as Module Loader
Vite->>Plugin: transform(id, code)
alt capture lookup
Plugin->>Compiler: ingestModule({ id, code })
Compiler-->>Plugin: cache top-level info
else server-fn transform
Plugin->>Compiler: init if missing (env, libName, rootExport)
Plugin->>Loader: resolve/load deps (clean ids)
Loader-->>Plugin: code/ids
Plugin->>Compiler: compile({ id, code })
Compiler->>Compiler: analyze graph, find .handler chains
Compiler->>Compiler: rewrite createServerFn chains
Compiler-->>Plugin: { code, map }
Plugin-->>Vite: transformed result
end
Note over Plugin,Compiler: HMR invalidates updated modules per env
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (27)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
|
View your CI Pipeline Execution ↗ for commit 14dcd50
☁️ Nx Cloud last updated this comment at |
|
@CodeRabbit summarize this PR |
🧩 Analysis chainLet me examine the key files to understand the serverfn abstraction feature: @lukstei Here's a comprehensive summary of PR #5040: 🚀 Feature: ServerFn AbstractionThis PR introduces a new server function abstraction to TanStack Router, adding powerful server-side functionality capabilities. Here are the key highlights: What's Added:
Key Components:
Benefits:
Impact:This is a major feature addition that transforms TanStack Router from a client-side routing library into a full-stack framework, enabling developers to build complete applications with server-side functionality while maintaining the excellent DX that TanStack is known for. The PR includes extensive implementation across multiple packages, proper TypeScript definitions, and sets the foundation for server-side rendering and API routes within the TanStack Router ecosystem. 🏁 Script executed: Length of output: 4603 🏁 Script executed: Length of output: 9722 🏁 Script executed: Length of output: 349 🏁 Script executed: Length of output: 222801 🏁 Script executed: Length of output: 9472 🏁 Script executed: Length of output: 437 🏁 Script executed: Length of output: 262590 🏁 Script executed: Length of output: 1065 @lukstei Here’s the summary of PR #5040 (feat: serverfn abstraction) — MERGED
If you’d like, I can tailor a “how to use” snippet for React or Solid next. ✅ Actions performedSummary regeneration triggered. |
Summary by CodeRabbit
New Features
Chores
Tests