(projectRoot: string)
| 53 | * the same way it does {@link loadProjectAliases} / {@link loadGoModule}. |
| 54 | */ |
| 55 | export function loadWorkspacePackages(projectRoot: string): WorkspacePackages | null { |
| 56 | const byName = new Map<string, string>(); |
| 57 | |
| 58 | const patterns = readWorkspaceGlobs(projectRoot); |
| 59 | for (const pattern of patterns) { |
| 60 | for (const dir of expandWorkspaceGlob(projectRoot, pattern)) { |
| 61 | const pkgName = readPackageName(path.join(projectRoot, dir)); |
| 62 | // First declaration wins — workspace patterns are tried in order. |
| 63 | if (pkgName && !byName.has(pkgName)) byName.set(pkgName, dir); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | // HarmonyOS/OpenHarmony (ArkTS) modular projects: every module's |
| 68 | // oh-package.json5 declares its local siblings as `"data": "file:../../ |
| 69 | // core/data"` dependencies, and code then imports the bare name |
| 70 | // (`import { CartRepository } from "data"`). Same monorepo problem as npm |
| 71 | // workspaces, different manifest. |
| 72 | const entryByName = new Map<string, string>(); |
| 73 | for (const [name, dir] of collectOhpmFileDeps(projectRoot)) { |
| 74 | if (byName.has(name)) continue; |
| 75 | byName.set(name, dir); |
| 76 | const entry = readOhpmMain(projectRoot, dir); |
| 77 | if (entry) entryByName.set(name, entry); |
| 78 | } |
| 79 | |
| 80 | if (byName.size === 0) return null; |
| 81 | |
| 82 | logDebug('workspace packages loaded', { count: byName.size }); |
| 83 | return { byName, entryByName: entryByName.size > 0 ? entryByName : undefined }; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Read an ohpm member's declared entry file: `<dir>/oh-package.json5`'s |
no test coverage detected