这是indexloc提供的服务,不要输入任何密码
Skip to content

Handle pnpm resolving a dependency to multiple versions #2090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 27, 2022

Conversation

gsoltis
Copy link
Contributor

@gsoltis gsoltis commented Sep 26, 2022

  • pnpm can resolve multiple versions of a package. Resolve the package dependency specific to the workspace that asked for it.
  • handle "exclusions" in pnpm-workspace.yaml so that we don't try to resolve non-existent workspaces

Fixes #2075

@vercel
Copy link

vercel bot commented Sep 26, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated
turbo-site ⬜️ Ignored (Inspect) Visit Preview Sep 27, 2022 at 6:22PM (UTC)

@@ -277,7 +277,7 @@ func (c *Context) populateTopologicGraphForPackageJSON(pkg *fs.PackageJSON, root
pkg.TransitiveDeps = []string{}
seen := mapset.NewSet()
var lockfileWg sync.WaitGroup
c.resolveDepGraph(&lockfileWg, pkg.UnresolvedExternalDeps, externalDepSet, seen, pkg)
c.resolveDepGraph(&lockfileWg, pkg.Name, pkg.UnresolvedExternalDeps, externalDepSet, seen, pkg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be passing down pkg.Dir.ToUnixPath().ToString() since both pnpm and Yarn identify workspace projects by path and not by name.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other thing we need to do is to special case on when pkg is the root package and pass .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to pkg.Dir and turbopath.AnchoredUnixPath

}
importer, ok := p.Importers[workspace]
if !ok {
return "", false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should probably panic in this scenario. If we're querying for dependencies of a non-existent workspace we're doing something wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a panic here, are there other comparisons in here where we should panic?

@gsoltis gsoltis marked this pull request as ready for review September 27, 2022 18:22
@gsoltis gsoltis requested a review from a team as a code owner September 27, 2022 18:22
@gsoltis gsoltis requested review from nathanhammond and NicholasLYang and removed request for nathanhammond September 27, 2022 18:22
Copy link
Member

@chris-olszewski chris-olszewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! Played around with it a bit and everything seemed in working order

}
}
pnpmWorkspacePath := workspacePath.ToString()
if pnpmWorkspacePath == "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call pushing this into the lockfile implementation

@gsoltis gsoltis merged commit c4e69f1 into main Sep 27, 2022
@gsoltis gsoltis deleted the gsoltis/pnpm_resolve_multiple branch September 27, 2022 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache hash changes on windows without any change
2 participants