const builtinModules = [ "_http_agent", "_http_client", "_http_common", "_http_incoming", "_http_outgoing", "_http_server", "_stream_duplex", "_stream_passthrough", "_stream_readable", "_stream_transform", "_stream_wrap", "_stream_writable", "_tls_common", "_tls_wrap", "assert", "assert/strict", "async_hooks", "buffer", "child_process", "cluster", "console", "constants", "crypto", "dgram", "diagnostics_channel", "dns", "dns/promises", "domain", "events", "fs", "fs/promises", "http", "http2", "https", "inspector", "module", "net", "os", "path", "path/posix", "path/win32", "perf_hooks", "process", "punycode", "querystring", "readline", "readline/promises", "repl", "stream", "stream/consumers", "stream/promises", "stream/web", "string_decoder", "sys", "timers", "timers/promises", "tls", "trace_events", "tty", "url", "util", "util/types", "v8", "vm", "wasi", "worker_threads", "zlib", ]; const moduleSet = new Set(builtinModules); const NODE_PROTOCOL = "node:"; export default (moduleName: string) => { if (moduleName.startsWith(NODE_PROTOCOL)) { moduleName = moduleName.slice(NODE_PROTOCOL.length); } const slashIndex = moduleName.indexOf("/"); if (slashIndex !== -1 && slashIndex !== moduleName.length - 1) { moduleName = moduleName.slice(0, slashIndex); } return moduleSet.has(moduleName); };