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

feat(core): add a way to add additional package.json files to the sources read from the monorepo #205

Open
dominics opened this issue Apr 10, 2024 · 1 comment

Comments

@dominics
Copy link

Description

In the monorepo I work in, there are a large number of package.json files configured using (yarn, soon pnpm) workspaces, and then some few additional package.json files that don't participate in the monorepo for one reason or another. It'd be nice to have a way to include these additional package.json files in the source configuration, without losing the ability to include automatically discovered package.json files from the workspaces configuration.

In other words, where the documentation says:

package.json files are resolved in this order of precedence:

  1. If --source glob patterns are provided, use those.
  2. If using Yarn Workspaces, read workspaces from ./package.json.
  3. If using Lerna, read packages from ./lerna.json.
  4. If using Pnpm, read packages from ./pnpm-workspace.yaml.
  5. Default to 'package.json' and 'packages/*/package.json'.

I'd like a way to use 2-4, while adding some additional package.json files to the sources.

Suggested Solution

Maybe there could be some pre-defined values that can be provided when using globs (1 in the above list), to also merge in the values from 2, 3, 4? MIght cause conflicts with real directories though... I don't know exactly what configuration format to use here

Thanks for the amazing tool!

@JamieMason
Copy link
Owner

Thanks @dominics.

As you rightly said, it is currently either:

  1. Define no sources and syncpack will discover them from known package manager configs (first one wins).
  2. Define sources and syncpack will only use those.

This issue can track adding some way to combine both.

In the meantime you'd need to manually duplicate the sources.

In some cases you could import './package.json' into a JS syncpack config file to reference the workspace config from there, but for pnpm projects that wouldn't be a straightforward option since its config is yaml.

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

2 participants