MCPcopy Index your code
hub / github.com/angular/angular / resolve

Function resolve

tools/bazel/node_loader/hooks.mjs:34–67  ·  view source on GitHub ↗
(specifier, context, nextResolve)

Source from the content-addressed store, hash-verified

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

Callers 14

prerender.tsFile · 0.50
server.tsFile · 0.50
prerender.tsFile · 0.50
server.tsFile · 0.50
prerender.tsFile · 0.50
server.tsFile · 0.50
testFunction · 0.50
sourcemap_spec.tsFile · 0.50
startDevServerMethod · 0.50
getTooltipExtensionFunction · 0.50
getDiagnosticsExtensionFunction · 0.50
getAutocompleteExtensionFunction · 0.50

Calls 2

catchErrorFunction · 0.85
testMethod · 0.45

Tested by 1

testFunction · 0.40

Used in the wild real call sites across dependent graphs

searching dependent graphs…