MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / lazyRouteReference

Function lazyRouteReference

src/resolution/frameworks/react.ts:1579–1587  ·  view source on GitHub ↗

* What a data-router `lazy` loader renders, as the route's reference names * it. The loader resolves to the route's properties, and their `Component`, * or the page their `element` shows, is what the route renders: * * - `() => import('./x')` hands over the module's exports: `lazy-import:./x`.

(loader: string | undefined, elementTag: (jsx: string) => string | undefined)

Source from the content-addressed store, hash-verified

1577 * module its first import names, as before.
1578 */
1579function lazyRouteReference(loader: string | undefined, elementTag: (jsx: string) => string | undefined): string | undefined {
1580 if (!loader) return undefined;
1581 const code = stripCommentsForRegex(loader, 'typescript').trim();
1582 const rendered = code.startsWith('{') ? lazyPropertiesRender(code) : routeRender(loaderValue(code, new Map()), elementTag);
1583 if (rendered === null) return undefined;
1584 if (rendered !== undefined) return rendered;
1585 const spec = FIRST_IMPORT.exec(code)?.[1];
1586 return spec ? LAZY_ROUTE_PREFIX + spec : undefined;
1587}
1588
1589/**
1590 * What route properties a loader resolves to render: the reference for its

Callers 2

unitFunction · 0.85
jsxFunction · 0.85

Calls 5

stripCommentsForRegexFunction · 0.90
lazyPropertiesRenderFunction · 0.85
routeRenderFunction · 0.85
loaderValueFunction · 0.85
execMethod · 0.65

Tested by

no test coverage detected