fix(vite): use isBuiltin polyfill for greater node support (#24512)

This commit is contained in:
Daniel Roe 2023-11-28 22:53:12 +01:00 committed by GitHub
parent fdc75fecb4
commit 4b3892117f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
import { isBuiltin } from 'node:module'
import { builtinModules } from 'node:module'
import { logger } from '@nuxt/kit'
import { join, normalize, relative } from 'pathe'
import { withoutBase } from 'ufo'
@ -28,6 +28,12 @@ function normaliseURL (url: string, base: string) {
return url
}
// TODO: remove when we drop support for node 18
const builtins = new Set(builtinModules)
function isBuiltin (id: string) {
return id.startsWith('node:') || builtins.has(id)
}
// TODO: use built-in warmup logic when we update to vite 5
export async function warmupViteServer (
server: ViteDevServer,