* Attempt to resolve a module request using the parent module package metadata. * @param {string} parentPath The path of the parent module * @param {string} request The module request to resolve * @param {unknown} conditions * @returns {false|string}
(parentPath, request, conditions)
| 661 | * @returns {false|string} |
| 662 | */ |
| 663 | function trySelf(parentPath, request, conditions) { |
| 664 | if (!parentPath) { return false; } |
| 665 | |
| 666 | const pkg = packageJsonReader.getNearestParentPackageJSON(parentPath); |
| 667 | if (pkg?.data.exports === undefined || pkg.data.name === undefined) { |
| 668 | return false; |
| 669 | } |
| 670 | |
| 671 | let expansion; |
| 672 | if (request === pkg.data.name) { |
| 673 | expansion = '.'; |
| 674 | } else if (StringPrototypeStartsWith(request, `${pkg.data.name}/`)) { |
| 675 | expansion = '.' + StringPrototypeSlice(request, pkg.data.name.length); |
| 676 | } else { |
| 677 | return false; |
| 678 | } |
| 679 | |
| 680 | return resolveExpansion(expansion, pkg.path, pkg.data, parentPath, conditions); |
| 681 | } |
| 682 | |
| 683 | /** |
| 684 | * Try to resolve using package map (if enabled via --experimental-package-map). |
no test coverage detected
searching dependent graphs…