Skip to content

Commit

Permalink
fix: resovedUrls is null after server restart
Browse files Browse the repository at this point in the history
  • Loading branch information
XiSenao committed Dec 28, 2023
1 parent 56ae92c commit f9e4cfe
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,9 @@ export async function _createServer(

const devHtmlTransformFn = createDevHtmlTransformFn(config)

let server: ViteDevServer = {
let server = {} as ViteDevServer

let initServerParameters: ViteDevServer = {
config,
middlewares,
httpServer,
Expand Down Expand Up @@ -611,7 +613,7 @@ export async function _createServer(
_setInternalServer(_server: ViteDevServer) {
// Rebind internal the server variable so functions reference the user
// server instance after a restart
server = _server
initServerParameters = _server
},
_restartPromise: null,
_importGlobMap: new Map(),
Expand All @@ -621,6 +623,16 @@ export async function _createServer(
_shortcutsOptions: undefined,
}

server = new Proxy(initServerParameters, {
get: (_, property: keyof ViteDevServer) => {
return initServerParameters[property]
},
set: (_, property: keyof ViteDevServer, value: never) => {
initServerParameters[property] = value
return true
},
})

if (!middlewareMode) {
exitProcess = async () => {
try {
Expand Down Expand Up @@ -842,7 +854,7 @@ export async function _createServer(
await initServer()
}

return server
return initServerParameters
}

async function startServer(
Expand Down

0 comments on commit f9e4cfe

Please sign in to comment.