-
Notifications
You must be signed in to change notification settings - Fork 118
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
Support for date-fns v3 #260
Comments
Hey @woothu, I haven't had time to look into date-fns v3 yet. What is it that makes it incompatible? Were there significant changes to the core functions, or is it just a matter of updating this lib's dependencies? |
@marnusw there are some errors when using date-fns v3 and
|
Here is a list of breaking changes https://github.com/date-fns/date-fns/releases/tag/v3.0.0 |
It would be nice to match the major versioning of date-fns with this change, publish it as "v3.0.0". |
Yes, that's related to date-fns changing their exports. They got rid of all default exports and now you have to refactor the imports like this: // Old
import format from 'date-fns/format'
// New
import { format } from 'date-fns/format' So besides that I hope there aren't other breaking changes that affect date-fns-tz |
@StefanNedelchev already refactored imports for date-fns to new format, those errors i posted are after refactor |
Not you - the author of date-fns-tz. The library itself needs to address these changes too |
This library doesn't really work with date-fns 3 anymore. If you try to follow the documentation, you just get this:
|
@marnusw sorry for the mess! I wish I had given you a heads-up before v3.0.0 |
Edited Synopsis of what may need to be addressed (Release Notes):
Other things to think about due to
Found this out by trying to see if I could help migrate/upgrade @tuukkasp pointed out a good point that perhaps a
The stepped efforts I've done can be walked through here: This combines some stepped approaches with a breakdown into one into a scoped short-term package:
Obviously this made some decisions, but trying to look through the code it looked to mimic a lot of the original decision to base off of Giant PRs like this are difficult (at best) to sift through, so if anything like this wants to be considered for As of this edit though I will not have time until next week at the earliest it looks like. |
getting some erros trying to start my application with vite
|
is there any workaround to make it work at this point? |
The move from
For those affected and use
Then at a later date when -- Sharing a bit more about semantic versioning 🔗 if it is helpful to anyone. In the case for |
It would probably be good to release v2.0.1 of this that caps the date-fns dependency to |
This has been a help! Just a note going back a version caused errors in my code which I had to fix, nothing too major. I uninstalled date-fns and date-fns-tz: I reinstalled both at v2: |
I created a PR to update date-fns to v3. Right now some tests are failing due to a webpack loader missing. Any help is much appreciated! |
Sweet @christopherklint97 ! I shared some findings on the upgrade path as I saw it earlier in the thread if it is helpful, and will try and pull down your code and assist in review later today: I did publish a stop-gap (for myself) at: Since it did a lot more than just the minimal upgrade did not think it was in a state to do a PR here without understanding the desired path forward for the library. But may be of short-term use for some folks. |
Yeah, I believe this shouldn't be closed as v3 is still not supported |
I am also facing the same issue and I have used this temporary solution for now. This is working!!!
|
I believe it has been automatically closed when #267 has been merged. I also think it should be reopened, because even if #267 is a good step to help mark the package as compatible with date-fns@2 only, it doesn't solve the initial issue of it not being compatible with date-fns@3 #265 is the one that will fix this issue when it's merged |
|
This PR is updating minor/patch updates as well as a couple of major updates. The following dependencies are left unchanged. - `date-fns`, because `date-fns-tz` is not compatible with it yet (see marnusw/date-fns-tz#260) - `prettier-2` only exists as a temporary workaround and will not be needed anymore as soon as `jest@30` is released. (see jestjs/jest#14305) ``` date-fns ^2.30.0 → ^3.4.0 prettier-2 npm:prettier@^2 → ^3 ```
|
With these two installed:
I am getting these errors upon build: ./node_modules/date-fns-tz/esm/format/index.js:1:0-61 - Error: Module not found: Error: Package path ./format.js is not exported from package /node_modules/date-fns (see exports field in /node_modules/date-fns/package.json) ./node_modules/date-fns-tz/esm/toDate/index.js:1:0-99 - Error: Module not found: Error: Package path ./_lib/getTimezoneOffsetInMilliseconds.js is not exported from package /node_modules/date-fns (see exports field in /node_modules/date-fns/package.json) |
The same problem here, any ideas? because i'm downgrade version to v2 and many methods not exists :( |
I used this patch-package in the meantime. diff --git a/node_modules/date-fns/package.json b/node_modules/date-fns/package.json
index 2af042a..b444ab8 100644
--- a/node_modules/date-fns/package.json
+++ b/node_modules/date-fns/package.json
@@ -18,6 +18,16 @@
"module": "./index.mjs",
"exports": {
"./package.json": "./package.json",
+ "./_lib/getTimezoneOffsetInMilliseconds.js": {
+ "require": {
+ "types": "./_lib/getTimezoneOffsetInMilliseconds.d.ts",
+ "default": "./_lib/getTimezoneOffsetInMilliseconds.js"
+ },
+ "import": {
+ "types": "./_lib/getTimezoneOffsetInMilliseconds.d.mts",
+ "default": "./_lib/getTimezoneOffsetInMilliseconds.mjs"
+ }
+ },
".": {
"require": {
"types": "./index.d.ts",
@@ -678,6 +688,16 @@
"default": "./endOfYesterday.mjs"
}
},
+ "./format.js": {
+ "require": {
+ "types": "./format.d.ts",
+ "default": "./format.js"
+ },
+ "import": {
+ "types": "./format.d.mts",
+ "default": "./format.mjs"
+ }
+ },
"./format": {
"require": {
"types": "./format.d.ts",
|
@russcarver @voors please try Edit: I think it's fixed for |
confirmed
|
I think the best solution is literally just copying the function from |
Please give |
It’s working 🍾 |
It seems like
Looks like it's being imported here, I suppose these versions aren't as widely used. |
@Pinqvin I'll take another look. I only merged the PR that was created thus far. I'll ensure all the usages are cleaned up. Actually, yes, that convert to fp is probably the last one and would only affect those using the FP variant. |
@marnusw I don't know the details of the problem, but if you need any internals exposed, I can work on it. It wasn't my intention to conceal anything, here's what I did for calendar adapters: https://github.com/date-fns/date-fns/blob/main/src/format/index.ts#L20-L22 |
@marnusw also, I understand how open source can be a burden and priorities change, so if you feel like it, I can overtake the maintenance of the package and/or merge functionality into the core. I would do it on the terms that seem most fair to you. I have to mention first that despite the pile of requests, the timeline of date-fns-tz adopting v3 is absolutely fine, and I hope you're not feeling much pressure. I think you're doing a great job, and working on open-source on your terms is okay. I know how it feels as I was in such a position many times. Even though time zones were always on my mind, having independent date-fns-tz allowed me to focus on the core library, which always had something going on. I'm very grateful for that. I deeply respect your work, so I never tried to compete with or reimplement anything from this library. I have plans to extend the work I did with @date-fns/utc and do something similar with timezones, i.e., I believe that it's the best strategy for everyone, from users to maintainers, as it nourishes the ecosystem instead of killing it with fierce competition. |
@Pinqvin finally in |
And it does indeed build now, thank you! |
Please watch #273 for the official |
|
Note: I am learning to code and hence not experienced enough. In my package.json, I have the dependencies showing: Do I need to replace it with another version? I am getting the below errors: |
Have you read the changelog with regards to the breaking changes? https://github.com/marnusw/date-fns-tz/blob/master/CHANGELOG.md#v300-6-april-2024 |
Thank you very much for the reply! I went through the link you mentioned but can't figure out which one in the list I should be looking at. |
Date-fns just released a stable version 3:
Is this package going to support the new version?
The text was updated successfully, but these errors were encountered: