-
Notifications
You must be signed in to change notification settings - Fork 160
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
TypeScript dependencies #254
Comments
Sorry, I see you already declared said dependencies as |
The This library actually only uses Therefore, I would disagree at this point and say that the support of several libraries is feasible at this point, since the libraries must be installed for Typescript, but they do not have to be used or included in the final product. If you see it differently, feel free to re-open the issue and clarify your point. |
Sorry, I didn't see your comment when I formulated my previous one. Did you get any further with it? |
Thanks for your reply. I'm still investigating. I'm actually using yarn. It's strange, because I agree, |
My Yarn is the most recent 1.x and an upgrade to v2 didn't really work yet. Regardless, I'm feeling confused. It feels somewhat strange to me that npm 7+ is required and it would't work with Yarn 1 at all. As I said, it's the first time I ever encountered an issue like this and I have a feeling that tells me this should be approached slightly differently, but I couldn't figure out how yet. This question on StackOverflow was the best I could find. The accepted answer is what seems to make sense, but then the second answer also makes sense, but it doesn't seem to work. I'm also still trying to find another repository/package with a similar problem and a solution for inspiration… Right now I'm experimenting with a potential solution, I'll let you know, probably tomorrow. |
Feel free to let me know if you have a better solution to the problem. The StackOverflow article summarises the possibilities I know quite well, although the former is not practical for me, because with my own types I wouldn't notice if something changed in a third-party library. That's why it was important to me to use the "real" types (as described in the second answer). I don't use yarn, but maybe there is a parameter or some other way to persuade yarn to install the peerDependencies? Because if I've understood you correctly, the only problem is that yarn doesn't install these dependencies, right? |
Last Saturday I continued with my investigation and I already started to write a massive comment with all my findings. I must have closed the tab before I submitted the final comment. To cut a long story short, I actually went round in circles and didn't find a quick and easy solution. And although it wasn't my intention, I somehow ended up starting to rewrite the library for my own purposes. I'm have just published the fork, in which I have removed support for third-party libraries altogether. I believe, this is not the way you want to go with this library, but feel free to take a look. I'm open to collaboration. For example, I could imagine that you use my stripped-down library as a base for a future version of your library and extend it with support for third-party libs. In my opinion it would make more sense to work on one base library than on two separate ones. Anyway, thanks for all the great work you have put into this library so far! |
At this point, I hope that yarn will provide support for peerDependencies like npm does from v6 on - because then the problem would have been solved, wouldn't it? |
I have doubts that For example, popular packages like image minifiers that support optional third-party packages, still do not list them as An example, where That's why I think, the question should be: Does the package require lib X for development? If so, add it to devDependencies; if not, don't add it. If it's required, but up to the dev to install it, add it to And like I said before, the fact that this is the first time I encountered this issue despite working on many projects with many dependencies, indicates to me that the majority of packages don't use However, I'm also not saying that the way this lib is using this option is wrong. I just don't know. But then, I'm also not sure if simply moving those dependencies from |
Both of your examples are JavaScript examples, so they automatically don't have the problem: the third-party libraries are only needed for typing. Otherwise, no dependencies are included, so the JavaScript gets by completely without these third-party libraries.
I don't think so, because if you look in the package.json, it's already there. In |
I think I remember now why moving the optional libraries to The |
Out of interest, I just created a new minimal project using NPM version 7.12.1 with dependencies import ical from 'ical-generator';
console.log(ical().toString()); Running
It looks like to me that using NPM 7 does not solve the issue either. |
I actually tested this at the time, but can do it again tonight. If it doesn't work with npm 7 (anymore), I have to change something, of course. |
If it helps, I've pushed my sample project: https://github.com/Manc/cal-example |
Okay, the modules are no longer installed automatically because of this commit, as they were marked as optional. That is, of course, unfavourable. I understand that it can be desirable to have to install as few modules as possible, but the pure use of native Date is currently not an option, as time zones are only insufficiently supported here. And these are in turn necessary when it comes to repeating events, for example. I will expand the FAQ in the README accordingly and ask Typescript users to install these modules manually. I think this is currently the most sensible way to solve this dilemma. JavaScript users do not need these dependencies and after the Typescript code is built, they are no longer needed, so they do not have to be included in productive containers or the like. |
Thanks for the 2.0.0 update! I'm just trying to upgrade my project to make use of the new version, but when I build my project with
tsc
, I get the following errors:It looks like the included
.d.ts
files import packages likerrule
,dayjs
,moment
,luxon
and more, but ical-generator has them as dev dependencies only, and to my best knowledge, this is not the correct way. If ical-generator wants to support third-party packages, it must reference them as properdependencies
inpackage.json
, not justdevDependencies
.The reason, why only those two (
rrule
anddayjs
) are missing in my project is, I requireluxon
in myself as well as another package, that requirescron-parser
, that requiresmoment-timezone
, that requiresmoment
.Personally, I think it would make sense to give up support for several third-party date utilities and reduce input dates to native
Date
or JavaScript native timestamps in milliseconds (as inDate.now()
). If you really want to support other date utilities, you must also bind support to specific versions of those as any of those could change their API at any time.I suppose my possible workarounds for now would be to either require other utilities that I don't really need in my project, or to revert back to version 1.x. If you have any tips and tricks, please let me know. Thanks!
The text was updated successfully, but these errors were encountered: