| 39 | const seen = new Set<string>(); |
| 40 | const stack: string[] = []; |
| 41 | const dfs = (node: string) => { |
| 42 | if (seen.has(node)) return; |
| 43 | seen.add(node); |
| 44 | stack.push(node); |
| 45 | const ps = parents.get(node) || []; |
| 46 | if (ps.length === 0) { |
| 47 | // hit a root (likely main entry or plugin virtual) |
| 48 | console.log("\nImporter chain:"); |
| 49 | stack |
| 50 | .slice() |
| 51 | .reverse() |
| 52 | .forEach((s) => console.log(" ↳", s)); |
| 53 | } else { |
| 54 | for (const p of ps) dfs(p); |
| 55 | } |
| 56 | stack.pop(); |
| 57 | }; |
| 58 | |
| 59 | if (!parents.has(target)) { |
| 60 | console.log(`[who-imports] TARGET not in MAIN graph: ${target}`); |