mirror of
https://github.com/vitejs/vite.git
synced 2024-11-21 22:59:10 +00:00
feat: improve Plugin option types
This commit is contained in:
parent
63de43a5cd
commit
21225c9fdf
@ -52,7 +52,13 @@ export type {
|
||||
DevEnvironmentOptions,
|
||||
ResolvedDevEnvironmentOptions,
|
||||
} from './config'
|
||||
export type { PluginOption } from './plugin'
|
||||
export type {
|
||||
EnvironmentPlugin,
|
||||
Plugin,
|
||||
EnvironmentPluginOptionArray,
|
||||
PluginOption,
|
||||
HookHandler,
|
||||
} from './plugin'
|
||||
export type { FilterPattern } from './utils'
|
||||
export type { CorsOptions, CorsOrigin, CommonServerOptions } from './http'
|
||||
export type {
|
||||
@ -96,7 +102,6 @@ export type {
|
||||
SSROptions,
|
||||
SSRTarget,
|
||||
} from './ssr'
|
||||
export type { EnvironmentPlugin, Plugin, HookHandler } from './plugin'
|
||||
export type {
|
||||
Logger,
|
||||
LogOptions,
|
||||
|
@ -310,7 +310,7 @@ export interface Plugin<A = any> extends EnvironmentPlugin<A> {
|
||||
*/
|
||||
environmentPlugins?: (
|
||||
environment: PluginEnvironment,
|
||||
) => PluginOption[] | undefined
|
||||
) => EnvironmentPluginOptionArray
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
@ -331,23 +331,18 @@ export type PluginWithRequiredHook<K extends keyof Plugin> = Plugin & {
|
||||
[P in K]: NonNullable<Plugin[P]>
|
||||
}
|
||||
|
||||
export type MaybeEnvironmentPlugin =
|
||||
| EnvironmentPlugin
|
||||
| false
|
||||
| null
|
||||
| undefined
|
||||
type Thenable<T> = T | Promise<T>
|
||||
type FalsyPlugin = false | null | undefined
|
||||
|
||||
export type EnvironmentPluginOption =
|
||||
| MaybeEnvironmentPlugin
|
||||
| EnvironmentPluginOption[]
|
||||
| Promise<MaybeEnvironmentPlugin | EnvironmentPluginOption[]>
|
||||
export type EnvironmentPluginOption = Thenable<
|
||||
EnvironmentPlugin | FalsyPlugin | EnvironmentPluginOption[]
|
||||
>
|
||||
|
||||
export type MaybePlugin = Plugin | false | null | undefined
|
||||
export type EnvironmentPluginOptionArray = Thenable<
|
||||
EnvironmentPluginOption[] | FalsyPlugin
|
||||
>
|
||||
|
||||
export type PluginOption =
|
||||
| MaybePlugin
|
||||
| PluginOption[]
|
||||
| Promise<MaybePlugin | PluginOption[]>
|
||||
export type PluginOption = Thenable<Plugin | FalsyPlugin | PluginOption[]>
|
||||
|
||||
export async function resolveEnvironmentPlugins(
|
||||
environment: PluginEnvironment,
|
||||
|
Loading…
Reference in New Issue
Block a user