Skip to content

server function transformation plugin should exclude node_modules #6270

@jasongitmail

Description

@jasongitmail

Which project does this relate to?

Start

Describe the bug

When using @cloudflare/vite-plugin instead of target: "cloudflare-module", the SSR build fails with:

[tanstack-start-core::server-fn:ssr] 'return' outside of function at position XXXXXX

The [tanstack-start-core::server-fn:ssr] transformation is parsing third-party library code in node_modules that it doesn't parse when using target: "cloudflare-module". The parser encounters JavaScript patterns it can't handle.

Suggested fix: The server function transformation plugin should exclude node_modules from processing, since server functions are defined in user code, not libraries. But to still allow any tanstack packages from node_modules to be transformed:

See PR #6285

Your Example Website or App

https://github.com/jasongitmail/tanstack-xlsx-repro

Steps to Reproduce the Bug or Issue

git clone https://github.com/jasongitmail/tanstack-xlsx-repro.git
cd tanstack-xlsx-repro
bun install

See steps in README.

Expected behavior

SSR build should succeed with @cloudflare/vite-plugin, matching the behavior of target: "cloudflare-module".

Screenshots or Videos

No response

Platform

    "@tanstack/react-query": "5.83.0",
    "@tanstack/react-router": "1.144.0",
    "@tanstack/react-router-devtools": "^1.144.0",
    "@tanstack/react-router-with-query": "1.130.17",
    "@tanstack/react-start": "1.145.3",
    "@tanstack/router-core": "1.144.0",
    "@tanstack/router-devtools-core": "^1.144.0",
    "@tanstack/router-generator": "1.145.2",
    "@tanstack/router-plugin": "1.145.2",

    "@vitejs/plugin-react": "^4.6.0",
    "@vitejs/plugin-react-oxc": "^0.2.3",
    "vite": "^7.0.4",
    "vite-env-only": "^3.0.3",
    "vite-tsconfig-paths": "^5.1.4",

Mac 26.1

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions