voidzero-dev / voidzero-dev/vite-plus
Feat: add "definePackageConfig" and "defineRootConfig" to make type definition closer to actual work
- Lenguaje dominante
- Rust
- Estrellas
- 5.8k
- Forks
- 262
- Merge medio
- 23 h 41 min
- PR fusionados (30 d)
- 138
Descripción
### 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.
Guía de contribución
Línea de trabajo
Comienza localizando la definición de tipo existente de defineConfig y el punto de entrada de exportación de vite-plus. Sigue cómo se representan los tipos de configuración de root y de paquete y, después, verifica que defineRootConfig acepte opciones exclusivas de root, mientras que definePackageConfig las rechace; comprueba también las indicaciones propuestas sobre la deprecación de defineConfig.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- developer-experience
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 58/100