( filePath: string, packageCache?: PackageCache, )
| 423 | } |
| 424 | |
| 425 | export function isFilePathESM( |
| 426 | filePath: string, |
| 427 | packageCache?: PackageCache, |
| 428 | ): boolean { |
| 429 | if (/\.m[jt]s$/.test(filePath)) { |
| 430 | return true |
| 431 | } else if (/\.c[jt]s$/.test(filePath)) { |
| 432 | return false |
| 433 | } else { |
| 434 | // check package.json for type: "module" |
| 435 | try { |
| 436 | const pkg = findNearestPackageData(path.dirname(filePath), packageCache) |
| 437 | return pkg?.data.type === 'module' |
| 438 | } catch { |
| 439 | return false |
| 440 | } |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | export const splitRE: RegExp = /\r?\n/g |
| 445 |
no test coverage detected