( fsPath: string, options: InternalResolveOptions, tryIndex = true, skipPackageJson = false, )
| 551 | } |
| 552 | |
| 553 | export function tryFsResolve( |
| 554 | fsPath: string, |
| 555 | options: InternalResolveOptions, |
| 556 | tryIndex = true, |
| 557 | skipPackageJson = false, |
| 558 | ): string | undefined { |
| 559 | // Dependencies like es5-ext use `#` in their paths. We don't support `#` in user |
| 560 | // source code so we only need to perform the check for dependencies. |
| 561 | // We don't support `?` in node_modules paths, so we only need to check in this branch. |
| 562 | const hashIndex = fsPath.indexOf('#') |
| 563 | if (hashIndex >= 0 && isInNodeModules(fsPath)) { |
| 564 | const queryIndex = fsPath.indexOf('?') |
| 565 | // We only need to check foo#bar?baz and foo#bar, ignore foo?bar#baz |
| 566 | if (queryIndex < 0 || queryIndex > hashIndex) { |
| 567 | const file = queryIndex > hashIndex ? fsPath.slice(0, queryIndex) : fsPath |
| 568 | const res = tryCleanFsResolve(file, options, tryIndex, skipPackageJson) |
| 569 | if (res) return res + fsPath.slice(file.length) |
| 570 | } |
| 571 | } |
| 572 | |
| 573 | const { file, postfix } = splitFileAndPostfix(fsPath) |
| 574 | const res = tryCleanFsResolve(file, options, tryIndex, skipPackageJson) |
| 575 | if (res) return res + postfix |
| 576 | } |
| 577 | |
| 578 | const knownTsOutputRE = /\.(?:js|mjs|cjs|jsx)$/ |
| 579 | const isPossibleTsOutput = (url: string): boolean => knownTsOutputRE.test(url) |
no test coverage detected