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

Function lazyRouteReference

src/resolution/frameworks/react.ts:1557–1565  ·  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

1555 * module its first import names, as before.
1556 */
1557function lazyRouteReference(loader: string | undefined, elementTag: (jsx: string) => string | undefined): string | undefined {
1558 if (!loader) return undefined;
1559 const code = stripCommentsForRegex(loader, 'typescript').trim();
1560 const rendered = code.startsWith('{') ? lazyPropertiesRender(code) : routeRender(loaderValue(code, new Map()), elementTag);
1561 if (rendered === null) return undefined;
1562 if (rendered !== undefined) return rendered;
1563 const spec = FIRST_IMPORT.exec(code)?.[1];
1564 return spec ? LAZY_ROUTE_PREFIX + spec : undefined;
1565}
1566
1567/**
1568 * 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