react-datepicker icon indicating copy to clipboard operation
react-datepicker copied to clipboard

Upgrade to `date-fns` version 3

Open hueter opened this issue 1 year ago • 6 comments

There are some mild breaking changes in date-fns version 3, particularly around imports. Codebases that use date-fns and react-datepicker are blocked from upgrading date-fns until react-datepicker updates this dependency.

hueter avatar Jan 02 '24 18:01 hueter

I could use some help to upgrade this in our package. I'm preparing a major upgrade with some breaking changes and could include this as well ideally.

martijnrusschen avatar Jan 04 '24 09:01 martijnrusschen

Tried to get the project running so I could look at contributing however encountered an issue getting the project to build (something about command 'tee' not found).

When I migrated some of my own code it was just a case of updating the format of the import statements which I was able to do with a regex find and replace. e.g. import parse from "date-fns/parse"; -> import {parse} from "date-fns/parse";

I have also found a few places where there are imports from the root of date-fns, these need replacing import { isSunday } from "date-fns" -> import { isSunday } from "date-fns/isSunday "

I will have another go at getting the project running next week.

fsuk avatar Jan 19 '24 10:01 fsuk

Awesome, sounds good. I'll be here to review the PR once you have it ready.

martijnrusschen avatar Jan 19 '24 10:01 martijnrusschen

Tried to get the project running so I could look at contributing however encountered an issue getting the project to build (something about command 'tee' not found).

When I migrated some of my own code it was just a case of updating the format of the import statements which I was able to do with a regex find and replace. e.g. import parse from "date-fns/parse"; -> import {parse} from "date-fns/parse";

I have also found a few places where there are imports from the root of date-fns, these need replacing import { isSunday } from "date-fns" -> import { isSunday } from "date-fns/isSunday "

I will have another go at getting the project running next week.

Are there any advantages to importing from the subfolder instead of the root package itself now that everything are named exports? The usage doc themselves show import { isSunday } from "date-fns"; for ESM and you would save on multiple lines of imports from the same package.

iernie avatar Jan 19 '24 11:01 iernie

Tried to get the project running so I could look at contributing however encountered an issue getting the project to build (something about command 'tee' not found). When I migrated some of my own code it was just a case of updating the format of the import statements which I was able to do with a regex find and replace. e.g. import parse from "date-fns/parse"; -> import {parse} from "date-fns/parse"; I have also found a few places where there are imports from the root of date-fns, these need replacing import { isSunday } from "date-fns" -> import { isSunday } from "date-fns/isSunday " I will have another go at getting the project running next week.

Are there any advantages to importing from the subfolder instead of the root package itself now that everything are named exports? The usage doc themselves show import { isSunday } from "date-fns"; for ESM and you would save on multiple lines of imports from the same package.

I've found that in some projects which don't have tree shaking importing from the root package results in the WHOLE date-fns package being included in the output bundle instead of just the functions you need. This can result in a much bigger bundle size, especially if using locales.

Only found this out after using https://www.npmjs.com/package/source-map-explorer

fsuk avatar Jan 19 '24 11:01 fsuk

Closed via https://github.com/Hacker0x01/react-datepicker/commit/68236d8d82d2e1f4bf94252a7acef4800d027637?

danilofuchs avatar Feb 19 '24 18:02 danilofuchs

( cc. @martijnrusschen )

yuki0410-dev avatar Mar 24 '24 15:03 yuki0410-dev