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 摘要。