Skip to content

Commit

Permalink
fix: server.force deprecation and force on restart API (#8842)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev authored Jun 29, 2022
1 parent 7257fd8 commit c94f564
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
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

0 comments on commit c94f564

Please sign in to comment.