-
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
nohoist installs peerDependencies if root package.json has it #5520
Comments
hmm... the current implementation goes like this: if the peerDependency is fulfilled, it is treated like a regular package, thus subject to all hoist/nohoist logic. (see code). to make sure left-pad created because of the logic mentioned above, I tried the following with your repo:
I can see why you expected the peerDependencies to be exempt from "nohoist", but I can also see if we flip the logic, others can equally argue that peerDependencies should be nohoist if the pattern clearly said "proj/**"... yarn has to pick one definition and right now it is the later. This is not a bug, however, there are a couple of options you can try:
good luck. |
That doesn't sound right. A peerDependency, just by its wording, means that it expects that dependency to be a peer ( I am not using explicit nohoist because in my use case I want all of a project's dependencies to be nohoisted to the project, as if it was its own isolated package. I expect the project layout with my config to look like the following:
Is this not reasonable? |
not really... peerDependencies:
peer dependency is just a dependency with the extra constraint. The word "peer" means this dependency should align with its peer's version otherwise report error. you could try option-2 (but you will need #5442) |
From the description you linked me:
Emphasis on "a single copy". Because I'm installing |
yarn, by default, always deploy "a single copy" of a given package@version, whether it is peerDependencies or not. The only exception is when you specify nohoist. If you are arguing that yarn should never nohoist the package as long as it is in the peerDependencies, try to think about the opposite use case: what if people do need to nohoist the peerDependencies package because the library doesn't work in the workspaces? I hope you can see yarn can't have it both ways. I think you are better off with option-2, you will find that it gives you what you asked for and more... |
I'm having a similar issue, and in my case having the peer dependency be installed in the package's node_modules is breaking my build because the bundler is treating it as 2 separate libraries :( If I manually remove the peer dependency it works again. |
This fixes jupyterlab#6709, and is a follow up to jupyterlab#6572. It separates building vega assets from the rest of our package management. That way, we can avoid any hoisting issues that we were seeing (possibly from yarnpkg/yarn#5520). To test this, you can try this notebook which should render both versions without errors: https://gist.github.com/saulshanabrook/97c28550ab12e684adc3c325038537ce
Closing as fixed in v2 |
Do you want to request a feature or report a bug?
bug
What is the current behavior?
if a workspace package has a peerDependency that the root package.json has in its devDependencies (+ dependencies?), and the dependency is nohoisted for the workspace package, it gets installed in the workspace package's node_modules
If the current behavior is a bug, please provide the steps to reproduce.
repo: https://github.com/SEAPUNK/yarn-nohoist-peerdep
clone,
yarn install
, and see thatnice/node_modules/left-pad
exists (and subsequently,proj/node_modules/left-pad
exists as well)What is the expected behavior?
left-pad
should not be installed innice/node_modules
Please mention your node.js, yarn and operating system version.
nodejs 8.9.4
yarn 1.5.1
macOS high sierra
The text was updated successfully, but these errors were encountered: