monorepo-utils
monorepo-utils copied to clipboard
workspaces-to-typescript-project-references: Dependency resolution logic doesn't match yarn
Based on https://github.com/azu/monorepo-utils/blob/8ccf1c70c2582770ee6fc5fd71bf3b6e5e95400f/packages/%40monorepo-utils/workspaces-to-typescript-project-references/src/manager/workspaces.ts#L26-L30, the dependency resolution logic is:
- package name has to match AND
- if dependency version starts with
workspace:
OR - dependency version matches semver of package version
This does not match the Yarn resolution logic in at least the following scenarios:
- Dependency version starts with
workspace
and semver doesn't match (which does not resolve as per https://yarnpkg.com/features/workspaces#workspace-ranges-workspace, specifially):
if a semver range, it will select the workspace matching the specified version.
- If a module has a non-compatible dependency with the rest of the monorepo, yarn 1 will resolve this inside a
node_modules
folder inside the module folder - but only for this module. Whereas the current logic will use this to resolve dependencies for other modules
I recommend avoiding re-implementing the dependency resolution logic in this library and instead re-using the resolution logic of the build tool chosen by the plugin