Simplify handling of node:-prefixed modules in auto-imports (#59702)

This commit is contained in:
Andrew Branch
2024-08-21 16:43:21 -07:00
committed by GitHub
parent f6ec916313
commit a5eec2485f
16 changed files with 943 additions and 191 deletions
+1 -58
View File
@@ -19,6 +19,7 @@ import {
hasJSFileExtension,
mapDefined,
MapLike,
nodeCoreModules,
normalizePath,
Path,
readConfigFile,
@@ -61,64 +62,6 @@ export function isTypingUpToDate(cachedTyping: CachedTyping, availableTypingVers
return availableVersion.compareTo(cachedTyping.version) <= 0;
}
const unprefixedNodeCoreModuleList = [
"assert",
"assert/strict",
"async_hooks",
"buffer",
"child_process",
"cluster",
"console",
"constants",
"crypto",
"dgram",
"diagnostics_channel",
"dns",
"dns/promises",
"domain",
"events",
"fs",
"fs/promises",
"http",
"https",
"http2",
"inspector",
"module",
"net",
"os",
"path",
"perf_hooks",
"process",
"punycode",
"querystring",
"readline",
"repl",
"stream",
"stream/promises",
"string_decoder",
"timers",
"timers/promises",
"tls",
"trace_events",
"tty",
"url",
"util",
"util/types",
"v8",
"vm",
"wasi",
"worker_threads",
"zlib",
];
const prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(name => `node:${name}`);
/** @internal */
export const nodeCoreModuleList: readonly string[] = [...unprefixedNodeCoreModuleList, ...prefixedNodeCoreModuleList];
/** @internal */
export const nodeCoreModules = new Set(nodeCoreModuleList);
/** @internal */
export function nonRelativeModuleNameForTypingCache(moduleName: string) {
return nodeCoreModules.has(moduleName) ? "node" : moduleName;