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

オープン 初心者向け
#532 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript, vite
領域
cli

調査の方向性

まず、バンドルされた autoconfig 内の TanStack Start のフレームワーククラスを見つけ、その supportsMode 設定を Vite と Astro のクラスと比較します。issue に記載された cf build のチェックを追います。提供された再現手順で cf build --mode production と cf dev --mode production を実行して動作を確認します。TanStack Start で両方が --mode を受け付ければ完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
TypeScript
スター
993
フォーク
65
平均マージ
21時間 51分
マージ済み PR(30日)
209

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

cloudflare/cf のほかの issue

cloudflare/cf の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。