cf build/dev --mode fails for TanStack Start even though the detected command is vite build/dev (1.0.0-beta.28)

Đang mở Phù hợp với người mới
#532 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript, vite
Lĩnh vực
cli

Hướng nghiên cứu

Bắt đầu bằng cách tìm lớp framework TanStack Start trong autoconfig được đóng gói và so sánh thiết lập supportsMode của lớp này với các lớp Vite và Astro; lần theo bước kiểm tra cf build được mô tả trong issue. Xác nhận hành vi bằng ví dụ tái hiện được cung cấp với cf build --mode production và cf dev --mode production; hoàn tất khi cả hai đều chấp nhận --mode cho TanStack Start.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

What happened

In a TanStack Start project, cf build --mode <name> and cf dev --mode <name> both fail before anything runs:

$ cf build --mode production
┌ Error
│ The detected command `bunx vite build` does not currently support `--mode`.
└

$ cf dev --mode production
┌ Error
│ The detected command `bunx vite dev` does not currently support `--mode`.
└

(With npm the command is shown as npx vite build.)

The detected command is plain vite build / vite dev, and Vite accepts --mode. The same project without @tanstack/react-start installed works: cf build --mode production delegates to vite build "--mode" "production" and succeeds.

Minimal reproduction
mkdir cf-mode-repro && cd cf-mode-repro
cat > package.json <<'JSON'
{ "name": "cf-mode-repro", "private": true, "type": "module",
  "devDependencies": { "vite": "8.3.6", "@cloudflare/vite-plugin": "2.0.0-beta.v.12", "cf": "1.0.0-beta.28" } }
JSON
cat > vite.config.ts <<'TS'
import { defineConfig } from "vite";
import { cloudflare } from "@cloudflare/vite-plugin";
export default defineConfig({ plugins: [cloudflare()] });
TS
mkdir src && echo 'export default { fetch() { return new Response("ok") } }' > src/index.ts
cat > cloudflare.config.ts <<'TS'
import { defineConfig } from "cf/config";
export default defineConfig({ worker: { name: "cf-mode-repro", entrypoint: "./src/index.ts", compatibilityDate: "2026-11-01" } });
TS
bun install
cf build --mode production      # works: "Delegating to bunx vite build "--mode" "production""

bun add -d @tanstack/[email protected] react@19 react-dom@19
cf build --mode production      # fails: "does not currently support `--mode`"
cf dev --mode production        # fails the same way
Likely cause

In the bundled autoconfig, the Vite and Astro framework classes set supportsMode = true, but the TanStack Start class extends the base Framework class (supportsMode = false). Its configuration still reports buildTool: "vite", and the build and dev commands are <pm> vite build / <pm> vite dev. cf build then throws on if (buildCommand && mode && !framework.supportsMode).

Setting supportsMode = true for TanStack Start (or deriving it from buildTool === "vite") should fix it.

Why it matters

defineConfig(({ mode }) => …) can't branch on mode for TanStack Start projects through cf. That rules out a staging or preview Worker. Our workaround is to call vite build --mode <name> directly and skip cf build.

Environment
  • cf 1.0.0-beta.28, @cloudflare/vite-plugin 2.0.0-beta.v.12, @tanstack/react-start 1.169.4, Vite 8.3.6
  • macOS (arm64), Node 26.13, Bun 1.4.4. Also reproduced with npm (no lockfile, monorepo workspace).
Related

#45 covers the same error for Nuxt and Next.js, which don't build through Vite. This one is narrower: TanStack Start already builds through vite, so only the supportsMode flag is missing.

Ngôn ngữ chính
TypeScript
Star
993
Fork
65
Merge trung bình
21 giờ 51 phút
Pull request đã merge (30 ngày)
209

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của cloudflare/cf

Tất cả issue của cloudflare/cf

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.