-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
☂️ Implement Workspace Feature #53875
Comments
@jacob314 @keertip Thanks for filing issue to track this work. Could we also produce some sort of overall design document that outlines our plans and their implications - so that we could circulate it in the community and collect feedback? @incendial privately provided me some feedback that makes me a bit concerned: he is aware of monorepos which are not normalized with respect to external dependencies. That is monorepo might contain multiple entry point packages (e.g. different apps) and these entry point packages have inconsistent version resolutions when it comes to the external packages. This is similar to the feedback provided here dart-lang/pub#4022 (comment) by @olexale. Right now we are operating under the assumption that external monorepos either already operate like Google's internal monorepo (following one version rule) or can be easily brought under the same constraints. I wonder if we should pause before plunging here and validate our assumption? I wonder if pub team (cc @sigurdm @jonasfj) could create a tool which takes a path to monorepository root and computes the global resolution for all |
Part of the support for monorepo in the analysis server is based on the pub proposal #4022. The key points of that proposal that would make the analysis server treat the codebase as a single workspace/monorepo and use one version of dependencies for resolution are
As mentioned in the pub proposal, there is a way out if for some reason a package's dependencies are unable to meet the global constraints. It can opt out of the From the analysis server's perspective, a monorepo would be one workspace containing several packages, the individual packages rooted at their respective |
Yes, if we haven't already done so we should absolutely validate our assumptions.
But presumably a consistent version resolution when it comes to the non-entry-point packages within the root directory? If so, the first thing the analyzer would need is to have one But, that repository style (not sure what to call it; maybe 'multi-rooted-mono-repo'?) would raise at least one interesting UX question: when a user is viewing a file from a non-entry-point package, which entry-point package's version resolution (
We could choose one arbitrarily, allow the user to tell us, or try to merge the information from all of them, but all of these approaches will require additional supporting implementation work. It isn't a blocker, but it is a question we'd need to answer. On the other hand, unless we find evidence that the currently proposed form of mono-repo ('single-rooted-mono-repo'?) won't satisfy a reasonable percentage of our user's needs, we could support the current form as a first step while we try to figure out which other styles to support and how best to do that. That approach would allow the users we could help with what we have today get help sooner. I definitely want us to be confident that the currently proposed form would provide significant value before we invest too much effort on it, but I don't believe that we should wait to support it just because we find out that it won't help every user's use case. (I'd be more cautious if I thought that expanding our support to a wider set of use cases was likely to invalidate the work done to get the first form of monorepo implemented, but I don't think that's going to be the case.) |
I've created an umbrella doc for the feature that should hopefully clarify some of these concerns. Happy to chat more on discord and or in a meeting. |
@jacob314 thanks for sharing the doc, I left a few questions that I didn't find an answer to. |
I don't think the feature relies on a single version solve. As @keertip and the pub proposal note, "there is a way out if for some reason a package's dependencies are unable to meet the global constraints." I can think of two circumstances in which the developer might reasonably/commonly desire non-compatible version constraints on a dependency:
The solution might be to not use external resolution in pkg_one. It might be to separate out the In these reasonable situations, the mono-repo support still allows a DAS instance rooted to the mono-repo root to have many fewer analysis contexts, and allow developers to have more confidence in the consistency of their external dependencies. Instead of 30 analysis contexts, maybe you get down to 1. Or maybe 5 due to dev_dependency version conflicts. Or maybe, during a big migration of a dependency, you have 10 analysis contexts temporarily, and you're back to 1 after the migration. Instead of 300 analysis contexts, maybe they get away with 20 as a steady state. |
Analyzer memory usage should be fine with what Sam is suggesting + the monorepo workspace feature as described. |
I created https://github.com/sigurdm/pub_workspace_tool I have tested it on the protobuf.dart monorepo, and there a common resolution works. |
Status update: workspaces are now supported in |
How does |
Which aspect are you asking about? If a workspace has package A and B and A depends on B, then when publishing A validation of the version constraint But consumers of the published package will use the published version of B. |
Ignore me I was confused by a separate error. Long story short, I tried workspaces and made two packages A and B where A depends on B ... but forgot to add a version number on either of them: name: b
environment:
sdk: ^3.5.0-259.0.dev
resolution: workspace Then, inside A, I tried to depend on B with: name: a
environment:
sdk: ^3.5.0-259.0.dev
resolution: workspace
dependencies:
b: ^1.0.0 But got:
This error confused me and I thought the only way to make workspace work with unpublished packages was: dependencies:
b: # no constraint specified Hence the earlier question. I wondered which constraint would be picked when publishing A. Maybe we could improve the Such as:
|
Yeah I can see the confusion. I have created dart-lang/pub#4356 to see if we can improve the messaging here. |
Workspace feature
Description
Support shared resolution between packages of a workspace / mono-repo.
Workspaces are tightly related packages that are developed and released together.
We have seen the analysis server consume large memory such that it is rendered unusable mainly due to the lack of a workspace feature.
#52447
#41793
Work items
flutter
tool support: Adapt flutter tools to handle pub workspaces: flutter/flutter#150196The text was updated successfully, but these errors were encountered: