voidzero-dev / voidzero-dev/vite-plus
Support pnpm catalog
- 主要言語
- Rust
- スター
- 5.8k
- フォーク
- 262
- 平均マージ
- 23時間 41分
- マージ済み PR(30日)
- 138
説明
### 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.
コントリビューションガイド
調査の方向性
まず `vp add` コマンドと、`package.json` および `pnpm-workspace.yaml` の処理箇所を特定します。カタログエントリがどのように検出、選択、更新されるかを追跡し、要求された `catalog:` 参照と、既存および新規の依存関係に対するインストール動作を確認します。
索引モデルが issue の本文から書いたものです。
評価
- 領域
- cli, tooling
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100