Skip to content

Commit 477921b

Browse files
committed
refactor: use environment.warmupRequest for server.warmupRequest
1 parent 27a192f commit 477921b

File tree

1 file changed

+5
-26
lines changed

1 file changed

+5
-26
lines changed

packages/vite/src/node/server/index.ts

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import { ssrTransform } from '../ssr/ssrTransform'
4545
import { reloadOnTsconfigChange } from '../plugins/esbuild'
4646
import { bindCLIShortcuts } from '../shortcuts'
4747
import type { BindCLIShortcutsOptions } from '../shortcuts'
48-
import { ERR_OUTDATED_OPTIMIZED_DEP } from '../../shared/constants'
4948
import {
5049
CLIENT_DIR,
5150
DEFAULT_DEV_PORT,
@@ -67,7 +66,6 @@ import type { MinimalPluginContextWithoutEnvironment } from '../plugin'
6766
import type { PluginContainer } from './pluginContainer'
6867
import {
6968
BasicMinimalPluginContext,
70-
ERR_CLOSED_SERVER,
7169
basePluginContextMeta,
7270
createPluginContainer,
7371
} from './pluginContainer'
@@ -93,12 +91,11 @@ import { timeMiddleware } from './middlewares/time'
9391
import { ModuleGraph } from './mixedModuleGraph'
9492
import type { ModuleNode } from './mixedModuleGraph'
9593
import { notFoundMiddleware } from './middlewares/notFound'
96-
import { buildErrorMessage, errorMiddleware } from './middlewares/error'
94+
import { errorMiddleware } from './middlewares/error'
9795
import type { HmrOptions, NormalizedHotChannel } from './hmr'
9896
import { handleHMRUpdate, updateModules } from './hmr'
9997
import { openBrowser as _openBrowser } from './openBrowser'
10098
import type { TransformOptions, TransformResult } from './transformRequest'
101-
import { transformRequest } from './transformRequest'
10299
import { searchForPackageRoot, searchForWorkspaceRoot } from './searchRoot'
103100
import type { DevEnvironment } from './environment'
104101
import { hostValidationMiddleware } from './middlewares/hostCheck'
@@ -606,29 +603,11 @@ export async function _createServer(
606603
'server.transformRequest() is deprecated. Use environment.transformRequest() instead.',
607604
)
608605
const environment = server.environments[options?.ssr ? 'ssr' : 'client']
609-
return transformRequest(environment, url, options)
606+
return environment.transformRequest(url)
610607
},
611-
async warmupRequest(url, options) {
612-
try {
613-
const environment = server.environments[options?.ssr ? 'ssr' : 'client']
614-
await transformRequest(environment, url, options)
615-
} catch (e) {
616-
if (
617-
e?.code === ERR_OUTDATED_OPTIMIZED_DEP ||
618-
e?.code === ERR_CLOSED_SERVER
619-
) {
620-
// these are expected errors
621-
return
622-
}
623-
// Unexpected error, log the issue but avoid an unhandled exception
624-
server.config.logger.error(
625-
buildErrorMessage(e, [`Pre-transform error: ${e.message}`], false),
626-
{
627-
error: e,
628-
timestamp: true,
629-
},
630-
)
631-
}
608+
warmupRequest(url, options) {
609+
const environment = server.environments[options?.ssr ? 'ssr' : 'client']
610+
return environment.warmupRequest(url)
632611
},
633612
transformIndexHtml(url, html, originalUrl) {
634613
return devHtmlTransformFn(server, url, html, originalUrl)

0 commit comments

Comments
 (0)