You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于Relay的Tanstack Start部署Cloudflare Workers时出现函数错误

Tanstack Start + Relay 部署后页面报错:Sr is not a function/vo is not a function

编辑于9月26日:目前暂时改用Netlify,或许Tanstack Start的新版本RC能解决问题。

执行vite build构建成功,但打开任意页面均报错:旧版Tanstack Start提示Sr is not a function,最新版提示vo is not a function。

相关配置文件

relay.config.js

{
    "src": "./",
    "language": "typescript",
    "schema": "./src/graphql/schema.graphql",
    "excludes": ["./node_modules/**", "**/__mocks__/**", "**/__generated__/**"],
    "artifactDirectory": "./src/graphql/__generated__",
    "eagerEsModules": true
}

tsconfig.json

{
  "include": ["**/*.ts", "**/*.tsx"],
  "exclude": ["node_modules"],
  "compilerOptions": {
    "strict": true,
    "strictNullChecks": true,
    "esModuleInterop": true,
    "jsx": "react-jsx",
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "lib": ["DOM", "DOM.Iterable", "ES2022"],
    "isolatedModules": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "target": "ES2022",
    "allowJs": false,
    "incremental": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "baseUrl": ".",
    "paths": {
      "~/lib/*": ["./src/lib/*"],
      "~/gql-gen/*": ["./src/graphql/__generated__/*"],
      "~/gql/*": ["./src/graphql/*"],
      "~/*": ["./src/*"]
    }
  }
}

vite.config.js

import tailwindcss from "@tailwindcss/vite";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
import { defineConfig } from "vite";
import relay from "vite-plugin-relay-lite";
import tsConfigPaths from "vite-tsconfig-paths";

export default defineConfig({
  server: {
    strictPort: true,
  },
  plugins: [
    relay(),
    tsConfigPaths({
      projects: ["./tsconfig.json"],
    }),
    tanstackStart({
      target: "cloudflare-module",
    }),
    tailwindcss(),
  ],
});

wrangler.jsonc

{
    "$schema": "./node_modules/wrangler/config-schema.json",
    "name": "project-name",
    "main": "./.output/server/index.mjs",
    "compatibility_date": "2025-09-01",
    "compatibility_flags": ["nodejs_compat"],
    "assets": {
        "binding": "ASSETS",
        "directory": ".output/public"
    },
    "observability": {
        "enabled": true
    }
}

错误栈信息

{
    cause: TypeError: Sr is not a function
        at .output/server/chunks/_/ssr.mjs  (file:///.../client/web/.output/server/chunks/_/ssr.mjs:1:303687)
        at __init  (file:///.../client/web/.wrangler/tmp/dev-CVdYDF/index.js:5:59)
        at null.<anonymous>  (file:///.../client/web/.output/server/chunks/nitro/nitro.mjs:1:73890)
        at async Object.handler  (file:///.../client/web/.output/server/chunks/nitro/nitro.mjs:1:34660)
        at null.<anonymous> (async  file:///.../client/web/.wrangler/tmp/dev-CVdYDF/index.js:31616:7)
        at async b  (file:///.../client/web/.output/server/chunks/nitro/nitro.mjs:1:22792)
        at null.<anonymous> (async  file:///.../client/web/.wrangler/tmp/dev-CVdYDF/index.js:33695:22)
        at async jsonError  (file:///.../client/web/node_modules/.pnpm/wrangler@4.33.1/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts:22:10)
        at async drainBody  (file:///.../client/web/node_modules/.pnpm/wrangler@4.33.1/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts:5:10),
    statusCode: 500,
    fatal: false,
    unhandled: true,
    statusMessage: undefined,
    data: undefined
}

[wrangler:info] GET / 500 Server Error (90ms)
[wrangler:info] GET /favicon.ico 500 Server Error (3ms)

生成文件中的异常代码片段

function _interopRequireDefault$V(e){   return e&&e.__esModule?e:{default:e}}

Sr=_interopRequireDefault$V.default

已尝试的解决方案

  • 开启SPA模式完全禁用SSR,无效;
  • 更换babel与Relay相关插件,无效;
  • 安装@babel/runtime,无效。

现寻求解决该部署错误的有效方案。


内容的提问来源于stack exchange,提问作者Miguel Merheb

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 10:17:04