We already have findworkspaceDir but it is not strict enough to make distinguish between a monorepo and just the closest root dir of a project.
We could introduce a new resolveWorkspace utility that only detects an explicit monorepo workspace with the detected field in package.json or pnpm workspaces lock returning a workspaces config object (array of objects for forward compatibility.
Resolve workspace packages
Another utility like resolveWorkspacePkgs can be introduced to accepd resolved workspace config (from resolveWorkspace or a string to do this) and read all of its packages.
Resolve workspace packages graph
Get array of workspace packages, returning an (ordered and sorted) graph of devDependency and dependency between monorepo packages.
@pi0
I don't think it's necessary to include Turbo, because Turbo isn't an independent workspace manager.The document mentions that you need to configure npm, yarn, or pnpm workspaces yourself.
Supporting monorepo and workspace detection
Common sources:
workspaces
field inpackage.json
(yarn, npm and lerna, turbo supported)pnpm-workspace.yaml
(pnpm, our odd friend with it's odd requirements)Common workspace managers:
Reolve workspace
We already have
findworkspaceDir
but it is not strict enough to make distinguish between a monorepo and just the closest root dir of a project.We could introduce a new
resolveWorkspace
utility that only detects an explicit monorepo workspace with the detected field in package.json or pnpm workspaces lock returning a workspaces config object (array of objects for forward compatibility.Resolve workspace packages
Another utility like
resolveWorkspacePkgs
can be introduced to accepd resolved workspace config (fromresolveWorkspace
or a string to do this) and read all of its packages.Resolve workspace packages graph
Get array of workspace packages, returning an (ordered and sorted) graph of
devDependency
anddependency
between monorepo packages.(PR more than welcome 🙏🏼 )