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

Đang mở Phù hợp với người mới
#3,381 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
76/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
Lĩnh vực
build-system

Hướng nghiên cứu

Bắt đầu với packages/cli/templates/monorepo/pnpm-workspace.yaml và so sánh các mục trong catalog của nó với các manifest gói được tạo, đặc biệt là packages/utils/package.json và apps/website/package.json. Kiểm tra các bài kiểm thử tạo hoặc xác thực của template monorepo và chạy bài kiểm thử phù hợp sau khi quyết định template nên dùng các tham chiếu catalog: hay xóa các mục không được dùng. Công việc hoàn tất khi các mục catalog được tạo ra được sử dụng và phiên bản của chúng khớp nhau, hoặc không còn mục nào không được dùng.

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

Mô tả

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
Ngôn ngữ chính
TypeScript
Star
6.6k
Fork
303
Merge trung bình
1 ngày 4 giờ
Pull request đã merge (30 ngày)
224

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

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

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 voidzero-dev/vite-plus

Tất cả issue của voidzero-dev/vite-plus

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.