Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change ResolvedConfig type to interface to allow extending it #19210

Merged
merged 3 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/vite/rollup.dts.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ const identifierReplacements: Record<string, Record<string, string>> = {
Plugin$1: 'rollup.Plugin',
PluginContext$1: 'rollup.PluginContext',
TransformPluginContext$1: 'rollup.TransformPluginContext',
TransformResult$2: 'rollup.TransformResult',
TransformResult$1: 'rollup.TransformResult',
},
esbuild: {
TransformResult$1: 'esbuild_TransformResult',
TransformResult$2: 'esbuild_TransformResult',
TransformOptions$1: 'esbuild_TransformOptions',
BuildOptions$1: 'esbuild_BuildOptions',
},
Expand Down
161 changes: 81 additions & 80 deletions packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,86 +549,87 @@ export interface InlineConfig extends UserConfig {
envFile?: false
}

export type ResolvedConfig = Readonly<
Omit<
UserConfig,
| 'plugins'
| 'css'
| 'json'
| 'assetsInclude'
| 'optimizeDeps'
| 'worker'
| 'build'
| 'dev'
| 'environments'
| 'server'
| 'preview'
> & {
configFile: string | undefined
configFileDependencies: string[]
inlineConfig: InlineConfig
root: string
base: string
/** @internal */
decodedBase: string
/** @internal */
rawBase: string
publicDir: string
cacheDir: string
command: 'build' | 'serve'
mode: string
isWorker: boolean
// in nested worker bundle to find the main config
/** @internal */
mainConfig: ResolvedConfig | null
/** @internal list of bundle entry id. used to detect recursive worker bundle. */
bundleChain: string[]
isProduction: boolean
envDir: string
env: Record<string, any>
resolve: Required<ResolveOptions> & {
alias: Alias[]
}
plugins: readonly Plugin[]
css: ResolvedCSSOptions
json: Required<JsonOptions>
esbuild: ESBuildOptions | false
server: ResolvedServerOptions
dev: ResolvedDevEnvironmentOptions
/** @experimental */
builder: ResolvedBuilderOptions | undefined
build: ResolvedBuildOptions
preview: ResolvedPreviewOptions
ssr: ResolvedSSROptions
assetsInclude: (file: string) => boolean
logger: Logger
createResolver: (options?: Partial<InternalResolveOptions>) => ResolveFn
optimizeDeps: DepOptimizationOptions
/** @internal */
packageCache: PackageCache
worker: ResolvedWorkerOptions
appType: AppType
experimental: ExperimentalOptions
environments: Record<string, ResolvedEnvironmentOptions>
/**
* The token to connect to the WebSocket server from browsers.
*
* We recommend using `import.meta.hot` rather than connecting
* to the WebSocket server directly.
* If you have a usecase that requires connecting to the WebSocket
* server, please create an issue so that we can discuss.
*
* @deprecated
*/
webSocketToken: string
/** @internal */
fsDenyGlob: AnymatchFn
/** @internal */
safeModulePaths: Set<string>
/** @internal */
additionalAllowedHosts: string[]
} & PluginHookUtils
>
export interface ResolvedConfig
extends Readonly<
Omit<
UserConfig,
| 'plugins'
| 'css'
| 'json'
| 'assetsInclude'
| 'optimizeDeps'
| 'worker'
| 'build'
| 'dev'
| 'environments'
| 'server'
| 'preview'
> & {
configFile: string | undefined
configFileDependencies: string[]
inlineConfig: InlineConfig
root: string
base: string
/** @internal */
decodedBase: string
/** @internal */
rawBase: string
publicDir: string
cacheDir: string
command: 'build' | 'serve'
mode: string
isWorker: boolean
// in nested worker bundle to find the main config
/** @internal */
mainConfig: ResolvedConfig | null
/** @internal list of bundle entry id. used to detect recursive worker bundle. */
bundleChain: string[]
isProduction: boolean
envDir: string
env: Record<string, any>
resolve: Required<ResolveOptions> & {
alias: Alias[]
}
plugins: readonly Plugin[]
css: ResolvedCSSOptions
json: Required<JsonOptions>
esbuild: ESBuildOptions | false
server: ResolvedServerOptions
dev: ResolvedDevEnvironmentOptions
/** @experimental */
builder: ResolvedBuilderOptions | undefined
build: ResolvedBuildOptions
preview: ResolvedPreviewOptions
ssr: ResolvedSSROptions
assetsInclude: (file: string) => boolean
logger: Logger
createResolver: (options?: Partial<InternalResolveOptions>) => ResolveFn
optimizeDeps: DepOptimizationOptions
/** @internal */
packageCache: PackageCache
worker: ResolvedWorkerOptions
appType: AppType
experimental: ExperimentalOptions
environments: Record<string, ResolvedEnvironmentOptions>
/**
* The token to connect to the WebSocket server from browsers.
*
* We recommend using `import.meta.hot` rather than connecting
* to the WebSocket server directly.
* If you have a usecase that requires connecting to the WebSocket
* server, please create an issue so that we can discuss.
*
* @deprecated
*/
webSocketToken: string
/** @internal */
fsDenyGlob: AnymatchFn
/** @internal */
safeModulePaths: Set<string>
/** @internal */
additionalAllowedHosts: string[]
} & PluginHookUtils
> {}

// inferred ones are omitted
export const configDefaults = Object.freeze({
Expand Down
Loading