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

Volta and monorepos #1100

Closed
eridem opened this issue Dec 6, 2021 · 3 comments
Closed

Volta and monorepos #1100

eridem opened this issue Dec 6, 2021 · 3 comments

Comments

@eridem
Copy link

eridem commented Dec 6, 2021

Hi, we are working in several mono-repositories. Here an example of our structure:

MONOREPO X
~/monorepo-x/.volta/hooks.json
~/monorepo-x/services/a
~/monorepo-x/services/b

MONOREPO Y
~/monorepo-y/.volta/hooks.json
~/monorepo-y/services/c
~/monorepo-y/services/d

Problem

The problem we see is that when we are in ~/monorepo-x/services/a it will try to fetch the current service .volta/hooks.json otherwise, it will jump directly to the $HOME one.

We could add the .volta/hooks.json per service, but we have hundreds of them per monorepo and this file will be repeated and unnecessary. If we repeat this per each monorepo we have, it will be thousands of duplication.

In another hand, each monorepo has different repositories, so we cannot use the $HOME one.

Desired behavior

Our desired behavior is: if you cannot find .volta/hooks.json on the current directory, go a step back on directories until you find it.

This will support having global hooks.json per monorepo without duplicating the configuration per service. E.g.

~/monorepo-x/services/a/.volta/hooks.json   ? ⨯
~/monorepo-x/services/.volta/hooks.json     ? ⨯
~/monorepo-x/.volta/hooks.json              ? ✓

~/monorepo-y/services/c/.volta/hooks.json   ? ⨯
~/monorepo-y/services/.volta/hooks.json     ? ⨯
~/monorepo-y/.volta/hooks.json              ? ✓

~/other-path/.volta/hooks.json  ? ⨯
~/.volta/hooks.json             ? ✓

Is there any way now to have this behavior?
Is it something that will be implemented in the future?

@chriskrycho
Copy link
Contributor

The way we have this designed at present is that you can extends a parent volta config in your package.json, which will correctly use the hooks from the root. So, e.g. in monorepo-x/services/a/package.json, and assuming a monorepo-x/package.json:

{
  "volta": {
    "extends": "../../package.json"
  }
}

For the sake of speed we have consciously chosen not to walk the file system like this: it can take a semi-arbitrary amount of time, depending on your folder structure. It's also not a given that it's a desired behavior for all situations like this! See some prior discussions in volta-cli/rfcs#43, #862, #282, and #950.

That doesn't make it a never, just a needs quite a bit of thought and design work, especially given we don't want to break any existing behavior!

@eridem
Copy link
Author

eridem commented Dec 14, 2021

Thanks @chriskrycho.
Although we still need to add volta section, it is a viable approach for us to go ahead with our monorepos 👍

@chriskrycho
Copy link
Contributor

Very good – closing this accordingly as a duplicate of the other issues. Thanks!

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