volta-cli / volta

Volta: JS Toolchains as Code. ⚡
https://volta.sh
Other
11.15k stars 238 forks source link

Suggestion: volta should use the `directory` field of the `repository` key in `package.json` to determine root config in monorepos #1263

Open runspired opened 2 years ago

runspired commented 2 years ago

This prevents needing to have unique volta configs or re-exports in every package.json file, as long as the package.json file is correctly using the spec for specifying respository volta can easily and safely determine where the root is.

cc @chriskrycho

Royston-Shufflebotham-i2 commented 2 years ago

Btw, you can use monorepos right now without duplicating volta configuration by adding

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

to each child package package.json file. (You might need to adjust the path depending on the layout of your monorepo.)

runspired commented 2 years ago

@Royston-Shufflebotham-i2 I'm aware (hence noting it in the description). I brought up with @chriskrycho thar Volta doesn't need to do this since there's a spec it can follow instead, but it was a private convo months ago and I didn't want the knowledge to get forgotten.

SBoudrias commented 2 months ago

We're willing to work on this, would you review/accept a PR implementing this if we sent one?

chriskrycho commented 2 months ago

@SBoudrias definitely!

chriskrycho commented 2 months ago

An implementation note: we should not require it but should support it. As a bit of an open design question, we may also want to think about giving users a way to opt into that behavior, since it will otherwise be a change to the semantics of existing projects.

SBoudrias commented 2 months ago

@chriskrycho I wasn't quite sure about the directory approach per se. But I'd have in mind something akin to

That'd reduce boilerplate inside monorepos a lot.

I guess it would however change the behaviour seen today, where it'll use the machine global version instead of the defined one. But do you think that's an expected behaviour we should maintain? To me this feels like a case where the user might not have realize the versions aren't pinned (but think they are.)