Skip to content

Commit

Permalink
refactor: move getDefaultResolvedEnvironmentOptions to `baseEnviron…
Browse files Browse the repository at this point in the history
…ment.ts`
  • Loading branch information
sapphi-red committed Sep 30, 2024
1 parent f25a8de commit 30832ad
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
13 changes: 13 additions & 0 deletions packages/vite/src/node/baseEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ const environmentColors = [
colors.gray,
]

export function getDefaultResolvedEnvironmentOptions(
config: ResolvedConfig,
): ResolvedEnvironmentOptions {
return {
define: config.define,
resolve: config.resolve,
consumer: 'server',
webCompatible: false,
dev: config.dev,
build: config.build,
}
}

export class PartialEnvironment {
name: string
getTopLevelConfig(): ResolvedConfig {
Expand Down
6 changes: 4 additions & 2 deletions packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ import { completeSystemWrapPlugin } from './plugins/completeSystemWrap'
import { mergeConfig } from './publicUtils'
import { webWorkerPostPlugin } from './plugins/worker'
import { getHookHandler } from './plugins'
import { BaseEnvironment } from './baseEnvironment'
import {
BaseEnvironment,
getDefaultResolvedEnvironmentOptions,
} from './baseEnvironment'
import type { MinimalPluginContext, Plugin, PluginContext } from './plugin'
import type { RollupPluginHooks } from './typeUtils'
import { getDefaultResolvedEnvironmentOptions } from './server/environment'

export interface BuildEnvironmentOptions {
/**
Expand Down
18 changes: 4 additions & 14 deletions packages/vite/src/node/server/environment.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import type { FetchFunctionOptions, FetchResult } from 'vite/module-runner'
import type { FSWatcher } from 'dep-types/chokidar'
import colors from 'picocolors'
import { BaseEnvironment } from '../baseEnvironment'
import {
BaseEnvironment,
getDefaultResolvedEnvironmentOptions,
} from '../baseEnvironment'
import type {
EnvironmentOptions,
ResolvedConfig,
Expand Down Expand Up @@ -31,19 +34,6 @@ import {
import type { RemoteEnvironmentTransport } from './environmentTransport'
import { isWebSocketServer } from './ws'

export function getDefaultResolvedEnvironmentOptions(
config: ResolvedConfig,
): ResolvedEnvironmentOptions {
return {
define: config.define,
resolve: config.resolve,
consumer: 'server',
webCompatible: false,
dev: config.dev,
build: config.build,
}
}

export interface DevEnvironmentContext {
hot: false | HotChannel
options?: EnvironmentOptions
Expand Down

0 comments on commit 30832ad

Please sign in to comment.