fix: decouple server functions caller and provider #5712
main fromrefs/pull/5712/head·merged by schiller-manuel(GitHub profile, opens in a new tab) Summary by CodeRabbit#
New Features
- Exposed SSR RPC helpers for React and Solid Start packages and included them in builds.
Refactor
- Reworked server-function and directive plugin/config surface to a callers/provider model with explicit directive handling.
- Added a split-parameter directive path and improved environment selection, compilation flow, and runtime wiring for multi-environment support.
- Adjusted when directive-function callbacks are invoked to avoid duplicate notifications.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: directive-functions-plugin
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: server-functions-plugin
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: react-start
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: solid-start
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-plugin-core
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-server-core
View your CI Pipeline Execution ↗ for commit f549563a87f3432e3751d0d96ab9f45aadb7f820
Command Status Duration Result nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded 5m 5s View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded 25s View ↗
☁️ Nx Cloud last updated this comment at
2025-10-31 22:30:15UTCMore templates
- tanstack-router-solid-example-basic
- tanstack-router-solid-example-basic-devtools-panel
- tanstack-router-solid-example-basic-file-based
- tanstack-router-solid-example-basic-non-nested-devtools
- tanstack-router-solid-example-basic-solid-query
- tanstack-router-solid-example-basic-solid-query-file-based
- tanstack-router-solid-example-basic-ssr-streaming-file-based
- tanstack-router-solid-example-kitchen-sink-file-based
- tanstack-router-solid-example-kitchen-sink-solid-query
- tanstack-router-solid-example-kitchen-sink-solid-query-file-based
- tanstack-router-solid-example-quickstart-file-based
- tanstack-solid-start-example-bare
- tanstack-solid-start-example-basic
- tanstack-solid-start-example-basic-auth
- tanstack-solid-start-example-basic-cloudflare
- tanstack-solid-start-example-basic-netlify
- tanstack-solid-start-example-basic-nitro
- tanstack-start-example-basic-solid-query
- tanstack-solid-start-example-basic-static
- tanstack-solid-start-example-basic-supabase
- tanstack-router-react-example-authenticated-routes
- tanstack-router-react-example-authenticated-routes-firebase
- tanstack-router-react-example-basic
- tanstack-router-react-example-basic-default-search-params
- tanstack-router-react-example-basic-devtools-panel
- tanstack-router-react-example-basic-file-based
- tanstack-router-react-example-basic-non-nested-devtools
- tanstack-router-react-example-react-query
- tanstack-router-react-example-basic-react-query-file-based
- tanstack-router-react-example-basic-ssr-file-based
- tanstack-router-react-example-basic-ssr-streaming-file-based
- tanstack-router-react-example-basic-virtual-file-based
- tanstack-router-react-example-basic-virtual-inside-file-based
- tanstack-router-react-example-deferred-data
- tanstack-router-i18n-paraglide
- tanstack-router-react-example-kitchen-sink
- tanstack-router-react-example-kitchen-sink-file-based
- tanstack-router-react-example-kitchen-sink-react-query
- tanstack-router-react-example-kitchen-sink-react-query-file-based
- tanstack-router-react-example-large-file-based
- tanstack-router-react-example-location-masking
- tanstack-router-react-example-navigation-blocking
- tanstack-router-react-example-quickstart
- tanstack-router-react-example-quickstart-esbuild-file-based
- tanstack-router-react-example-quickstart-file-based
- tanstack-router-react-example-quickstart-rspack-file-based
- tanstack-router-react-example-quickstart-webpack-file-based
- router-monorepo-react-query
- router-mono-simple
- router-mono-simple-lazy
- tanstack-router-react-example-scroll-restoration
- tanstack-search-validator-adapters
- tanstack-start-example-bare
- tanstack-start-example-basic
- tanstack-start-example-basic-auth
- tanstack-start-example-basic-cloudflare
- tanstack-start-example-basic-react-query
- tanstack-start-example-basic-static
- tanstack-start-bun-hosting
- tanstack-start-example-clerk-basic
- tanstack-start-example-convex-trellaux
- tanstack-start-example-counter
- tanstack-start-i18n-paraglide
- tanstack-start-example-large
- tanstack-start-example-material-ui
- tanstack-start-streaming-data-from-server-functions
- tanstack-start-example-supabase-basic
- tanstack-start-tailwind-v4
- tanstack-start-example-trellaux
- tanstack-start-example-workos
- tanstack-router-react-example-view-transitions
- tanstack-router-react-example-with-framer-motion
- tanstack-router-react-example-with-trpc
- tanstack-router-react-example-with-trpc-react-query
@tanstack/arktype-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5712@tanstack/directive-functions-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5712@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@5712@tanstack/history
npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5712@tanstack/nitro-v2-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@5712@tanstack/react-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@5712@tanstack/react-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@5712@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@5712@tanstack/react-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5712@tanstack/react-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5712@tanstack/react-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5712@tanstack/router-cli
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@5712@tanstack/router-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@5712@tanstack/router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@5712@tanstack/router-devtools-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@5712@tanstack/router-generator
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@5712@tanstack/router-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@5712@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@5712@tanstack/router-utils
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@5712@tanstack/router-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@5712@tanstack/server-functions-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5712@tanstack/solid-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@5712@tanstack/solid-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@5712@tanstack/solid-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@5712@tanstack/solid-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5712@tanstack/solid-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5712@tanstack/solid-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5712@tanstack/start-client-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5712@tanstack/start-plugin-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5712@tanstack/start-server-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5712@tanstack/start-static-server-functions
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@5712@tanstack/start-storage-context
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5712@tanstack/valibot-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5712@tanstack/virtual-file-routes
npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5712@tanstack/zod-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5712commit:
f549563Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/start-plugin-core/src/create-server-fn-plugin/handleCreateServerFn.ts (1)
149-150: Use the provided directive stringWe now take
opts.directive, but we still emit a hard-coded'use server'directive. Any consumer configuring a different directive will silently fail because the transformed AST never reflects their value. Please wire the new option through.- [t.directive(t.directiveLiteral('use server'))], + [t.directive(t.directiveLiteral(opts.directive))],packages/directive-functions-plugin/src/compilers.ts (1)
492-499: Fix isSourceFn derivation for replacersisSourceFnis meant to distinguish source modules from provider split chunks, but!!opts.directiveSplitParamis alwaystruebecause the param string is never empty. Provider-side compilations now masquerade as source calls, so replacer implementations that branch onisSourceFnwill mis-handle split files. Please flip the flag to use!opts.isDirectiveSplitParaminstead.- isSourceFn: !!opts.directiveSplitParam, + isSourceFn: !opts.isDirectiveSplitParam,🧹 Nitpick comments (2)
packages/start-server-core/src/router-manifest.ts (2)
11-12: Add type annotations for the dynamic import.The dynamic import lacks explicit type information, which reduces type safety and could lead to runtime errors if the virtual module doesn't export
tsrStartManifestas expected.Consider adding a type annotation:
- const { tsrStartManifest } = await import('tanstack-start-manifest:v') + const { tsrStartManifest } = await import('tanstack-start-manifest:v') as { tsrStartManifest: () => typeof startManifest }Alternatively, declare module types in a
.d.tsfile:declare module 'tanstack-start-manifest:v' { export const tsrStartManifest: () => StartManifest }As per coding guidelines (TypeScript in strict mode with extensive type safety).
21-23: Add type annotations for the dynamic import.Similar to the import on line 11, this dynamic import lacks type information.
Add appropriate type annotations:
- const { injectedHeadScripts } = await import( - 'tanstack-start-injected-head-scripts:v' - ) + const { injectedHeadScripts } = await import( + 'tanstack-start-injected-head-scripts:v' + ) as { injectedHeadScripts?: string }Or declare the module type in a
.d.tsfile as mentioned in the previous comment.As per coding guidelines (TypeScript in strict mode with extensive type safety).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 943d61642f55247861085e166189d2babd448b03 and c57f012ef7fefb3da8c354d51d8888a31594774b.
📒 Files selected for processing (21)
packages/directive-functions-plugin/src/compilers.ts(7 hunks)packages/directive-functions-plugin/src/index.ts(1 hunks)packages/directive-functions-plugin/tests/compiler.test.ts(0 hunks)packages/react-start/package.json(1 hunks)packages/react-start/src/ssr-rpc.ts(1 hunks)packages/react-start/vite.config.ts(1 hunks)packages/server-functions-plugin/src/index.ts(4 hunks)packages/solid-start/package.json(1 hunks)packages/solid-start/src/ssr-rpc.ts(1 hunks)packages/solid-start/vite.config.ts(1 hunks)packages/start-plugin-core/src/create-server-fn-plugin/compiler.ts(2 hunks)packages/start-plugin-core/src/create-server-fn-plugin/handleCreateServerFn.ts(1 hunks)packages/start-plugin-core/src/create-server-fn-plugin/plugin.ts(2 hunks)packages/start-plugin-core/src/plugin.ts(3 hunks)packages/start-server-core/package.json(1 hunks)packages/start-server-core/src/createServerRpc.ts(0 hunks)packages/start-server-core/src/createSsrRpc.ts(1 hunks)packages/start-server-core/src/loadVirtualModule.ts(0 hunks)packages/start-server-core/src/router-manifest.ts(2 hunks)packages/start-server-core/src/virtual-modules.ts(1 hunks)packages/start-server-core/vite.config.ts(1 hunks)
💤 Files with no reviewable changes (3)
- packages/start-server-core/src/createServerRpc.ts
- packages/directive-functions-plugin/tests/compiler.test.ts
- packages/start-server-core/src/loadVirtualModule.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
packages/solid-start/src/ssr-rpc.tspackages/react-start/vite.config.tspackages/start-plugin-core/src/create-server-fn-plugin/plugin.tspackages/start-server-core/src/virtual-modules.tspackages/start-plugin-core/src/create-server-fn-plugin/handleCreateServerFn.tspackages/start-plugin-core/src/create-server-fn-plugin/compiler.tspackages/server-functions-plugin/src/index.tspackages/start-server-core/src/createSsrRpc.tspackages/solid-start/vite.config.tspackages/react-start/src/ssr-rpc.tspackages/start-server-core/src/router-manifest.tspackages/directive-functions-plugin/src/compilers.tspackages/start-server-core/vite.config.tspackages/start-plugin-core/src/plugin.tspackages/directive-functions-plugin/src/index.ts
packages/{*-start,start-*}/**
📄 CodeRabbit inference engine (AGENTS.md)
Name and place Start framework packages under packages/-start/ or packages/start-/
Files:
packages/solid-start/src/ssr-rpc.tspackages/react-start/vite.config.tspackages/start-plugin-core/src/create-server-fn-plugin/plugin.tspackages/start-server-core/src/virtual-modules.tspackages/start-server-core/package.jsonpackages/start-plugin-core/src/create-server-fn-plugin/handleCreateServerFn.tspackages/start-plugin-core/src/create-server-fn-plugin/compiler.tspackages/react-start/package.jsonpackages/start-server-core/src/createSsrRpc.tspackages/solid-start/package.jsonpackages/solid-start/vite.config.tspackages/react-start/src/ssr-rpc.tspackages/start-server-core/src/router-manifest.tspackages/start-server-core/vite.config.tspackages/start-plugin-core/src/plugin.ts
**/package.json
📄 CodeRabbit inference engine (AGENTS.md)
Use workspace:* protocol for internal dependencies in package.json files
Files:
packages/start-server-core/package.jsonpackages/react-start/package.jsonpackages/solid-start/package.json
🧠 Learnings (6)
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/{react-router,solid-router}/** : Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/Applied to files:
packages/solid-start/src/ssr-rpc.tspackages/start-server-core/src/router-manifest.ts
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/router-core/** : Keep framework-agnostic core router logic in packages/router-core/Applied to files:
packages/start-server-core/src/router-manifest.ts
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to docs/{router,start}/** : Place router docs under docs/router/ and start framework docs under docs/start/Applied to files:
packages/start-server-core/src/router-manifest.ts
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/{router-cli,router-generator,router-plugin,virtual-file-routes}/** : Keep CLI, generators, bundler plugins, and virtual file routing utilities in their dedicated tooling package directoriesApplied to files:
packages/start-server-core/src/router-manifest.ts
📚 Learning: 2025-09-23T17:36:12.598Z
Learnt from: CR Repo: TanStack/router PR: 0 File: AGENTS.md:0-0 Timestamp: 2025-09-23T17:36:12.598Z Learning: Applies to packages/router-plugin/** : Use unplugin for universal bundler plugins in the router-plugin packageApplied to files:
packages/start-server-core/src/router-manifest.ts
📚 Learning: 2025-10-08T08:11:47.088Z
Learnt from: nlynzaad Repo: TanStack/router PR: 5402 File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21 Timestamp: 2025-10-08T08:11:47.088Z Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.Applied to files:
packages/start-server-core/src/router-manifest.ts
🧬 Code graph analysis (5)
packages/start-plugin-core/src/create-server-fn-plugin/plugin.ts (1)
packages/start-plugin-core/src/start-compiler-plugin/compilers.ts (1)
CompileStartFrameworkOptions(18-18)
packages/start-plugin-core/src/create-server-fn-plugin/compiler.ts (1)
packages/start-plugin-core/src/create-server-fn-plugin/handleCreateServerFn.ts (1)
handleCreateServerFn(8-157)
packages/server-functions-plugin/src/index.ts (3)
packages/directive-functions-plugin/src/compilers.ts (2)
ReplacerFn(32-38)GenerateFunctionIdFn(26-30)
packages/directive-functions-plugin/src/index.ts (3)
ReplacerFn(19-19)GenerateFunctionIdFn(20-20)TanStackDirectiveFunctionsPluginEnv(48-126)
packages/start-server-core/src/fake-start-server-fn-manifest.ts (1)
getServerFnById(1-1)
packages/start-plugin-core/src/plugin.ts (4)
packages/start-plugin-core/src/create-server-fn-plugin/plugin.ts (1)
createServerFnPlugin(42-178)
packages/server-functions-plugin/src/index.ts (1)
TanStackServerFnPlugin(42-244)
packages/start-server-core/src/virtual-modules.ts (1)
VIRTUAL_MODULES(1-5)
packages/start-plugin-core/src/constants.ts (1)
VITE_ENVIRONMENT_NAMES(1-6)
packages/directive-functions-plugin/src/index.ts (2)
packages/directive-functions-plugin/src/compilers.ts (3)
DirectiveFn(12-19)GenerateFunctionIdFn(26-30)compileDirectives(55-110)
packages/router-plugin/src/core/utils.ts (1)
debug(1-3)
🪛 ast-grep (0.39.6)
packages/directive-functions-plugin/src/index.ts
[warning] 33-33: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns. Context: new RegExp(
"${directive}"|'${directive}', 'gm') Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html
(regexp-from-variable)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Preview
- GitHub Check: Test
🔇 Additional comments (10)
packages/start-server-core/src/router-manifest.ts (1)
11-11: The suggestion in the review comment would break bundler support and is not viable.The hardcoded strings in
router-manifest.ts(lines 11 and 21-22) are not problematic duplication—they are a technical necessity. Bundlers like Vite and Webpack require statically analyzable string literals inawait import()calls at build time. Usingawait import(VIRTUAL_MODULES.startManifest)would prevent the bundler from resolving the virtual module, breaking the build.The VIRTUAL_MODULES constant serves a different purpose (likely for reference and type safety elsewhere) but cannot be used in these dynamic import statements without losing bundler support.
Likely an incorrect or invalid review comment.
packages/react-start/vite.config.ts (1)
32-32: LGTM! SSR RPC entry added correctly.The new entry point for SSR RPC follows the existing pattern and aligns with the corresponding source file and package.json export additions.
packages/solid-start/vite.config.ts (1)
30-30: LGTM! SSR RPC entry added correctly.The entry addition is consistent with the React Start implementation and properly wired with the source file and package.json exports.
packages/start-server-core/vite.config.ts (1)
24-24: LGTM! Core SSR RPC entry added correctly.The createSsrRpc entry point is properly configured and will be re-exported by downstream packages (react-start and solid-start).
packages/react-start/src/ssr-rpc.ts (1)
1-1: LGTM! Consistent re-export pattern.The re-export follows the same pattern as the Solid Start implementation. The verification script in the solid-start/src/ssr-rpc.ts review will confirm the export path exists.
packages/solid-start/package.json (1)
59-64: LGTM! SSR RPC export properly configured.The new export follows the established pattern and correctly maps to the built artifacts in the dist directory.
packages/react-start/package.json (1)
65-70: LGTM! SSR RPC export properly configured.The export configuration is consistent with the Solid Start implementation and follows the existing export patterns in this package.
packages/start-plugin-core/src/create-server-fn-plugin/compiler.ts (2)
63-63: LGTM! Directive parameter added to options.The directive field is properly added to the constructor options, enabling explicit directive handling as described in the PR objectives.
256-263: Code changes are correct; directive propagation is appropriate.The verification confirms that
handleCreateMiddlewareis correctly designed without directive context. The function signature only acceptsenvparameter, and all transformations (removing validators and server calls on the client) are purely environment-based, not directive-dependent. The directive is correctly passed only tohandleCreateServerFn, where it's needed for server function creation logic.packages/solid-start/src/ssr-rpc.ts (1)
1-1: Export path verified and confirmed.The
@tanstack/start-server-corepackage properly exports./createSsrRpcwith both TypeScript types and default exports configured. The source file exists atpackages/start-server-core/src/createSsrRpc.ts. No issues found.packages/start-server-core/src/createSsrRpc.ts lines 6 to 9Outdated@@ -0,0 +1,9 @@1+import { TSS_SERVER_FUNCTION } from '@tanstack/start-client-core'2+import { getServerFnById } from './getServerFnById'3+4+export const createSsrRpc = (functionId: string) => {5+ const url = process.env.TSS_SERVER_FN_BASE + functionId6+ const fn = async (opts: any, signal: any): Promise<any> => {7+ const serverFn = await getServerFnById(functionId)8+ return serverFn(opts ?? {}, signal)9+ }⚠️ Potential issue | 🟠 Major
Make SSR RPC callable with a single argument
The generated declaration right now requires two positional parameters, so TypeScript callers can’t do
await rpc(payload)without supplying a second argument. The client/server RPC helpers keepsignaloptional; this one should too to avoid an API regression.- const fn = async (opts: any, signal: any): Promise<any> => { + const fn = async ( + opts?: any, + signal?: any, + ): Promise<any> => { const serverFn = await getServerFnById(functionId) return serverFn(opts ?? {}, signal) }📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const fn = async ( opts?: any, signal?: any, ): Promise<any> => { const serverFn = await getServerFnById(functionId) return serverFn(opts ?? {}, signal) }🤖 Prompt for AI Agents
In packages/start-server-core/src/createSsrRpc.ts around lines 6 to 9, the async wrapper requires two positional params which prevents callers from invoking rpc(payload) — make the second parameter optional (e.g. signal?: AbortSignal or signal?: any) in the function signature and keep the current fallback behavior when calling serverFn(opts ?? {}, signal) so callers can omit the signal without a type error.Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/directive-functions-plugin/tests/compiler.test.ts (1)
48-55: Consider updating or clarifying comments.The comments mention
splitImportFnand conditional behavior for split functions vs referenced functions, but thereplacercode only showscreateServerRpc(${JSON.stringify(opts.functionId)}, ${opts.fn}). If this conditional logic is handled elsewhere in the compiler (driven by the newisDirectiveSplitParamflag), consider updating these comments to clarify that, or remove them if they're outdated.📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between c57f012ef7fefb3da8c354d51d8888a31594774b and 06b687f92e081b68d620127c21cacdf4d202ed93.
📒 Files selected for processing (3)
packages/directive-functions-plugin/tests/compiler.test.ts(2 hunks)packages/start-plugin-core/tests/createMiddleware-create-server-fn-plugin/createMiddleware.test.ts(1 hunks)packages/start-plugin-core/tests/createServerFn/createServerFn.test.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
packages/start-plugin-core/tests/createMiddleware-create-server-fn-plugin/createMiddleware.test.tspackages/start-plugin-core/tests/createServerFn/createServerFn.test.tspackages/directive-functions-plugin/tests/compiler.test.ts
packages/{*-start,start-*}/**
📄 CodeRabbit inference engine (AGENTS.md)
Name and place Start framework packages under packages/-start/ or packages/start-/
Files:
packages/start-plugin-core/tests/createMiddleware-create-server-fn-plugin/createMiddleware.test.tspackages/start-plugin-core/tests/createServerFn/createServerFn.test.ts
🧬 Code graph analysis (1)
packages/directive-functions-plugin/tests/compiler.test.ts (1)
packages/directive-functions-plugin/src/compilers.ts (1)
CompileDirectivesOpts(42-53)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test
- GitHub Check: Preview
🔇 Additional comments (5)
packages/start-plugin-core/tests/createMiddleware-create-server-fn-plugin/createMiddleware.test.ts (1)
34-34: LGTM! Directive option added correctly.The addition of the
directive: 'use server'option aligns with the PR's objective to thread directives through the compiler pipeline. The test setup correctly passes this directive to theServerFnCompilerconstructor.packages/start-plugin-core/tests/createServerFn/createServerFn.test.ts (1)
30-30: LGTM! Directive option added with comprehensive test coverage.The addition of the
directive: 'use server'option is correct and aligns with the PR's refactoring objectives. The inline snapshots throughout this file (lines 77-96, 118-130, 139-157) provide excellent verification that the directive is properly emitted in the generated code, confirming the feature works as expected.packages/directive-functions-plugin/tests/compiler.test.ts (3)
20-29: LGTM! Configuration correctly updated for new API.The addition of
directiveSplitParamandisDirectiveSplitParam: falsealigns with the refactoredCompileDirectivesOptsinterface. Thefalsevalue is appropriate for client-side compilation.
31-40: LGTM! SSR configuration correctly updated.The configuration changes mirror the client config appropriately, with
isDirectiveSplitParam: falsefor SSR compilation context.
60-978: Excellent test coverage maintained.The comprehensive test suite remains unchanged and continues to validate all directive compilation scenarios. The fact that only configuration objects needed updating demonstrates good API design and backward compatibility.
Sign in to join this conversation.
Walkthrough#
Refactors directive and server-function compilation and plugin wiring: threads a single
directivestring and split-param flags through compiler APIs, replaces client/server env pairs with a callers/provider model, adds SSR RPC exports andcreateSsrRpc, and replaces static virtual-module loading with dynamic imports.Changes#
packages/directive-functions-plugin/src/compilers.ts,packages/directive-functions-plugin/src/index.ts,packages/directive-functions-plugin/tests/compiler.test.tsdirectiveLabel; add publicdirectiveSplitParam: stringandisDirectiveSplitParam: boolean; threaddirectivethrough APIs; remove internal derivation helpers; addbuildDirectiveSplitParam; update compile/find signatures and error messages.packages/server-functions-plugin/src/index.tscallers: []+providermodel; makeenvNamerequired; adddirectiveoption; computeappliedEnvironmentsfor apply-to-env logic; update manifest /getServerFnByIdresolution per environment.packages/start-plugin-core/src/create-server-fn-plugin/compiler.ts,packages/start-plugin-core/src/create-server-fn-plugin/handleCreateServerFn.ts,packages/start-plugin-core/src/create-server-fn-plugin/plugin.tsdirectivetoServerFnCompileroptions and pass tohandleCreateServerFn; changecreateServerFnPluginto accept{ framework, directive }and forwarddirectiveinto the compiler.packages/start-plugin-core/src/plugin.tsserverFnconfig (directive,ssr.getServerFnById); derivedirective; buildcallers/providerstructures; callcreateServerFnPluginwith new options.packages/react-start/package.json,packages/react-start/src/ssr-rpc.ts,packages/react-start/vite.config.ts,packages/solid-start/package.json,packages/solid-start/src/ssr-rpc.ts,packages/solid-start/vite.config.ts,packages/start-server-core/package.json,packages/start-server-core/vite.config.ts./ssr-rpcexport entries toreact-startandsolid-start; add./createSsrRpcexport tostart-server-core; add corresponding re-export modules and include SSR RPC sources in Vite entries.packages/start-server-core/src/createSsrRpc.ts,packages/start-server-core/src/createServerRpc.tscreateSsrRpc(functionId)factory (async handler withurl,functionId, and[TSS_SERVER_FUNCTION]metadata); remove URL construction from previouscreateServerRpc.packages/start-server-core/src/loadVirtualModule.ts,packages/start-server-core/src/router-manifest.ts,packages/start-server-core/src/virtual-modules.tsloadVirtualModulehelper andVirtualModulestype; switch to dynamic imports for virtual modules inrouter-manifest; reorderVIRTUAL_MODULESentries and remove the unused helper.packages/directive-functions-plugin/tests/compiler.test.ts,packages/start-plugin-core/tests/*directiveLabeland adddirectiveSplitParam/isDirectiveSplitParam; constructServerFnCompilerwithdirectivein test setups.Sequence Diagram(s)#
Estimated code review effort#
🎯 4 (Complex) | ⏱️ ~60 minutes
packages/server-functions-plugin/src/index.ts— environment model, manifest and per-environmentgetServerFnByIdlogic.packages/directive-functions-plugin/src/compilers.ts&src/index.ts— changed signatures and option shapes threaded widely.createSsrRpcaddition, Vite entries, and dynamic virtual-module imports inrouter-manifest.ts.Possibly related PRs#
server-functions-plugin/src/index.tsand relates to environment/directive wiring.Suggested reviewers#
Poem#
Pre-merge checks and finishing touches#
❌ Failed checks (1 warning)
@coderabbitai generate docstringsto improve docstring coverage.✅ Passed checks (2 passed)
TanStackServerFnPluginOptsandDirectiveFunctionsVitePluginEnvOptionsfrom separate client/server configuration fields to a unified callers array plus provider object pattern, which is the most significant and pervasive change across multiple files in the directive-functions-plugin, server-functions-plugin, and start-plugin-core packages. The title is concise, specific, and clearly communicates the main change from a developer's perspective without being vague or misleading.✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 06b687f92e081b68d620127c21cacdf4d202ed93 and f549563a87f3432e3751d0d96ab9f45aadb7f820.
📒 Files selected for processing (1)
packages/start-server-core/src/createSsrRpc.ts(1 hunks)🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
Comment `@coderabbitai help` to get the list of available commands and usage tips.