MCPcopy Index your code
hub / github.com/nodejs/node / loadModuleFromImports

Function loadModuleFromImports

test/fixtures/snapshot/typescript.js:43979–44010  ·  view source on GitHub ↗
(extensions, moduleName, directory, state, cache, redirectedReference)

Source from the content-addressed store, hash-verified

43977 return toSearchResult(/*value*/ undefined);
43978 }
43979 function loadModuleFromImports(extensions, moduleName, directory, state, cache, redirectedReference) {
43980 var _a, _b;
43981 if (moduleName === "#" || ts.startsWith(moduleName, "#/")) {
43982 if (state.traceEnabled) {
43983 trace(state.host, ts.Diagnostics.Invalid_import_specifier_0_has_no_possible_resolutions, moduleName);
43984 }
43985 return toSearchResult(/*value*/ undefined);
43986 }
43987 var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
43988 var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames));
43989 var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
43990 if (!scope) {
43991 if (state.traceEnabled) {
43992 trace(state.host, ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath);
43993 }
43994 return toSearchResult(/*value*/ undefined);
43995 }
43996 if (!scope.packageJsonContent.imports) {
43997 if (state.traceEnabled) {
43998 trace(state.host, ts.Diagnostics.package_json_scope_0_has_no_imports_defined, scope.packageDirectory);
43999 }
44000 return toSearchResult(/*value*/ undefined);
44001 }
44002 var result = loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, scope.packageJsonContent.imports, scope, /*isImports*/ true);
44003 if (result) {
44004 return result;
44005 }
44006 if (state.traceEnabled) {
44007 trace(state.host, ts.Diagnostics.Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1, moduleName, scope.packageDirectory);
44008 }
44009 return toSearchResult(/*value*/ undefined);
44010 }
44011 /**
44012 * From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
44013 * "longest" has some nuance as to what "longest" means in the presence of pattern trailers

Callers 1

tryResolveFunction · 0.85

Calls 5

traceFunction · 0.85
toSearchResultFunction · 0.85
getPackageScopeForPathFunction · 0.85
callMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…