From 84a462ce6e63b7134e5c15eb0c6ebc7ccc4cce36 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Mon, 15 Aug 2022 17:33:45 +0200 Subject: [PATCH] fix(vite): warmup server entries with `ssr` condition --- packages/vite/src/utils/warmup.ts | 5 +++-- packages/vite/src/vite.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/vite/src/utils/warmup.ts b/packages/vite/src/utils/warmup.ts index 6fd4bf79914..d7458e66ea9 100644 --- a/packages/vite/src/utils/warmup.ts +++ b/packages/vite/src/utils/warmup.ts @@ -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() @@ -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) } diff --git a/packages/vite/src/vite.ts b/packages/vite/src/vite.ts index d4d3ca8c22f..619c56b8219 100644 --- a/packages/vite/src/vite.ts +++ b/packages/vite/src/vite.ts @@ -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) })