mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-31 07:40:33 +00:00
fix(vite): include more of warmup within try/catch (#24072)
This commit is contained in:
parent
ec317befc0
commit
dc04f28cff
@ -36,6 +36,7 @@ export async function warmupViteServer (
|
|||||||
const warmedUrls = new Set<String>()
|
const warmedUrls = new Set<String>()
|
||||||
|
|
||||||
const warmup = async (url: string) => {
|
const warmup = async (url: string) => {
|
||||||
|
try {
|
||||||
url = normaliseURL(url, server.config.base)
|
url = normaliseURL(url, server.config.base)
|
||||||
|
|
||||||
if (warmedUrls.has(url)) { return }
|
if (warmedUrls.has(url)) { return }
|
||||||
@ -45,18 +46,21 @@ export async function warmupViteServer (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
warmedUrls.add(url)
|
warmedUrls.add(url)
|
||||||
try {
|
|
||||||
await server.transformRequest(url, { ssr: isServer })
|
await server.transformRequest(url, { ssr: isServer })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.debug('Warmup for %s failed with: %s', url, e)
|
logger.debug('[nuxt] warmup for %s failed with: %s', url, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't warmup CSS file dependencies as they have already all been loaded to produce result
|
// Don't warmup CSS file dependencies as they have already all been loaded to produce result
|
||||||
if (isCSSRequest(url)) { return }
|
if (isCSSRequest(url)) { return }
|
||||||
|
|
||||||
|
try {
|
||||||
const mod = await server.moduleGraph.getModuleByUrl(url, isServer)
|
const mod = await server.moduleGraph.getModuleByUrl(url, isServer)
|
||||||
const deps = mod?.ssrTransformResult?.deps /* server */ || Array.from(mod?.importedModules /* client */ || []).map(m => m.url)
|
const deps = mod?.ssrTransformResult?.deps /* server */ || Array.from(mod?.importedModules /* client */ || []).map(m => m.url)
|
||||||
await Promise.all(deps.map(m => warmup(m)))
|
await Promise.all(deps.map(m => warmup(m)))
|
||||||
|
} catch (e) {
|
||||||
|
logger.debug('[warmup] tracking dependencies for %s failed with: %s', url, e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all(entries.map(entry => warmup(fileToUrl(entry, server.config.root))))
|
await Promise.all(entries.map(entry => warmup(fileToUrl(entry, server.config.root))))
|
||||||
|
Loading…
Reference in New Issue
Block a user