-
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
Yarn add attempts to resolve packages we didn't ask it to install #946
Comments
I don't think this is quite right, because ultimately yarn wants to understand the complete dependency graph, and the not-yet-linked packages may affect it. Is there a good place I can learn about the strategy lerna is using to automate the linking process? |
cc @tomdale I think you use lerna? |
@wycats while I do not quite understand deep workings of Yarn, but let's imagine a dependency to be linked x has 10 more dependencies. The thing in this particular scenario is, none of them are a problem because the user did not ask yarn to install any of them, and in cases of links, the linked packages will have their separate dependencies in a different So I personally think that if Yarn could just ignore it, that would be wonderful and more in line with the NPM behavior |
@steelbrain I think the problem here is that Yarn, by design, treats the As a Lerna user myself, my recommendation would be to just publish the packages to npm. If they're not ready for public consumption, you can always just publish a stub package at version 0.0.1. What's the reason they aren't in npm now? |
@tomdale Now that I'm thinking about it. Instead of publishing meta packages to npm, if we change the order of execution in lerna that is currently
to
Will it work? Because while the stuff will not be on the registry, but will still be available in |
Let me try to make another analogy that I hope helps. In React, the model is to construct a tree of virtual DOM from component state. This tree of virtual DOM is then diffed against the previous version, and a sequence of update operations is applied to the real DOM. But in this sense, the DOM is just dumb output—the side effect of computing virtual DOM diffs. In Yarn, the In this case, asking Yarn to look at the file system as a secondary source of truth is like asking React to sometimes pull data out of the DOM in case a jQuery plugin had changed it. Not only is it an awkward inversion of the model, it is likely to have consequences that prevent many of the performance and correctness benefits of Yarn. (Which is not to say that the problem isn't worth solving, just that I think we need some way of expressing the desired semantics in the |
@steelbrain I made my above comment before reading yours, sorry about that. Your suggestion to link first, then install dependencies, was my first thought too. But I'm not sure it works because I think Yarn would still check the npm registry. Maybe someone who is more familiar with the implementation can chime in. |
The problem here is actually that you can't install individual packages without updating the dependency in npm install external-package-1 external-package-2 external-package-3
ln -s ...
ln -s ...
ln -s ... In yarn you can only either do: yarn install Which installs everything or yarn add/upgrade package-1 package-2 ... If we could run installs on a limited set of packages that would fix the issue but at the same time I don't want to add that to yarn |
@thejameskyle What is your concern on adding custom multiple modules install to yarn? |
That's not the concern, the concern is allowing an install which adds dependencies to your |
Maybe we can add a |
As I understand it, the reason Yarn will look in the registry first is so that it can generate a proper lock file, and that makes sense. First, let me describe a typical situation when you're developing two packages together than have a dependency on each other: Suppose you have a package That workflow all makes sense to me and its reasonable that there's this limbo state of mis-matched lockfiles because we're amidst making changes. Now, let me describe the same situation but you're just getting started with building these package. That is, suppose Let's also example another scenario -- suppose we have these same packages, In the last, what if If you've made it this far, I hope we're on the same page that perhaps Yarn should allow resolving linked local packages. If not, I'm happy to clarify. So here's what I think ought to be changed:
I'm keep to Lerna working with Yarn ASAP, so let me know what you think and any tips for where to look if you want me to submit a PR. |
Just forked yarn to try to do this... I don't even know where to start. |
@thejameskyle can I get some help here? |
@kittens has said to me privately that he does not want to add this feature. We're going to solve Lerna+Yarn issues by merging Lerna into Yarn. |
that sounds cool! any ideas when that might happen? |
Unsure, I don't have time to work on it now |
Ah ok. Bummer. Well try to ping here when this gets moving again. :)
…On Fri, Dec 2, 2016 at 23:21 James Kyle ***@***.***> wrote:
Unsure, I don't have time to work on it now
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#946 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABth3zu_vK_P-9bQeHL3PFMRvrIM6wl2ks5rERhhgaJpZM4KVUWf>
.
|
We are planning to this next half but it's not the most hi-pri thing for as (adoption at FB is really important). We also haven't fully mapped out what that would look like, but yes, we are thinking of effectively "merging" lerna into Yarn. Yarn is really great for using dependencies right now but it doesn't do a good job helping you maintain and publish them. We can do a lot better here. If you have ideas on what that may look like or how to get started with this work, let's talk! |
@cpojer i'd love to hear what this looks like, we could really use this functionality |
Yeah, I could use this functionality yesterday. Let's regroup early next year after the holidays and figure it out together? :) |
@fivetanley If you look at Cargo's workspaces feature, it's going to mostly look the same, just with a few minor API differences borrowed from Lerna and existing Yarn commands. |
@thejameskyle any suggestions in the meantime? I have a bunch of projects that are interdependent on each other any my strategy right now is just to My solution to the lockfiles is just to regenerate all of them whenever I change some dependencies. |
For those interested, I wrote a pretty hacky proof-of-concept that implements a subset of Lerna's behavior with Yarn (and also adds some other features I needed on the side). |
Workspaces will be a Yarn-native solution to Lerna |
@thejameskyle @kittens Guys -- thanks for working on the monorepo issues. The thing is though, lots of us are really struggling with lerna/yarn due to this issue. I.e., totally dependent on lerna for mono repo, want to use yarn (and have the yarn option for lerna ON), but tragically have to manually edit package.json files every time we add a package to the sub package. I.e., yarn is totally utterly useless in this configuration. It seems to me @thejameskyle 's lerna monorepo is going to be awesome, but can you help us in the meantime? Cheers. |
If people are still looking for a temporary solution, we (Palantir) are currently using yerna until the workspaces stuff ships. |
@michael-yx-wu do the 0.28 release or the nightlies not fit the bill for you? If so what are the missing features? |
Didn't realize that had shipped already. Could you point me to some docs (or the original PR is fine if no docs). |
Do you want to request a feature or report a bug?
This is a bug report
What is the current behavior?
The current behavior is, if we do
lerna add randomcolor
and have apackage.json
file where we have a few modules that are non-existent in the NPM registry, and are local and to be linked by lerna a few seconds later, It tries to resolve those non-existent modules and fails.We didn't ask lerna to install those modules so it shouldn't care about them, it should only throw the error when it couldn't find one of the packages we asked it to install
If the current behavior is a bug, please provide the steps to reproduce.
Described above
What is the expected behavior?
Described above
Please mention your node.js, yarn and operating system version.
This is not specific to the Node.js version or OS. I'm using [email protected]
The text was updated successfully, but these errors were encountered: