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: server.force deprecation and force on restart API #8842

Merged
merged 2 commits into from
Jun 29, 2022
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
13 changes: 13 additions & 0 deletions packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,19 @@ export async function resolveConfig(
)
}

if (
config.server?.force &&
!isBuild &&
config.optimizeDeps?.force === undefined
) {
resolved.optimizeDeps.force = true
logger.warn(
colors.yellow(
`server.force is deprecated, use optimizeDeps.force instead`
)
)
}

if (resolved.legacy?.buildRollupPluginCommonjs) {
const optimizerDisabled = resolved.optimizeDeps.disabled
if (!optimizerDisabled) {
Expand Down
9 changes: 8 additions & 1 deletion packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ export interface ServerOptions extends CommonServerOptions {
* @default true
*/
preTransformRequests?: boolean
/**
* Force dep pre-optimization regardless of whether deps have changed.
*
* @deprecated Use optimizeDeps.force instead, this option may be removed
* in a future minor version without following semver
*/
force?: boolean
}

export interface ResolvedServerOptions extends ServerOptions {
Expand Down Expand Up @@ -697,7 +704,7 @@ async function restartServer(server: ViteDevServer) {
let inlineConfig = server.config.inlineConfig
if (server._forceOptimizeOnRestart) {
inlineConfig = mergeConfig(inlineConfig, {
server: {
optimizeDeps: {
force: true
}
})
Expand Down