( importPath: string, ws: WorkspacePackages, fromFile?: string )
| 699 | * above it declare. Returns `null` when no package name matches. |
| 700 | */ |
| 701 | export function resolveWorkspaceImport( |
| 702 | importPath: string, |
| 703 | ws: WorkspacePackages, |
| 704 | fromFile?: string |
| 705 | ): string | null { |
| 706 | const hit = matchPackage(importPath, ws, fromFile); |
| 707 | if (!hit) return null; |
| 708 | const subpath = importPath.slice(hit.name.length); // '' or '/widgets' |
| 709 | // A bare member import resolves straight to the member's declared entry |
| 710 | // file when the ohpm manifest names one — the caller's exact-path check |
| 711 | // hits it without extension/index guessing. |
| 712 | const ohpm = subpath ? undefined : ws.entryByName?.get(hit.name); |
| 713 | return ohpm ?? (hit.dir + subpath).replace(/\/{2,}/g, '/'); |
| 714 | } |
| 715 | |
| 716 | /** |
| 717 | * Where an import of a package of the project lands (see |
no test coverage detected