voidzero-dev / voidzero-dev/vite-plus

Feat: add "definePackageConfig" and "defineRootConfig" to make type definition closer to actual work

オープン
#2,348 コメント 0 件 リアクション 2 件 担当者 0 名 GitHub で見る
pending triage
主要言語
Rust
スター
5.8k
フォーク
262
平均マージ
23時間 41分
マージ済み PR(30日)
138

説明

### Description

current, defineConfig type definition allow to write root only option(e.g. run.enablePrePostScripts) to package. but actually, it does not works. this problem is not good of developer experience.

### Suggested solution

Add "definePackageConfig" and "defineRootConfig" function. this will be exported by "vite-plus". "defineRootConfig" is just alias of "defineConfig" but "definePackageConfig" has new type definition.

### code example

```typescript
// workspace/packages/main/vite.config.ts
// this is package's config file.
import { definePackageConfig } from "vite-plus"

export default definePackageConfig({
run: {
enablePrePostScripts:true // happen type error because run.enablePrePostScripts is root only option
}
})
```

```typescript
// workspace/vite.config.ts
// this is root's config.
import { defineRootConfig } from "vite-plus"

export default defineRootConfig({
run: {
enablePrePostScripts:true // does not happen type error.
}
})
```

also, this is just coding rules. no one can stop to use "defineConfig" or "defineRootConfig" in package's vite.config.ts.
this proposal make "defineConfig" deprecated and recommend use new function.

### Alternative

Add more readable jsdoc e.g. "@root-only - this option does not work on package's config". but probably, developer will fail to notice.

### Additional context

_No response_

### 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.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、既存の defineConfig の型定義と vite-plus の export エントリポイントを特定します。root と package の設定型がどのように表現されているかを追跡し、次に defineRootConfig が root 専用のオプションを受け入れ、definePackageConfig がそれらを拒否することを確認します。また、defineConfig に対して提案されている非推奨化の案内も確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
developer-experience
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
58/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。