-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Allow multiple versions of a particular dependency #41
Comments
Hi @ecraig12345, I know you've spoken about this but I just want to confirm – for the versions of
If A, your preferred shape looks a good fit as it allows for multiple partitions/contexts/scopes and, within them, suggests there's a relationship between the members of {
"syncpack": {
"mismatchContexts": [
{
"packages": ["foo", "foo-utilities"],
"dependencies": ["typescript", "react"]
}
]
}
} If B, I'd prefer to use a structure which couldn't be misinterpreted as describing a relationship between the packages, even if that means a little repetition. Roughly something like: {
"syncpack": {
"allowedMismatches": {
"foo": ["typescript", "react"],
"foo-utilities": ["typescript", "react"]
}
}
} Let me know what you think. Like you, I'm not set on the names Thanks again for your time, appreciate it. Jamie |
Thanks for the response! Option A is what I meant. |
I'm not sure about the name |
yeah good point, I think you're right. I wanted "mismatch" to be in there somewhere to indicate that this config only applies to that feature, but I think you're right that it could be confusing. I am away this weekend so this may take a couple of weeks before I have the time. Taking a quick look at the code here... Mismatched dependencies are collected here (they use generators to allow support for future interactive modes): syncpack/src/commands/lib/get-installations.ts Lines 61 to 78 in 9d48f88
This is read by both syncpack/src/commands/list-mismatches.ts Lines 21 to 22 in 9d48f88
and syncpack/src/commands/fix-mismatches.ts Lines 22 to 23 in 9d48f88
I'm not sure as I'd need more time to look at it properly, but it might be possible to pass more arguments into |
FYI I'm planning to split this up so we add support for a syncpack config first (via cosmiconfig), then return to this issue to extend that with what we want here. Branch: feat/config-file |
The config file work is released as of 5.2.5, which unblocks this issue. |
Great, thanks so much for all your work on this! |
Released in 5.6.7. I've tested for as much as I can think of, but please let me know if you run into any problems. |
Great, thank you!!! Haven't gotten to try it out yet but I'll let you know if there are issues. |
Yes, thanks for the quick turnaround! I gave it a try and think I may have found an issue. |
Description
This request pertains to the
list-mismatches
andfix-mismatches
commands.In some cases, it's necessary to temporarily have different versions of a particular dependency present in the same repo, for example when experimenting with new things or moving code into a monorepo.
Example:
foo
is a package within the monorepofoo
) depend ontypescript
andreact
typescript
andreact
versions must match, butfoo
is experimental and needs newer versions (it may also need newer versions of other packages)foo
could have a few related packages (likefoo-utilities
) which should share these different dependency versionsExisting solutions
foo
by using a custom--source
glob which excludes it: e.g.--source "{apps/*,packages/!(foo),packages/sub-group/*,scripts,.}/package.json"
(from the real monorepo where I want this feature)typescript
with--filter "^(?!^typescript$).*$"
typescript
These options also share the following disadvantages:
Suggested Solutions
There are multiple possible ways to solve this, most simply by adding another command line option, but a package.json and/or config file option would be easier to use and more capable.
1. Command line option
Simplest implementation would be to add a command line option listing packages for which dependencies don't need to match, something like
--ignore <package-name-regex>
.This is not my preference (at least as the only solution) because:
2. package.json (and/or config file) options
A better approach would be to add support for reading configuration from the monorepo root package.json (and/or a config file, but only using package.json would be easier). This allows easily specifying alternates xin the form of key/value mappings, which I think is the most logical form but would be very awkward to specify on the command line.
There are various ways the option could be set up. Alternatives can be found in the collapsed section below, but here's what I'd suggest (though I'm not at all set on the names).
Using the same example from above, this would allow
foo
andfoo-utilities
to depend on any version oftypescript
andreact
, but all other packages must still depend on a matching version.variationGroups
takes an array in case there are multiple groups of packages which should share alternate versions.Other solutions considered
Click to expand
These were other options I considered but discarded for various reasons. (Again in all these cases, naming is not final.)
2a. List groups of monorepo packages to consider separately
Essentially, do two sub-runs: against
foo
plusfoo-utilities
, and against everything else.Pros: Probably the simplest to set up and to implement. (Could potentially even be set up as a command line option.)
Cons: It's likely that the variation group and the main group should still share versions of some dependencies, and this does nothing to enforce that.
2b. Mapping between monorepo package and deps which may vary
foo
andfoo-utilities
may depend on any version oftypescript
andreact
, but all other packages must still depend on a matching version.Pros: Simple to set up in some ways.
Cons: Requires duplication if there are additional packages which are related to
foo
; no notion of groups which should share dep versions2c. Mapping from monorepo package to allowed semver specs
For particular packages, list the semver specs which are allowed. This is similar to
allowedAlternateVersions
fromrush
(which my team's monorepo previously used).Pros: No duplication required for multiple packages to share an alternate version; very specific
Cons: Additional place to manually change when upgrading versions; no notion of grouping; seems a bit incongruous with syncpack's other options (which don't rely on explicitly set semver specs)
Note for any package.json/config file-based solution
If any file-based config support is added for version alternates, it would probably make sense to also add support for overrideable defaults for the other options. For example, instead of having to specify
--prod --dev --source "{apps/*,packages/!(foo),packages/sub-group/*,scripts,.}/package.json"
for every syncpack command, you could do this:(Granted the long
source
glob would not be needed once this new config setting is added, but it would still be nice to have the other common options specified in a single place.)Help Needed
I can probably help implement this.
The text was updated successfully, but these errors were encountered: