Skip to content

Commit

Permalink
fix: change ResolvedConfig type to interface to allow extending it (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lazuee authored Jan 23, 2025
1 parent d0c3523 commit bc851e3
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 82 deletions.
4 changes: 2 additions & 2 deletions packages/vite/rollup.dts.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ const identifierReplacements: Record<string, Record<string, string>> = {
PluginContext$1: 'rollup.PluginContext',
MinimalPluginContext$1: 'rollup.MinimalPluginContext',
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

0 comments on commit bc851e3

Please sign in to comment.