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

Function lazyImport

src/resolution/frameworks/angular-router.ts:236–244  ·  view source on GitHub ↗

`() => import('./x')` → `./x`; `.then(m => m.X)` / `.then((c) => c.X)` names the member.

(text: string)

Source from the content-addressed store, hash-verified

234
235/** `() => import('./x')` → `./x`; `.then(m => m.X)` / `.then((c) => c.X)` names the member. */
236function lazyImport(text: string): { spec: string; member: string | null } | null {
237 const imp = /\bimport\s*\(\s*(['"`])([^'"`]+)\1\s*\)/.exec(text);
238 if (!imp) return null;
239 const after = text.slice(imp.index + imp[0].length);
240 const then = /^\s*\.then\s*\(\s*\(?\s*([A-Za-z_$][\w$]*)\s*\)?\s*=>\s*\(?\s*\1\s*\.\s*([A-Za-z_$][\w$]*)/.exec(after);
241 // `async () => (await import('./x')).HomeModule`
242 const awaited = /^\s*\)\s*\.\s*([A-Za-z_$][\w$]*)/.exec(after);
243 return { spec: imp[2]!, member: then ? then[2]! : awaited ? awaited[1]! : null };
244}
245
246function joinPath(segs: readonly string[]): string {
247 return '/' + segs.join('/');

Callers 2

componentRefFunction · 0.85
walkFunction · 0.85

Calls 1

execMethod · 0.65

Tested by

no test coverage detected