voidzero-dev / voidzero-dev/vite-plus

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

Open
#2,348 0 comments 2 reactions 0 assignees View on GitHub
pending triage
Dominant language
Rust
Stars
5.8k
Forks
261
Avg merge
1d 34m
Merged PRs (30d)
135

Description

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

Contributor guide

Open the contributing guide

Research direction

Start by locating the existing defineConfig type definition and the vite-plus export entry point. Trace how root and package configuration types are represented, then verify that defineRootConfig accepts root-only options while definePackageConfig rejects them; also check the proposed deprecation guidance for defineConfig.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.