Multiple versions of @internationalized/date package #4987
Replies: 3 comments 9 replies
-
We have both encountered and not encountered this. We maintain, much like React, that you should only resolve to one version of any of our packages. We rely on React Context a lot, and if you have multiple versions of our packages, then you will run into problems. So we know that multiple copies of our packages will cause issues, but so long as you resolve it to one version, as you have pointed out, then there are no issues. You could re-export from our packages, but then your users are possibly beholden to your update cycles or they may inadvertently use their own copy of the package and then you're back in the same boat. We have dependencies on the @internationalized/date packages in our react-spectrum packages, so I don't think having it be a peer of yours will be quite right. As long as you include it as a dependency with a range for the value, you should be fine. I don't quite understand the suggestion in your last point. NPM can try to be a little too smart when it comes to frontend, and it will frequently try to install multiple copies of packages so as to introduce the fewest code path changes possible. This is great for servers, however, for client code, it's usually unwanted. You may need to use tools like dedupe or resolutions in order to get back to a single copy of a given package. You can also delete node_modules and your lock file for the nuclear option. |
Beta Was this translation helpful? Give feedback.
-
Hi. I am also interested in this discussion for precisely the same reasons :). |
Beta Was this translation helpful? Give feedback.
-
Have you all considered encapsulating this in the DateField exports? It feels odd to add @internationalized/date as a separate dependency for just formatting the value that's passed to the DateField. |
Beta Was this translation helpful? Give feedback.
-
We faced an issue with date components, which seems not specific to us, and we are wondering if you have also faced the same issue and what your thoughts about it are.
Working with date components, one needs to install and use @internationalized/date package to import the date classes such as
CalendarDate
. The implementation of those date components (e.g. @react-spectrum/datepicker) also imports those classes. If those imports are resolved to different installation of @internationalized/date, it leads to the TS error below, which is caused by this trick to allow for nominal type checking instead of structural:Have you encountered the same issue? We have thought of the following solutions so far:
Beta Was this translation helpful? Give feedback.
All reactions