voidzero-dev / voidzero-dev/vite-plus

Support pnpm catalog

Đang mở
#1,835 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
Rust
Star
5.8k
Fork
262
Merge trung bình
23 giờ 18 phút
Pull request đã merge (30 ngày)
139

Mô tả

### Description

In current Vite+, when running `vp add vue` with [pnpm catalogs](https://pnpm.io/catalogs) configured in `pnpm-workspace.yaml`, it totally ignores the catalog and add the package with it version directly in `package.json`.

Since pnpm catalogs feature provide a lot of benefit for packages management (Anthony Fu wrote a [blog](https://antfu.me/posts/categorize-deps) about it), it will be great if VIte+ does support it.

### Suggested solution

- This feature can be toggle by a config in `vite.config.ts`: `pnpm.catalog: boolean` or an env var like `VP_CATALOG=boolean`.

- When running `vp add` and Vite+ detects a workspace that use pnpm catalog: instead of adding packages with pinned versions, it writes `catalog:` references into `package.json` and updates the workspace catalog:

```bash
# Given pnpm-workspace.yaml with:
# catalogs:
# prod:
# react: ^18.3.0

vp add react
# → detects react in "prod" catalog
# → writes "react": "catalog:prod" to package.json
# → runs vp install

vp add lodash
# → lodash not in any catalog
# → prompts to select a catalog (or skip)
# → fetches latest version, updates pnpm-workspace.yaml
# → writes "lodash": "catalog:prod" to package.json
# → runs vp install
```

### Alternative

_No response_

### Additional context

This feature is inspired by [`ni`](https://github.com/antfu-collective/ni)

### Validations

- [x] Read the [Contributing Guidelines](https://github.com/voidzero-dev/vite-plus/blob/main/CONTRIBUTING.md).
- [x] Confirm this request is for Vite+ itself and not for Vite, Vitest, tsdown, Rolldown, or Oxc.
- [x] Check that there isn't already an issue requesting the same feature.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng cách xác định lệnh `vp add` và cách lệnh này xử lý `package.json` và `pnpm-workspace.yaml`. Theo dõi cách các mục trong catalog được phát hiện, chọn và cập nhật, sau đó kiểm tra các tham chiếu `catalog:` được yêu cầu cũng như hành vi cài đặt đối với cả các dependency hiện có và dependency mới.

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

Đánh giá

Lĩnh vực
cli, tooling
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
42/100

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.