| 40 | |
| 41 | // Lazy-load heavy modules (CodeGraph, runInstaller) to keep CLI startup fast. |
| 42 | async function loadCodeGraph(): Promise<typeof import('../index')> { |
| 43 | try { |
| 44 | return await import('../index'); |
| 45 | } catch (err) { |
| 46 | const msg = err instanceof Error ? err.message : String(err); |
| 47 | console.error(`\x1b[31m${getGlyphs().err}\x1b[0m Failed to load CodeGraph modules.`); |
| 48 | console.error(`\n Node: ${process.version} Platform: ${process.platform} ${process.arch}`); |
| 49 | console.error(`\n Error: ${msg}`); |
| 50 | console.error('\n Try reinstalling with: npm install -g @colbymchenry/codegraph\n'); |
| 51 | process.exit(1); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | // Dynamic import helper — tsc compiles import() to require() in CJS mode, |
| 56 | // which fails for ESM-only packages. This bypasses the transformation. |