-
Notifications
You must be signed in to change notification settings - Fork 147
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
Yalc does NOT resolve dependencies of dependencies #95
Comments
I'm adding additional feedback here. This was bothering me, so I pulled down the source code for this tool and began poking around in it. Much to my surprise, I found that the code does seem to copy the .yalc directory along with the other content to each location it is deployed to. Then, after running it on my linux machine, I found that everything worked as expected. Nevertheless, I'm having the previously mentioned problem on my work macbook. I am going to continue investigating this issue further, and I will report back with any findings. Maybe I can work out why the inconsistent results are occurring. |
It would be nice if you could create repro repo and provide a description of actions and expected results. |
I will attempt to do so when I go into work on Monday. It is odd that I'm experiencing this issue on one device and not another when using your tool. |
Just chiming in to let you know I'm having the same issue on Linux. |
Hey. I have pinpointed the issue, and I have reproduce-able steps for recreating it. I also have steps for solving it. After re-reading your README.md, this issue actually makes sense now. I'll recommend two possible solutions, and leave the choice of which one up to you @whitecolor. THE PROBLEM IN DETAIL The source of the problem was the initial "publish" command. This was what moved my local project into the ~/.yalc folder. Upon inspecting the copy of it in the ~/.yalc folder, I discovered that the internal .yalc directory was missing. So all the contents of my project were published EXCEPT the local .yalc dependencies. This was why the dependency-of-dependency thing wasn't working, because when I used "yalc add" to add this project to another one, the .yalc folder was already missing and wouldn't carry over. THE SOLUTION Upon reviewing the source code, I saw you were getting a list of all files using npm-packlist. I've never worked with that library, but it gave me the idea that it might be using the package.json to determine which files to publish or not. This matches well with your README.md, which says that only the files that would be published to npm get published. So I added the .yalc directory to the "files" array of my package.json. The moment I did that, everything now worked. By explicitly including .yalc in the array of files to publish to npm, yalc now picks up that directory when runing "publish". MORE INFORMATION The default behavior of a project when it doesn't have a "files" section in the package.json is to publish everything, whereas the "files" section acts as a filter. This was why I didn't see this problem on my linux machine, the difference wasn't the OS, it was the fact that the project I tested there didn't have a files section. I have confirmed that adding such a section without adding .yalc to it causes the issue to occur on linux. NEXT STEPS As I see it, there are two possible next steps you could take.
Either way, I hope this helps folks (and you) dealing with this. EDIT I noticed a reference in your README to using .npmignore to ensure the .yalc directory gets included. I attempted to do this with no success. Only adding it to the "files" section of package.json works for me. |
If you use package.json's If you don't use I terms of which files will be included in the package |
Yep, that makes sense. I would recommend adding a section to your README explicitly calling out this issue. As I said, there are several different threads on this same issue, highlighting it as a common gotcha (and explicitly mentioning the "files" section, since .npmignore did not work for me) would be my recommendation. Regardless, at least this thread will exist for folks googling the issue. |
Ok I added some notice in docs. |
Awesome. Thank you so much. |
Great, thanks @craigmiller160, this seems to be the solution! For those reading this later I would like to add that, even if you don't have a files array in your package.json, keep in mind that npm also looks at the contents of your .gitignore file. So adding |
I have another problem. I'm using
then run,
The
Now, i use
All things goes will, but in project, it shows error I have to copy Anything I'm missing ? |
@Zaynex well |
Hi @wclr ! Thank for such a great tool! It's wonderful helper! |
@MontolioV
I don't get what you mean. |
TL;DR the best approach to not to accidentally pollute deployment package with dependencies of dependencies that I see now is to add yalc files to gitignore, then include yalc files in
When using #95 (comment) solution, dependencies of dependencies will be included in deployment. As was mentioned it's not the best option. When we publish a package to a registry, we don't expect to publish some dependencies as well. @wclr lets imagine we have 3 projects:
Project 2 depends on project 1, project 3 depends on project 1 and project 2.
If we exclude with .npmignore |
@MontolioV I'm wondering if prepublish would still delete the Does anyone have a definite way of permanently listing |
@neaumusic You may be interested in the wrapper I created for just this use-case (if I'm understanding you correctly): #16 (comment) |
|
I'm trying to be cool to avoid by sharing tailwind configs with their plugins deps without having to depend on @tailwindcss/forms in both projects: A = problem project, imports tailwind config from B (which needs @tailwindcss/forms)
-> specified in B im finding this too today, no peer dep (C) in B is downloaded by A (yalc add B) In A, I don't want to also depend on C (@tailwindcss/forms) when it should be downloaded by B |
Would this issue be solved with the |
|
So there is another issue about this same thing, issue #16 , but it was closed without being resolved. I'm opening this one because this is a problem with an otherwise great tool and it needs to be fixed.
Let's say I have three project. A, B, and C. C is a dependency of B, so I "yalc add C" to B. This adds to package.json "C": "file:.yalc/C". That is a relative path from the project to the dependency in my local yalc folder.
Then I "yalc add B" to project A. It adds B in the local .yalc folder, but the package.json inside of it still just has that relative path to C. The problem is, C NEVER GETS COPIED. I know in #16 you keep saying it works for you, but I'm telling you I and the others who commented in that thread all absolutely disagree. The relative paths in the package.json break the ability to resolve the dependencies when you nest them.
The solution is simple: use absolute paths instead of relative ones. If C is added like this: "file://Users/Me/B/.yalc/C", then everything works.
It's a very simple change, to make it use absolute instead of relative paths. Even if you just made it an option, where someone could do yalc add with a flat, that would be enough.
I'm hoping this will be taken under advisement. If I get the time I'm tempted to create a branch, PR, or fork to add this feature. I work for a company with a lot of distant contractors and this would make their lives (and mine) easier.
Thanks.
PS. Apologies about not using better code formatting. I'm writing this on mobile.
The text was updated successfully, but these errors were encountered: