question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to only check packages listed in versionGroups -- or how to have versionGroups match packages beyond the syncpackrc filter property?

See original GitHub issue

Description

Right now if you specify version groups with specific packages and/or with package patterns (with wildcards), syncpack still checks all packages unless you list each package again in the filter property of syncpackrc. Eventually, if you want to only match packages in version groups, the filter regex gets fairly unwieldy.

If there were a way to only check packages included in version groups, it would be easier to gradually onboard to syncpack.

Suggested Solution

Would it be possible to have a mode that only matches through version groups, not the filter property? Maybe by setting the filter to the empty string or false?

Another way to look at it would be that versionGroup packages wouldn’t be filtered.

Help Needed

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
JamieMasoncommented, Oct 28, 2022

Hey @dsilvasc, I just took a look at the repro. As I think you might have mentioned: filter applies globally, when it is set then only packages whose names match that RegEx will be included.

I just want to check before I do it, would something like this work for you?

versionGroups:
  - packages: ['**']
    dependencies: ['webpack']
  - packages: ['**']
    dependencies: ['react', 'react-dom']
    dependencyTypes: ['dependencies', 'devDependencies']
+  - packages: ['**']
+    dependencies: ['**']
+    isIgnored: true

What this would do is create a catch-all version group which ignores every package which does not match any of the preceding groups.

Thanks.

1reaction
JamieMasoncommented, Sep 27, 2022

Thanks @dsilvasc, could you make a small repro to demonstrate this please? I’ll need to see the scenario you’re facing so I can dig into it.

Dependencies are assigned to versionGroups in https://github.com/JamieMason/syncpack/blob/c6db8786f9a117eb9d1d334edc7dfa70b036eeaf/src/lib/get-input/get-instances.ts#L34

In theory it shouldn’t be possible for a given dependency to belong to more than one versionGroup because they’re looped over once and each dependency is partitioned into the first group it matches. If version groups aren’t being used or a dependency matches none of them, it goes into a final catch-all group.

Maybe something else is going on, we will see, if you can create a reproduction please with expected vs actual behaviour, I’ll hopefully be able to figure it out using that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JamieMason/syncpack - GitHub
List dependencies which are required by multiple packages, where the version is not the same across every package. See versionGroups if you have...
Read more >
How do I find all installed packages that depend on a given ...
I can update my package.json, but I don't want to break something. Is there a way to list all of the installed packages...
Read more >
error unexpected while resolving tree within virtual file system ...
See versionGroups if you have advanced requirements. Options -s, --source [pattern] glob pattern for package.json files to read from -p, --prod include ...
Read more >
syncpack/README.md - UNPKG
3, > Manage multiple package.json files, such as in Lerna Monorepos and Yarn/Pnpm Workspaces ... 62, # only inspect "devDependencies" and "peerDependencies".
Read more >
How to Easily Manage Dependencies in a JS Monorepo
Not far behind it in 2nd place, comes code… ... There is just one set of dependencies that every package in the monorepo...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found