fix(vite): skip warming up node builtins (#24162)

This commit is contained in:
Daniel Roe 2023-11-07 11:41:24 +00:00 committed by GitHub
parent 9a7e8b8e68
commit dfff6f13c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,4 @@
import { isBuiltin } from 'node:module'
import { logger } from '@nuxt/kit' import { logger } from '@nuxt/kit'
import { join, normalize, relative } from 'pathe' import { join, normalize, relative } from 'pathe'
import { withoutBase } from 'ufo' import { withoutBase } from 'ufo'
@ -39,7 +40,7 @@ export async function warmupViteServer (
try { try {
url = normaliseURL(url, server.config.base) url = normaliseURL(url, server.config.base)
if (warmedUrls.has(url)) { return } if (warmedUrls.has(url) || isBuiltin(url)) { return }
const m = await server.moduleGraph.getModuleByUrl(url, isServer) const m = await server.moduleGraph.getModuleByUrl(url, isServer)
// a module that is already compiled (and can't be warmed up anyway) // a module that is already compiled (and can't be warmed up anyway)
if (m?.transformResult?.code || m?.ssrTransformResult?.code) { if (m?.transformResult?.code || m?.ssrTransformResult?.code) {