-
Notifications
You must be signed in to change notification settings - Fork 245
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 doesn't look at parent package.json in monorepo workspaces #862
Comments
Monorepo support was added by way of adding a new As to why we didn't go with just walking upwards to find any parent
|
@rwjblue Thank you. That's a really helpful response. I hadn't spotted that bit of config (nor the rfcs repo). Yep, I totally get the concern about the extra IO. I'm slightly less convinced about the obfuscation concern: Node itself already walks up directory trees looking for packages. And for the workspace configuration, I don't think any parsing of But, |
I also expected this to be available out of the box. Repeating the #282 commenters also talked about something similar. |
Yes, in practice it turns out to be quite a pain. If I have a default Node version of v14, and a monorepo with 10 packages in it, 9 of which are set to Node v12 via an So, in practice, I'm finding that - contrary to the text that @rwjblue quoted - the current behaviour actually serves to obfuscate the platform-sourcing behaviour somewhat because it goes against the expectations set by other NodeJS tools which tend to inherit settings down through the file-system. I'm not going to reopen this issue myself as we're almost used to behaviour now. But it is an irritant that requires me to explain this behaviour every developer in my org who comes across Volta. |
@rdsedmundo and @RoystonS thanks for the extra context! I appreciate the point about how Volta's approach is breaking the expectations of other tools in the NodeJS ecosystem, which is a significant issue. Between #282 mentioned above, this and #983, I think there's definitely room for significant improvements to Volta's resolution logic. It's not a trivial change and will require a fair amount of design work, but there's a lot of value to be found. |
Volta (0.9.1) currently abandons its search for package information too early when used in monorepos. It consults only the local package's
package.json
instead of walking up the directory tree and checking the workspacepackage.json
as well.Let's say I have a typical monorepo containing a top-level
package.json
and a child package with its ownpackage.json
:monorepo/package.json
monorepo/packages/pkg1/package.json
(typically there'd be many such child packages, but I'm keeping the example simple here.)
I'd expect the following behaviour:
monorepo
folder would consultmonorepo/package.json
when looking for package version specifiers. This does work correctly.pkg1
folder would consult the localpkg1/package.json
when looking for package version specifiers. This works correctly.pkg1
, Volta should continue up to the parent directory (following something similar to the node package resolution process) and check for package specifiers there too. This does not currently appear to happen. As a result, Volta incorrectly ignores tool pinning and package versions intended for use across the entire monorepo.Here's a tiny example monorepo, with the structure as above. The top-level package.json contains some Volta tool pinning and the child package does not: https://github.com/RoystonS/volta-monorepo-issue
Here's an example of the output with such a repo:
My top-level
package.json
hasnode
pinned at12.8.1
andyarn
pinned at1.22.10
. However, insidepkg1
, I instead get the global default version of node (12.19.0
in my case) and no yarn because I haven't selected a default version.I'd expect Volta to be continuing up and scanning the workspace
package.json
instead of deciding - having found apackage.json
insidepkg1
- that its search was complete.I can see some discussions of this issue in #378, which was closed some time ago, and there are other complicated discussions of rc files. I'm hoping that in order to get things working correctly in monorepos it's "just" a case of walking up the tree, looking for
package.json
files?The text was updated successfully, but these errors were encountered: