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

feat: resolved createEnvironment #17791

Merged
merged 5 commits into from
Jul 30, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
chore: default dev environment has hot: false
  • Loading branch information
patak-dev committed Jul 30, 2024
commit 855c54943fb3cedf84febbcf396a8fb1984f3176
24 changes: 13 additions & 11 deletions packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export interface DevEnvironmentOptions {
// fs: { strict?: boolean, allow, deny }
}

function createDefaultClientDevEnvironment(
function defaultCreateClientDevEnvironment(
name: string,
config: ResolvedConfig,
context: CreateDevEnvironmentContext,
Expand All @@ -223,7 +223,7 @@ function createDefaultClientDevEnvironment(
})
}

function createDefaultSsrDevEnvironment(
function defaultCreateSsrDevEnvironment(
name: string,
config: ResolvedConfig,
): DevEnvironment {
Expand All @@ -232,14 +232,10 @@ function createDefaultSsrDevEnvironment(
})
}

function createDefaultDevEnvironment(
name: string,
config: ResolvedConfig,
context: CreateDevEnvironmentContext,
): DevEnvironment {
return config.environments[name].consumer === 'client'
? createDefaultClientDevEnvironment(name, config, context)
: createDefaultSsrDevEnvironment(name, config)
function defaultCreateDevEnvironment(name: string, config: ResolvedConfig) {
return new DevEnvironment(name, config, {
hot: false,
})
}

export type ResolvedDevEnvironmentOptions = Required<DevEnvironmentOptions>
Expand Down Expand Up @@ -630,7 +626,13 @@ export function resolveDevEnvironmentOptions(
preserverSymlinks,
environmentName,
),
createEnvironment: dev?.createEnvironment ?? createDefaultDevEnvironment,
createEnvironment:
dev?.createEnvironment ??
(environmentName === 'client'
? defaultCreateClientDevEnvironment
: environmentName === 'ssr'
? defaultCreateSsrDevEnvironment
: defaultCreateDevEnvironment),
recoverable: dev?.recoverable ?? environmentName === 'client',
moduleRunnerTransform:
dev?.moduleRunnerTransform ??
Expand Down