Skip to content

Commit

Permalink
refactor!: remove non boolean middleware mode (#14792)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red authored Oct 30, 2023
1 parent 17fb5ee commit deb5515
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 22 deletions.
1 change: 1 addition & 0 deletions docs/guide/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))
- Default exports of CSS files (e.g `import style from './foo.css'`): Use the `?inline` query instead
- `import.meta.globEager`: Use `import.meta.glob('*', { eager: true })` instead
- `ssr.format: 'cjs'` and `legacy.buildSsrCjsExternalHeuristics` ([#13816](https://github.com/vitejs/vite/discussions/13816))
- `server.middlewareMode: 'ssr'` and `server.middlewareMode: 'html'`: Use [`appType`](/config/shared-options.md#apptype) + [`server.middlewareMode: true`](/config/server-options.md#server-middlewaremode) instead ([#8452](https://github.com/vitejs/vite/pull/8452))

## Advanced

Expand Down
24 changes: 3 additions & 21 deletions packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,6 @@ export async function resolveConfig(
const server = resolveServerOptions(resolvedRoot, config.server, logger)
const ssr = resolveSSROptions(config.ssr, resolveOptions.preserveSymlinks)

const middlewareMode = config?.server?.middlewareMode

const optimizeDeps = config.optimizeDeps || {}

const BASE_URL = resolvedBase
Expand Down Expand Up @@ -796,7 +794,7 @@ export async function resolveConfig(
},
},
worker: resolvedWorkerOptions,
appType: config.appType ?? (middlewareMode === 'ssr' ? 'custom' : 'spa'),
appType: config.appType ?? 'spa',
experimental: {
importGlobRestoreExtension: false,
hmrPartialAccept: false,
Expand Down Expand Up @@ -824,24 +822,6 @@ export async function resolveConfig(
.map((hook) => hook(resolved)),
)

// validate config

if (middlewareMode === 'ssr') {
logger.warn(
colors.yellow(
`Setting server.middlewareMode to 'ssr' is deprecated, set server.middlewareMode to \`true\`${
config.appType === 'custom' ? '' : ` and appType to 'custom'`
} instead`,
),
)
} else if (middlewareMode === 'html') {
logger.warn(
colors.yellow(
`Setting server.middlewareMode to 'html' is deprecated, set server.middlewareMode to \`true\` instead`,
),
)
}

debug?.(`using resolved config: %O`, {
...resolved,
plugins: resolved.plugins.map((p) => p.name),
Expand All @@ -851,6 +831,8 @@ export async function resolveConfig(
},
})

// validate config

if (config.build?.terserOptions && config.build.minify !== 'terser') {
logger.warn(
colors.yellow(
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export interface ServerOptions extends CommonServerOptions {
* Create Vite dev server to be used as a middleware in an existing server
* @default false
*/
middlewareMode?: boolean | 'html' | 'ssr'
middlewareMode?: boolean
/**
* Options for files served via '/\@fs/'.
*/
Expand Down

0 comments on commit deb5515

Please sign in to comment.