Closed RareSecond closed 3 years ago
I'm curious if date-fns would be easier to remove unused date-fns functions if references were included as
import addDays from 'date-fns/addDays'
instead of
import { addDays } from 'date-fns'
All of date-fns functions are being included in a default CRA app, because the includes are not using the esm feature available with date-fns. If you import functions used explicitly, rather than wildcard import, the bundle size will be significantly smaller.
Hey all, thank you for raising it and the fix. I just merged #429 and we will make a release hopefully this week. :)
(And sorry for the delay, we are discussing how to improve the project maintenance)
This has been release as 1.1.4 Please give it a try and let us know if there is any concerns. :)
date-fns
or dayjs
should be an individual choice.
For example, we can:
import AdapterDateFns from 'react-date-range/AdapterDateFns';
// import AdapterDayjs from 'react-date-range/AdapterDayjs';
return (
<DateRangePicker adapter={AdapterDateFns} />
)
Subject of the issue
What's the exact reasoning behind having date-fns as a peer dependency? This really forces users to have this in their project, while they may not use any/may use another date library.
Also, what's the reasoning behind the choice for
date-fns
? Was this chosen arbitrarily, or is there a specific reason?When you compare
date-fns
to other libraries (e.g.dayjs
), you see that there's a huge difference in size. https://bundlephobia.com/result?p=date-fns@2.11.0 https://bundlephobia.com/result?p=dayjs@1.8.22