`() => import('./x')` → `./x`; `.then(m => m.X)` / `.then((c) => c.X)` names the member.
(text: string)
| 234 | |
| 235 | /** `() => import('./x')` → `./x`; `.then(m => m.X)` / `.then((c) => c.X)` names the member. */ |
| 236 | function 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 | |
| 246 | function joinPath(segs: readonly string[]): string { |
| 247 | return '/' + segs.join('/'); |
no test coverage detected