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: resolvedUrls is null in plugin's configureServer after server restart #15450

Merged
merged 2 commits into from
Jan 10, 2024
Merged
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: 12 additions & 1 deletion packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,17 @@ export async function _createServer(
_shortcutsOptions: undefined,
}

// maintain consistency with the server instance after restarting.
const reflexServer = new Proxy(server, {
get: (_, property: keyof ViteDevServer) => {
return server[property]
},
set: (_, property: keyof ViteDevServer, value: never) => {
server[property] = value
return true
},
})

if (!middlewareMode) {
exitProcess = async () => {
try {
Expand Down Expand Up @@ -714,7 +725,7 @@ export async function _createServer(
// apply server configuration hooks from plugins
const postHooks: ((() => void) | void)[] = []
for (const hook of config.getSortedPluginHooks('configureServer')) {
postHooks.push(await hook(server))
postHooks.push(await hook(reflexServer))
}

// Internal middlewares ------------------------------------------------------
Expand Down