Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

fix(vite): warmup server entries with ssr condition #6649

Merged
merged 2 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions packages/vite/src/utils/warmup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import type { ViteDevServer } from 'vite'

export async function warmupViteServer (
server: ViteDevServer,
entries: string[]
entries: string[],
isServer: boolean
) {
const warmedUrls = new Set<String>()

Expand All @@ -13,7 +14,7 @@ export async function warmupViteServer (
}
warmedUrls.add(url)
try {
await server.transformRequest(url)
await server.transformRequest(url, { ssr: isServer })
} catch (e) {
logger.debug('Warmup for %s failed with: %s', url, e)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export async function bundle (nuxt: Nuxt) {
})

const start = Date.now()
warmupViteServer(server, [join('/@fs/', ctx.entry)])
warmupViteServer(server, [join('/@fs/', ctx.entry)], env.isServer)
.then(() => logger.info(`Vite ${env.isClient ? 'client' : 'server'} warmed up in ${Date.now() - start}ms`))
.catch(logger.error)
})
Expand Down