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)

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 solved my issue with this using resolutions.

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

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.

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 .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.

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

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

Users should not be publishing files to npm which are specifically meant for local development

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.

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.

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)

Currently, there is no way to tell yalc to respect the above entries, because of the way it parses the .yalcignore file.

This too would make local publishing less consistent with remote (remote content should be >= local to prevent potential lack of files).

why would users be expected to add ‘.yalc’ to package.json -> files shouldn’t yalc be responsible for that given it’s required for nested dependencies to work ?

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:

@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 .