-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[feature-request] linking binaries from the root in workspaces #4543
Comments
+1 Yes this! |
Basically create the symlinks in the .bin folder of each workspace project for the matching hoisted dependencies that project relies on. I have to script this right now to keep everything working. |
@bryzaguy But I thought that was already how it worked, assuming you are referring to the links within Or is this issue requesting that links be placed in all packages even for dependencies only declared at the root? That seems questionable. |
I concern mostly about managing dev dependencies in one place. BTW as a workaround one can run |
This would greatly improve install time, disk usage and performance in my use case. This is one feature that sadly stops me from using yarn in most of my projects I develop. |
IMHO, if your binaries are used directly from your packages, they should be declared as dependencies of these package, not simply of the root. I personally try to keep some locality, root dependencies are only used from the root (https://github.com/vatesfr/xen-orchestra/blob/master/package.json). |
This is a small feature that can go a long way in terms of usability. I have a repo with several packages, where I'm using yarn workspaces for proper cross-package development. Many of my CLI-based devDependecies (typescript, rimraf, mocha, karma, tslint) keep repeating in every package, and I would rather control their versions in a single place (the root If I don't include them in every There are probably several ways to address this... Linking the root Maybe |
Note this is affected by #4730. Also
this seems like the real answer to me. The |
When running `yarn run` the env PATH would be set to look in node_modules/.bin, however in workspaces the root workspace .bin path was not being included. This PR adds the workspace root node_modules/.bin path after the individual package's path. Partial resolution for yarnpkg#4543
Not everyone uses Overall, this is a bad idea. I don't warn yarn guessing about my intentions. If I want a dependency in a sub-package, then I will put it there. If I want to update dependencies in multiple subrepos, then I will do that. Any functionality along the lines proposed here should be the responsibility of some tool running on top of yarn, for instance a tool which would allow you to update the dependency version in multiple sub-packages. Dependencies at the top level should mean exactly one thing, which is a dependency of the entire monorepo, such as |
Perhaps a wording difference; I submitted a PR above that adds the root's Using PATH to check the package then the root is the way I interpreted "automatically access the higher-up .bin" but I can certainly see a difference in interpretation there. I do think that each package's dependencies should be bin linked in their own |
If it is true that 1.3.2 does not bin link dependencies in their own directories, that seems like something between a severe bug, and a major design flaw, and a huge breaking change. What am I missing? I would try it but am wary of breaking my system by installing 1.3.2. The release page contains no changelog-like info for 1.3.2 so I'm having trouble finding any documentation of this change. I cannot see any commits in the range in question that appear to related to this issue. |
@wojtekmaj I fail to see how. Let's say I have a TypeScript dependency in subrepo1 and subrepo2., so I can get I sort of understand the notion that you want the bin linking in subrepos but yet not have to worry about changing versions in multiple places, but what if for some reason you do want different versions? More basically, having |
@rtm Maybe I did not fully understand. I have the following situation:
and in
In such case, npm does a symlink. Yarn, on the other hand, installs everything again in |
@wojtekmaj Now I'm really confused. Why would you add the overall, top-level package as a dependency to a sub-package (workspace)? What is your ultimate objective? Perhaps you could show some things that you want to work but aren't now or not in the way you hoped. The following should work just fine:
|
**Summary** Partial resolution for #4543. Previously, when running `yarn run` the env PATH would be set to look in node_modules/.bin, however, in workspaces the root workspace .bin path was not being included. This PR adds the workspace root node_modules/.bin path after the individual package's path. This is generally needed because #4730 ensures bin links in a workspace will be at the workspace root. With this PR, you can now `yarn run` commands in an individual package again. **Test plan** Manually tested by adding a script that runs `echo $PATH`
@rally25rs is it possible that (the feature added in) #4848 never made it into Berry? |
#4848 never made it into Berry - will this ever get ported? |
If anyone else ends up in this thread from google and wondering how you can reference a binary in a workspace which is declared only in root, a decent flow is to expose the binary in a script in the root package.json with the root package.json {
...
"scripts": {
"root:tsc": "tsc"
...
}
} and then in the workspace: {
...
"scripts": {
"build": "root:tsc"
...
}
} |
Is there a request created for this to be added to yarn modern? I like the |
I am using |
I’m trying to migrate a project from Yarn classic (v1) to modern (v4) and I think I’m running into a problem matching the reports here. The project has roughly this structure:
In the Yarn classic setup, I can run In the Yarn modern setup; however, this doesn’t work. I can run neither the root-level nor the package-level scripts because I don’t want to install This project also has further constraints that I really can’t change: packages/root-package is a git submodule that comes from a completely separate repository. That means I can’t just move out root-package’s devDependencies easily. Are the only strategies currently available to either
? Neither seem great. One significantly increases the dependency management work in the project and is messy. The other is just conceptually wrong in my opinion. The scripts related to package-a should live in packages/package-a, full stop. |
I wonder whether it would be possible to link binaries in all workspaces from dependencies declared in the root?
Right now to call binaries within a workspace one should redeclare it. It leads to trouble with keeping identical versions between workspaces.
The text was updated successfully, but these errors were encountered: