-
Notifications
You must be signed in to change notification settings - Fork 186
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
Request: common dependencies #94
Comments
Have you tried to add the dependencies to the root Then add the root package, like so: https://github.com/invertase/melos/blob/master/melos.yaml#L4 |
This is the same approach that I mentioned above. The root project would a The solution for now that I find is to use getx_cli to install the common packages. But would amazing if common_dependencies:
run: melos exec -c 1 --scope="package_one,package_two" -- exec "get install provider:5.0.0 http:0.13.1" |
This would be great if we can define common dependencies in |
Hey @Salakar would it possible to add this feature in Melos? |
is this already supported in melos? this is really useful especially with |
This is not currently supported by Melos. But if you just want to add melos exec -- dart pub add --dev dart_code_metrics:^4.15.0 |
I have a similar issue with |
Melos only overrides dependencies on packages in the same workspace to path dependencies. But even if we had common dependencies as a feature, I don't think that resolving dependencies across all packages would be wise. It would make it a lot harder for @BenVercammen Could you explain what issue you're facing? |
@blaugold Not really an issue (for now), just the fact that 2 packages in the same workspace have the same dependency, with the same |
Ah, ok. I guess one thing that could help is to regularly run |
Hi I just wrote a little dart script that updates common packages versions inside all
|
@fncap That's what I needed! Thank you very much! :) |
How about when we don't need a common dependency? In my case half of my packages need the same dependency, and the others don't. So I wanted to use the CLI to update this dependency version only on the packages that use the dependency. |
My solution use the |
Since we started using I am more than willing to take a stab at implementing such functionality. Are there any maintainers that would mind? |
That's an edge case in my opinion. In that case you would just not use the common dependencies method, and simply specify the version each time. |
I don't believe this is an edge case, my app is fairly big, and modularizing it is crucial to maintainability. But some modules depend on some stuff and others don't. The whole idea of using melos, for us, is to avoid the big manual hassle to deal with so many dependencies spread around so many modules. |
@feinstein What I'm saying is that specifying different dependencies versions for separate local packages is, and that it can easily be achieved by using dart's standard of way of defining package dependencies. Just to get an idea of your use case, can you detail:
|
Oh, sorry, I misunderstood you. Actually I think I misunderstood the whole thing. I was afraid melos would start adding dependencies to all packages, even the ones that don't need them. But I understand that's not the case, since the tree shaker would remove this unused dependencies. My bad. |
@blaugold and @Ehesp, would you be fine with me implementing this? |
@lohnn Would be great to get this feature implemented, so feel free to go a head. 👍 I think during the bootstrap command is a good time to sync the dependencies. Since Melos 3 we require a pubspec.yaml at the root of the workspace. Instead of a separate |
Great! Like this maybe? name: my_app
packages:
- packages/**
- apps/**
command:
bootstrap:
shareDependencies: true <--
version:
branch: HEAD
scripts: ... And I'm guessing we turn this off by default? |
👍
I think that's the save choice. |
@blaugold could you clarify what you mean by that? The decision of sharing the dependencies listed in the root
There are other API designs that wouldn't suffer from these issues, while being more explicit and more extensible. e.g. in common_dependencies:
my_package: 1.0.0
common_dev_dependencies:
my_dev_package: 1.0.0 e.g. in melos:
common_dependencies:
my_package: 1.0.0
common_dev_dependencies:
my_dev_package: 1.0.0 |
Sorry for interrupting the discussion, but regardless of the final implementation, I think It would be useful if we could run |
I have created a draft PR where I went with |
what exactly does bootstrap command do? if it doesnt do this? |
The flutter repo has a tool that tracks one file with common dependency versions, and updates all Melos could have the same functionality, looking in each Example here: async: 2.11.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade" |
This has already been supported since v3.2.0: #526 |
And how's that different from what has been asked in this issue? |
I guess this issue can now be closed |
Closed since implemented in #526 |
@spydon thar PR mentions the |
@feinstein if you read past the initial description of the PR, you'll get an answer to your question. |
@feinstein here are the docs for it :) |
Hi to all, it would be very useful if you can include |
The problem with shared dependency overrides is that there is no good way to remove them after they have been removed from the melos.yaml file, and since dependency overrides should be temporary that should be taken into consideration, that's why #520 and #594 haven't been merged. There is a specific issue for this: #439 |
In some cases, we have common dependencies around some packages. For now, we have two workarounds:
common_dependencies
and centralized the common dependencies here.[✗] The dependency is installed as a
transitive
dependency and we don't haveIntelliSense
.[✓] All common dependencies in a unique locale. This is easier to manipulate versions.
[✗] Is difficult to manipulate the version, needs to change in many locales.
[✓] We have the dependency as
direct
and so we haveIntelliSense
Any know the workaround to solve this?
Attempt
I tried to use the following below but it doesn't work.
Suggestion:
When the melos copy
pubspec.yaml
andpubspec.lock
, we could insert these dependencies on the specific packages.The text was updated successfully, but these errors were encountered: