(fromPath: string, specifier: string)
| 72 | } |
| 73 | |
| 74 | function resolveRelativeImportPath(fromPath: string, specifier: string): string | null { |
| 75 | const basePath = path.resolve(path.dirname(fromPath), specifier); |
| 76 | const direct = resolveExistingFile(basePath); |
| 77 | if (direct) return direct; |
| 78 | |
| 79 | for (const extension of RESOLVABLE_EXTENSIONS) { |
| 80 | const withExtension = resolveExistingFile(`${basePath}${extension}`); |
| 81 | if (withExtension) return withExtension; |
| 82 | } |
| 83 | |
| 84 | for (const extension of RESOLVABLE_EXTENSIONS) { |
| 85 | const indexPath = resolveExistingFile(path.join(basePath, `index${extension}`)); |
| 86 | if (indexPath) return indexPath; |
| 87 | } |
| 88 | |
| 89 | return null; |
| 90 | } |
| 91 | |
| 92 | function resolveExistingFile(candidatePath: string): string | null { |
| 93 | try { |
no test coverage detected