Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: isBuiltin using patched native builtinModules #5827

Merged
merged 9 commits into from Nov 27, 2021
1 change: 0 additions & 1 deletion packages/vite/package.json
Expand Up @@ -79,7 +79,6 @@
"acorn": "^8.6.0",
"acorn-class-fields": "^1.0.0",
"acorn-static-class-features": "^1.0.0",
"builtin-modules": "^3.2.0",
"cac": "6.7.9",
"chalk": "^4.1.2",
"chokidar": "^3.5.2",
Expand Down
8 changes: 5 additions & 3 deletions packages/vite/src/node/utils.ts
Expand Up @@ -12,7 +12,7 @@ import {
ENV_PUBLIC_PATH
} from './constants'
import resolve from 'resolve'
import builtins from 'builtin-modules'
import { builtinModules } from 'module'
import { FSWatcher } from 'chokidar'
import remapping from '@ampproject/remapping'
import {
Expand All @@ -38,8 +38,10 @@ export const normalizeId = (id: string): string =>
id.replace(/(\s*>\s*)/g, ' > ')

export function isBuiltin(id: string): boolean {
const deepMatch = id.match(deepImportRE)
id = deepMatch ? deepMatch[1] || deepMatch[2] : id
const builtins = [...builtinModules]
Niputi marked this conversation as resolved.
Show resolved Hide resolved
if (!builtins.includes('fs/promises')) builtins.push('fs/promises')
Niputi marked this conversation as resolved.
Show resolved Hide resolved
if (!builtins.includes('diagnostics_channel')) builtins.push('diagnostics_channel')
Niputi marked this conversation as resolved.
Show resolved Hide resolved
builtins.forEach(builtin => { builtins.push(`node:${builtin}`) })
return builtins.includes(id)
}

Expand Down
2 changes: 0 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.