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 6 years ago
  • Comments: 53 (20 by maintainers)

Most upvoted comments

@whitecolor can we re-open this please? Looks like ppl are still having problems. See comment from @yang for reproducible steps. Thanks!

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:

cd ...C
yalc publish
cd ...B
yalc add C
yalc publish
cd ...A
yalc add B
yarn install --force
error Package "C" refers to a non-existing file '"...A/.yalc/B/.yalc/C"'.

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.

I solved my issue with this using resolutions.

"resolutions": {
    "@ckeditor/ckeditor5-upload": "file:.yalc/@ckeditor/ckeditor5-upload"
  }

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 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 .yalc folder as part of its yalc-published contents (after adding a !.yalc/**/* line to the .yalcignore file); this allows a yalc-pushed module to contain a submodule’s contents (in its .yalc folder), without those submodules becoming part of the npm-published contents as well (since that could cause bloat/redundancy/submodule-staleness).

While zalc has 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:

cd ...C
yalc publish
cd ...B
yalc add C
yalc publish
cd ...A
yalc add B
yarn

image

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 .yalc to list of files array in package json. like

"files": [
    "README.md",
    "dist",
    "src",
    "tsconfig.json",
     ...
    ".yalc"
  ],

and run yalc publish --push or yalc push from this package. This will push the dependency package with ‘.yalc’ directory included in it, hence fixing this error.

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:

@Worthaboutapig https://github.com/Worthaboutapig

Could not install from “.yalc/project-b/.yalc/project-c” as it does not contain a package.json file

This should not be the case now.

@elie222 https://github.com/elie222 Well I tired using .yalc in a package that imports from another package. But had problems with that, the same as others.

Well actually I don’t really get what issues really are. If it is about absence of package.json in nsted packages, this should not be the case now. yalc is really very simple and transparent, there is no magic inside which could provide unexpected side effects.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/whitecolor/yalc/issues/16#issuecomment-449741835, or mute the thread https://github.com/notifications/unsubscribe-auth/AC8oX7JU14JvmuTY1EIfwfYYJGuk5Xz8ks5u8OfWgaJpZM4SKri3 .