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

Function loadModuleFromSelfNameReference

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

Source from the content-addressed store, hash-verified

43924 return !ts.some(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); });
43925 }
43926 function loadModuleFromSelfNameReference(extensions, moduleName, directory, state, cache, redirectedReference) {
43927 var _a, _b;
43928 var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
43929 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));
43930 var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
43931 if (!scope || !scope.packageJsonContent.exports) {
43932 return undefined;
43933 }
43934 if (typeof scope.packageJsonContent.name !== "string") {
43935 return undefined;
43936 }
43937 var parts = ts.getPathComponents(moduleName); // unrooted paths should have `""` as their 0th entry
43938 var nameParts = ts.getPathComponents(scope.packageJsonContent.name);
43939 if (!ts.every(nameParts, function (p, i) { return parts[i] === p; })) {
43940 return undefined;
43941 }
43942 var trailingParts = parts.slice(nameParts.length);
43943 return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : ".".concat(ts.directorySeparator).concat(trailingParts.join(ts.directorySeparator)), state, cache, redirectedReference);
43944 }
43945 function loadModuleFromExports(scope, extensions, subpath, state, cache, redirectedReference) {
43946 if (!scope.packageJsonContent.exports) {
43947 return undefined;

Callers 1

tryResolveFunction · 0.85

Calls 8

getPackageScopeForPathFunction · 0.85
loadModuleFromExportsFunction · 0.85
everyMethod · 0.80
concatMethod · 0.80
sliceMethod · 0.65
callMethod · 0.45
lengthMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…