Skip to content

Conversation

@schiller-manuel
Copy link
Contributor

@schiller-manuel schiller-manuel commented Oct 31, 2025

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.

- remove directiveLabel
- make directive configurable
- make envName required
this let's us avoid `tanstack-start-injected-head-scripts:v` being present in prod build
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 31, 2025

Walkthrough

Refactors directive and server-function compilation and plugin wiring: threads a single directive string and split-param flags through compiler APIs, replaces client/server env pairs with a callers/provider model, adds SSR RPC exports and createSsrRpc, and replaces static virtual-module loading with dynamic imports.

Changes

Cohort / File(s) Summary
Directive plugin
packages/directive-functions-plugin/src/compilers.ts, packages/directive-functions-plugin/src/index.ts, packages/directive-functions-plugin/tests/compiler.test.ts
Remove directiveLabel; add public directiveSplitParam: string and isDirectiveSplitParam: boolean; thread directive through APIs; remove internal derivation helpers; add buildDirectiveSplitParam; update compile/find signatures and error messages.
Server functions plugin
packages/server-functions-plugin/src/index.ts
Replace client/server paired envs with callers: [] + provider model; make envName required; add directive option; compute appliedEnvironments for apply-to-env logic; update manifest / getServerFnById resolution per environment.
Start plugin core — create-server-fn
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.ts
Add directive to ServerFnCompiler options and pass to handleCreateServerFn; change createServerFnPlugin to accept { framework, directive } and forward directive into the compiler.
Start plugin core — core wiring
packages/start-plugin-core/src/plugin.ts
Add optional serverFn config (directive, ssr.getServerFnById); derive directive; build callers/provider structures; call createServerFnPlugin with new options.
SSR RPC exports & entries
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
Add ./ssr-rpc export entries to react-start and solid-start; add ./createSsrRpc export to start-server-core; add corresponding re-export modules and include SSR RPC sources in Vite entries.
Server core — SSR RPC implementation
packages/start-server-core/src/createSsrRpc.ts, packages/start-server-core/src/createServerRpc.ts
Add new createSsrRpc(functionId) factory (async handler with url, functionId, and [TSS_SERVER_FUNCTION] metadata); remove URL construction from previous createServerRpc.
Virtual modules / manifest changes
packages/start-server-core/src/loadVirtualModule.ts, packages/start-server-core/src/router-manifest.ts, packages/start-server-core/src/virtual-modules.ts
Remove loadVirtualModule helper and VirtualModules type; switch to dynamic imports for virtual modules in router-manifest; reorder VIRTUAL_MODULES entries and remove the unused helper.
Tests updated for new options
packages/directive-functions-plugin/tests/compiler.test.ts, packages/start-plugin-core/tests/*
Update test configs to remove directiveLabel and add directiveSplitParam / isDirectiveSplitParam; construct ServerFnCompiler with directive in test setups.

Sequence Diagram(s)

sequenceDiagram
    actor File as File (source)
    participant Transform as Transform Handler
    participant EnvSel as Env Selector
    participant Compiler as compileDirectives
    participant Finder as findDirectives
    participant Caller as onDirectiveFnsById

    rect rgb(230,240,255)
    File->>Transform: transform(code, id)
    Transform->>Transform: normalize id
    Transform->>EnvSel: id contains directiveSplitParam?
    EnvSel-->>Transform: isDirectiveSplitParam (true/false)
    end

    rect rgb(235,255,230)
    alt isDirectiveSplitParam
        Transform->>Transform: select provider options
    else
        Transform->>Transform: select caller matching env
    end
    end

    rect rgb(255,245,220)
    Note over Transform,Compiler: Compile with explicit directive + split params
    Transform->>Compiler: compileDirectives({ directive, directiveSplitParam, isDirectiveSplitParam, ... })
    Compiler->>Finder: findDirectives({ directive, directiveSplitParam, isDirectiveSplitParam, ... })
    Finder-->>Compiler: directives map
    Compiler-->>Transform: { compiledResult, directiveFnsById }
    end

    rect rgb(250,235,245)
    alt not isDirectiveSplitParam
        Transform->>Caller: onDirectiveFnsById(directiveFnsById)
    else
        Note right of Transform: skip onDirectiveFnsById for split-param path
    end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

  • Areas needing extra attention:
    • packages/server-functions-plugin/src/index.ts — environment model, manifest and per-environment getServerFnById logic.
    • packages/directive-functions-plugin/src/compilers.ts & src/index.ts — changed signatures and option shapes threaded widely.
    • Cross-package changes: createSsrRpc addition, Vite entries, and dynamic virtual-module imports in router-manifest.ts.
    • Tests — ensure fixtures and expected outputs reflect new option shapes.

Possibly related PRs

Suggested reviewers

  • brenelz
  • birkskyum

Poem

🐰 A rabbit with a lint brush in paw,

threads a directive and hops past the law,
callers and provider now neatly align,
SSR RPCs glint on the export vine,
hop, compile, bundle — a fine little draw.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.14% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "fix: decouple server functions caller and provider" directly and accurately describes the primary architectural change throughout this changeset. The core refactoring restructures TanStackServerFnPluginOpts and DirectiveFunctionsVitePluginEnvOptions from 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 docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch server-fn-caller-provider

📜 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 06b687f and f549563.

📒 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)
  • packages/start-server-core/src/createSsrRpc.ts
⏰ 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

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Oct 31, 2025

View your CI Pipeline Execution ↗ for commit f549563

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:15 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 31, 2025

More templates

@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@5712

commit: f549563

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

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 string

We 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 replacers

isSourceFn is meant to distinguish source modules from provider split chunks, but !!opts.directiveSplitParam is always true because the param string is never empty. Provider-side compilations now masquerade as source calls, so replacer implementations that branch on isSourceFn will mis-handle split files. Please flip the flag to use !opts.isDirectiveSplitParam instead.

-        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 tsrStartManifest as 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.ts file:

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.ts file 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 943d616 and c57f012.

📒 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.ts
  • packages/react-start/vite.config.ts
  • packages/start-plugin-core/src/create-server-fn-plugin/plugin.ts
  • packages/start-server-core/src/virtual-modules.ts
  • packages/start-plugin-core/src/create-server-fn-plugin/handleCreateServerFn.ts
  • packages/start-plugin-core/src/create-server-fn-plugin/compiler.ts
  • packages/server-functions-plugin/src/index.ts
  • packages/start-server-core/src/createSsrRpc.ts
  • packages/solid-start/vite.config.ts
  • packages/react-start/src/ssr-rpc.ts
  • packages/start-server-core/src/router-manifest.ts
  • packages/directive-functions-plugin/src/compilers.ts
  • packages/start-server-core/vite.config.ts
  • packages/start-plugin-core/src/plugin.ts
  • packages/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.ts
  • packages/react-start/vite.config.ts
  • packages/start-plugin-core/src/create-server-fn-plugin/plugin.ts
  • packages/start-server-core/src/virtual-modules.ts
  • packages/start-server-core/package.json
  • packages/start-plugin-core/src/create-server-fn-plugin/handleCreateServerFn.ts
  • packages/start-plugin-core/src/create-server-fn-plugin/compiler.ts
  • packages/react-start/package.json
  • packages/start-server-core/src/createSsrRpc.ts
  • packages/solid-start/package.json
  • packages/solid-start/vite.config.ts
  • packages/react-start/src/ssr-rpc.ts
  • packages/start-server-core/src/router-manifest.ts
  • packages/start-server-core/vite.config.ts
  • packages/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.json
  • packages/react-start/package.json
  • packages/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.ts
  • 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-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 directories

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-plugin/** : Use unplugin for universal bundler plugins in the router-plugin package

Applied 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 in await import() calls at build time. Using await 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 handleCreateMiddleware is correctly designed without directive context. The function signature only accepts env parameter, and all transformations (removing validators and server calls on the client) are purely environment-based, not directive-dependent. The directive is correctly passed only to handleCreateServerFn, 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-core package properly exports ./createSsrRpc with both TypeScript types and default exports configured. The source file exists at packages/start-server-core/src/createSsrRpc.ts. No issues found.

Comment on lines 6 to 9
const fn = async (opts: any, signal: any): Promise<any> => {
const serverFn = await getServerFnById(functionId)
return serverFn(opts ?? {}, signal)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 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 keep signal optional; 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.

Suggested change
const fn = async (opts: any, signal: any): Promise<any> => {
const serverFn = await getServerFnById(functionId)
return serverFn(opts ?? {}, signal)
}
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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 splitImportFn and conditional behavior for split functions vs referenced functions, but the replacer code only shows createServerRpc(${JSON.stringify(opts.functionId)}, ${opts.fn}). If this conditional logic is handled elsewhere in the compiler (driven by the new isDirectiveSplitParam flag), 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 c57f012 and 06b687f.

📒 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.ts
  • packages/start-plugin-core/tests/createServerFn/createServerFn.test.ts
  • packages/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.ts
  • packages/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 the ServerFnCompiler constructor.

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 directiveSplitParam and isDirectiveSplitParam: false aligns with the refactored CompileDirectivesOpts interface. The false value is appropriate for client-side compilation.


31-40: LGTM! SSR configuration correctly updated.

The configuration changes mirror the client config appropriately, with isDirectiveSplitParam: false for 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.

@schiller-manuel schiller-manuel merged commit d995aa3 into main Oct 31, 2025
6 checks passed
@schiller-manuel schiller-manuel deleted the server-fn-caller-provider branch October 31, 2025 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants