vite:monorepo template declares catalog entries that no workspace package uses

未關閉 適合新手
#3,381 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
76/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
typescript
領域
build-system

研究方向

從 packages/cli/templates/monorepo/pnpm-workspace.yaml 著手,將其中的 catalog 項目與產生的套件清單進行比較,特別是 packages/utils/package.json 和 apps/website/package.json。檢查 monorepo 範本的產生或驗證測試,並在決定範本應使用 catalog: 參照還是移除未使用的項目後,執行相關測試。完成標準是產生的 catalog 項目有被使用且版本一致,或不存在未使用的項目。

由索引模型根據 Issue 內容生成。

描述

bug
Describe the bug

A project created with vp create vite:monorepo declares two pnpm catalog entries that no workspace package uses, and one of them does not match the version the packages actually pin.

The template's pnpm-workspace.yaml (packages/cli/templates/monorepo/pnpm-workspace.yaml) sets catalogMode: prefer and declares:

catalog:
  "@types/node": ^24
  typescript: ^7.0.0

The generated workspace packages do not reference these entries with catalog:. They pin direct ranges instead:

packages/utils/package.json   "@types/node": "^26.6.5", "typescript": "^7.0.2"
apps/website/package.json     "typescript": "^7.0.2"

What I expect: the generated packages use "typescript": "catalog:" and "@types/node": "catalog:", so the catalog is the single source of the versions, or the template leaves out catalog entries that are not used. The @types/node range should also agree between the catalog (^24) and the package (^26.6.5).

What happens: the catalog entries are dead, and a dead-code checker such as Knip reports them on a new project. vp check passes, so nothing inside Vite+ points this out.

Related: #1835 is about vp add writing catalog: references. This report is about the manifests the template itself generates.

Reproduction

No separate repository: the bug reproduces with the single vp create command under "Steps to reproduce", on a clean directory.

Steps to reproduce
vp create vite:monorepo --directory repro --no-interactive --git --package-manager pnpm
cd repro
grep -n "catalog" pnpm-workspace.yaml
grep -rn '"typescript"\|"@types/node"' apps/*/package.json packages/*/package.json
pnpm dlx [email protected]

Knip prints:

Unused catalog entries (2)
@types/node  default  pnpm-workspace.yaml:9:4
typescript   default  pnpm-workspace.yaml:10:3
System Info
$ vp env current
Node.js:
  Version    26.13.0
  Source     engines.node
  Installed  true
  Mode       managed

Package Manager:
  Name       pnpm
  Version    12.18.0
  Source     devEngines.packageManager
  Installed  true
  Mode       managed

$ vp --version
vp v1.5.0

Local vite-plus:
  vite-plus  v1.5.0

Tools:
  vite             v8.3.5
  rolldown         v1.2.16
  vitest           v5.1.0
  oxfmt            v0.76.0
  oxlint           v1.91.0
  oxlint-tsgolint  v7.0.2005
  tsdown           v0.23.4

The vp --version output is from the project's local vp (1.5.0); vp env current ran through the global binary (1.2.0), because the local one refuses env. Binary paths are removed.

Used Package Manager

pnpm

Logs

Not needed; the steps above reproduce it without any error output.

Validations
主要語言
TypeScript
星號
6.6k
分支
303
平均合併
1 天 4 小時
30 天內合併 PR
224

環境準備

在 Codespaces 中開啟

在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

voidzero-dev/vite-plus 的其他 Issue

查看 voidzero-dev/vite-plus 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。