From f8b9adb73dc838f14a41406def918cfd6c9a841e Mon Sep 17 00:00:00 2001 From: bluwy Date: Tue, 3 Oct 2023 20:17:10 +0800 Subject: [PATCH] fix: restore builtins list --- packages/vite/src/node/utils.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index a53ee86e614e67..7b8912835d1f79 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -94,8 +94,25 @@ const NODE_BUILTIN_NAMESPACE = 'node:' const NPM_BUILTIN_NAMESPACE = 'npm:' // Supported by Bun const BUN_BUILTIN_NAMESPACE = 'bun:' +//TODO: revisit later to see if the edge case that "compiling using node v12 code to be run in node v16 in the server" is what we intend to support. +const builtins = new Set([ + ...builtinModules, + 'assert/strict', + 'diagnostics_channel', + 'dns/promises', + 'fs/promises', + 'path/posix', + 'path/win32', + 'readline/promises', + 'stream/consumers', + 'stream/promises', + 'stream/web', + 'timers/promises', + 'util/types', + 'wasi', +]) // Some runtimes like Bun injects namespaced modules here, which is not a node builtin -const nodeBuiltins = builtinModules.filter((id) => !id.includes(':')) +const nodeBuiltins = [...builtins].filter((id) => !id.includes(':')) // TODO: Use `isBuiltin` from `node:module`, but Deno doesn't support it export function isBuiltin(id: string): boolean {