yalc: Doesn't work with dependency of dependency
Supposing I have a main project A which has a dependency on Project-B, which in turn has a dependency on Project-C. Both Project-B and Project-C are managed as yalc dependencies.
npm install throws an error such as:
Could not install from ".yalc/project-b/.yalc/project-c" as it does not contain a package.json file.
When installing the reference to project-c, the project-b .yalc folder is the same as usual file:.yalc/project-c- however, this is then attempting to reference the dependent project within the project copied to the .yalc folder, however, it should be referencing the yalc folder from the root of the .yalc in project-b instead.
Basically, if you have a project in your .yalc folder that references another project in the .yalc repository, then it will incorrectly assume the referenced project is at the same level, when it should be looking to the root yalc folder in the parent project (i.e. project-a/.yalc)
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 1
- Comments: 54 (20 by maintainers)
@whitecolor can we re-open this please? Looks like ppl are still having problems. See comment from @yang for reproducible steps. Thanks!
I solved my issue with this using
resolutions.I’m running into the same issue.
I have a project A depending on a project B which depends on a project C.
I ran:
I’m using the latest yalc version 1.0.0-pre.27.
I do not see any nested .yalc directory inside
...A/.yalc/B.I did this with a pretty simple project setup, but let me know if you are unable to repro for some reason.
the problem is that yalc should handle that itself, it should not require the user to add ‘.yalc’ to the list of npm published files. Users should not be publishing files to npm which are specifically meant for local development
For anybody who might be stuck with this “nested dependencies” issue, this worked for me. (this solution is already mentioned way up here, but just in case)
For each dependency that has nested dependencies, add
.yalcto list offilesarray in package json. likeand run
yalc publish --pushoryalc pushfrom this package. This will push the dependency package with ‘.yalc’ directory included in it, hence fixing this error.For what it’s worth, this is the main reason I created my “wrapper around yalc” that I named zalc: https://github.com/Venryx/zalc
Basically, it monkey-patches yalc so that when you run
zalc publish/push, it adds the files in the being-published module’s.yalcfolder as part of its yalc-published contents (after adding a!.yalc/**/*line to the.yalcignorefile); this allows a yalc-pushed module to contain a submodule’s contents (in its.yalcfolder), without those submodules becoming part of the npm-published contents as well (since that could cause bloat/redundancy/submodule-staleness).While
zalchas been working fine for me, it’s not been tested enough to be “production ready” or anything; I mention it to spur ideas, and give an example of how yalc can be modified to include local copies of “dependency subtrees” rather than just a single dependency.I can give more detailed instructions on how to set zalc up for this purpose is needed; zalc’s entire source-code is only 41 lines long atm though, so that may be unnecessary: https://github.com/Venryx/zalc/blob/master/Source/Bin.ts
I just tried:
i suppose we’ll see how many people that use this lib feel comfortable publishing content intended for local development out to the public registry. i think the yalc files have no place there and i feel others with this use case will feel similarly. i will use my fork as a result
I’m afraid this is not true, the fact that one uses yalc dependency in the package doesn’t mean that it is strictly “for local development”, one may want to publish it to the remote registry as well including .yalc content and deps. And we should try to keep consistency in terms of included content here.
So I explained why it is not a valid point. Anything else preventing from adding .yalc explicitly to package content? (esp. if you are not going to publish to the remote registry)
This too would make local publishing less consistent with remote (remote content should be >= local to prevent potential lack of files).
No, yalc totally mimics npm pack/publish behavior here, it is by design. If you wan’t to publish such package to the npm you probably would want .yalc folder to be included there too.
Yalc works simple here, I don’t see a reason to introduce some ad-hoc logic to handle nested yalc dependencies, this will only complicate things.
Sorry, could you explain how nested packages are supposed to work with yalc? Are they supported or not? And if they are, what are the steps to getti g nested packages working?
On Mon, 24 Dec 2018, 16:42 Alex <notifications@github.com wrote: