Skip to content
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: Smarter support for path dependencies on shared-dependencies #739

Open
1 task done
mugbug opened this issue Jul 22, 2024 · 2 comments
Open
1 task done

Comments

@mugbug
Copy link

mugbug commented Jul 22, 2024

Is there an existing feature request for this?

  • I have searched the existing issues.

Command

No response

Description

I expect melos' shared-dependencies feature to be able to understand the path reference I've set for a given dependency and use it based on the reference of the melos.yaml file. So, if my local package is under packages/core/my_local_package, I want to be able to set something like the following and it will adapt the path value based on the folder the package using this dependency is

# melos.yaml

# ...
command:
  bootstrap:
    dependencies:
      my_local_package:
        path: packages/core/my_local_package

Reasoning

When using shared dependencies feature, where one of the dependencies is referenced using path relation, and considering a monorepo structure where we have multiple levels of folders with packages in each of those, we can't just copy-paste the path reference defined inside the melos.yaml file. For instance, consider the following scenario:

Folder structure:

.
├── apps
│   ├── app1
│   └── app2
├── melos.yaml
└── packages
    ├── context1
    ├── context2
    ├── core
    │   └── my_local_package
    ├── features
    │   ├── feature_package1
    │   └── feature_package2
    ├── package1
    └── package2

If I define a library foo to be shared between all of those packages:

# melos.yaml

# ...
command:
  bootstrap:
    dependencies:
      my_local_package:
        path: packages/core/my_local_package # this is clear but won't work for any package
        path: ../core/my_local_package # this will only work for `package1` and `package2`
        path: ../../core/my_local_package # this will only work for `feature_package1` and `feature_package2`

We can't get a path to set that would work for all packages with that local dependency.

Additional context and comments

We probably do something similar with melos bs while creating the pubspec_overrides.yaml file, and I'm not sure shared-dependencies is the best feature for this tbh

@mugbug mugbug changed the title request: Smart support for path dependencies on shared-dependencies request: Smarter support for path dependencies on shared-dependencies Jul 22, 2024
@jifferon
Copy link

jifferon commented Sep 9, 2024

This feature is really needed

@spydon
Copy link
Collaborator

spydon commented Sep 9, 2024

@mugbug What is the reason for not using the automatic resolution of that package, it looks like it is within your monorepo?

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