| 98 | } |
| 99 | |
| 100 | function isLikelyEntryPoint(rel: string, packageJson: any): boolean { |
| 101 | if (ENTRY_HINT_PATTERNS.some(p => p.test(rel))) return true; |
| 102 | if (packageJson) { |
| 103 | if (packageJson.main && rel === packageJson.main.replace(/^\.\//, '')) return true; |
| 104 | if (packageJson.module && rel === packageJson.module.replace(/^\.\//, '')) return true; |
| 105 | if (packageJson.bin) { |
| 106 | const bins = typeof packageJson.bin === 'string' ? [packageJson.bin] : Object.values(packageJson.bin); |
| 107 | if (bins.some((b: any) => typeof b === 'string' && rel === b.replace(/^\.\//, ''))) return true; |
| 108 | } |
| 109 | if (Array.isArray(packageJson.files) && packageJson.files.some((f: string) => rel.startsWith(f))) { |
| 110 | // listed in `files` — meant to ship to npm, treat as potential entry |
| 111 | return true; |
| 112 | } |
| 113 | } |
| 114 | return false; |
| 115 | } |
| 116 | |
| 117 | /** Build the set of "anything that looks like an import or reference TO `target`'s stem". */ |
| 118 | function buildReferencePatterns(targetRel: string): string[] { |