Skip to content

request: handle flavor dependency overrides #800

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

Open
1 task done
tpucci opened this issue Dec 9, 2024 · 4 comments
Open
1 task done

request: handle flavor dependency overrides #800

tpucci opened this issue Dec 9, 2024 · 4 comments

Comments

@tpucci
Copy link

tpucci commented Dec 9, 2024

Is there an existing feature request for this?

  • I have searched the existing issues.

Command

melos bootstrap --flavor [flavorName]

Description

As a developer, I would like to override some dependencies thanks to the pubspec_overrides.yaml files.

Given some declarations in melos.yaml or in local pubspec.yaml files, running the bootstrap command would generate the right overrides.

Reasoning

It would tackle some issues created in the flutter project (flutter/flutter#46979).

I think melos could be the right place for such feature as it is the go-to tool for managing monorepos and local dependencies.

Additional context and comments

No response

@spydon
Copy link
Collaborator

spydon commented Dec 10, 2024

How do you suggest that this config would look like?

@pedrox-hs
Copy link

Maybe a possible approach for handling dependency overrides per flavor in Melos could be adding a flavors section in melos.yaml. This would allow defining specific dependency overrides for each flavor, generating the appropriate pubspec_overrides.yaml during melos bootstrap.

For example:

flavors:
  lite:
    overrides:
      ads_sdk:
        path: ../libs/ads_stub
      analytics:
        name: analytics_lite
        version: ^2.0.0

  pro:
    overrides:
      ads_sdk:
        path: ../libs/real_ads
      analytics:
        name: analytics_pro
        version: ^3.0.0

Running melos bootstrap --flavor lite would apply the corresponding overrides, making it easier to manage dependencies per flavor without manually modifying pubspec.yaml.

Does this approach make sense and seem feasible to implement?

@spydon
Copy link
Collaborator

spydon commented Mar 19, 2025

The pubspec_overrides are no longer being used by Melos from v7, since it relies on pub workspaces now. Since we haven't heard anyone else requesting this I don't think it'll be anything that we'd implement directly in Melos, but I believe you'd be able to do this yourself by writing a pre-bootstrap hook script that does this.

@spydon
Copy link
Collaborator

spydon commented Mar 19, 2025

Just read the original flutter issue again, it does indeed seem to be a demand for it, so I'll keep the issue open.
Maybe it could be integrated with the shared dependencies feature that Melos already has, preferably we wouldn't want to go back to maintaining the pubspec_overrides code in melos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants