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

refactor!: remove non boolean middleware mode #14792

Merged
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
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