MCPcopy Index your code
hub / github.com/angular/dev-infra / resolve

Function resolve

bazel/private/node_loader/hooks.mjs:41–75  ·  view source on GitHub ↗
(specifier, context, nextResolve)

Source from the content-addressed store, hash-verified

39
40/** @type {import('module').ResolveHook} */
41export const resolve = async (specifier, context, nextResolve) => {
42 // True when it's a non-module import without explicit extensions.
43 const isNonModuleExtensionlessImport =
44 nonModuleImportRe.test(specifier) && !explicitExtensionRe.test(specifier);
45 const pathMappings = !nonModuleImportRe.test(specifier) ? pathMappingMatcher(specifier) : [];
46
47 // If it's neither path mapped, nor an extension-less import that may be fixed up, exit early.
48 if (!isNonModuleExtensionlessImport && pathMappings.length === 0) {
49 return nextResolve(specifier, context);
50 }
51
52 if (pathMappings.length > 0) {
53 for (const mapping of pathMappings) {
54 const res = await resolve(mapping, context, nextResolve).catch(() => null);
55 if (res !== null) {
56 return res;
57 }
58 }
59 } else {
60 const specifiers = [
61 `${specifier}.js`,
62 `${specifier}/index.js`,
63 // Legacy variants for the `zone.js` variant using still `ts_library`.
64 // TODO(rules_js migration): Remove this.
65 `${specifier}.mjs`,
66 `${specifier}/index.mjs`,
67 ];
68 for (const specifier of specifiers) {
69 try {
70 return await nextResolve(specifier, context);
71 } catch {}
72 }
73 }
74 return nextResolve(specifier, context);
75};

Callers 15

validateFileFunction · 0.85
spawnInteractiveFunction · 0.85
processAsyncCmdFunction · 0.85
invokeNvmInstallFunction · 0.85
verifyFunction · 0.85
builderFunction · 0.85
resolveRelativePathFunction · 0.85
getSourceFileMethod · 0.85
verifyFunction · 0.85
runFormatterInParallelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected