Replies: 10 comments
-
WIll the adapters be small in size? another concern with moment related to unmodular is the huge size. What are the most common operations on time and date in antd that brings in the need for a library? can we detect those and see if its better to have adapters or just write our own antd date helpers? i guess we dont want to maintain own code managing dates but if the result is less code than adapters it should be considered. |
Beta Was this translation helpful? Give feedback.
-
Should We can add a common method in rc-[xxx]-adapter like |
Beta Was this translation helpful? Give feedback.
-
The adapter should be very small. I don't think we will repalce moment with our own date helper, because we don't want break any exists code, but we can have a |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Sounds great, thanks for making moment opt-in! Appreciate it! |
Beta Was this translation helpful? Give feedback.
-
I really like this feature, any update on this ? |
Beta Was this translation helpful? Give feedback.
-
Depending on build tools to implement type adapters is not a good solution, why don't we just make |
Beta Was this translation helpful? Give feedback.
-
#10437 is a better proposal |
Beta Was this translation helpful? Give feedback.
-
#10437 is closed. Should we reconsider date-library-agnostic solution here? |
Beta Was this translation helpful? Give feedback.
-
Strong proponent of luxon. Its combines moment clean, easy to use API with the immutability of date-fns. there is at least one abstraction library available which may make this easier: https://github.com/dmtrKovalenko/date-io |
Beta Was this translation helpful? Give feedback.
-
Previous discussions #5677, ant-design/ant-design-mobile#1217.
Motivation
moment
do have some downsides like it's mutable value and un-modular. And it's road to modular seems very slow. I also found that the moment team is writing another date library called luxon. It would be a big improvement if we can make our date related components date-library-agnostic.Detailed design
Create a
rc-date-util
package. It only contains one line:rc-moment-adapter
wraps all APIs which date components used.All date related components use
rc-date-util
instead of usingmoment
directly.People can change date library through webpack's alias:
Browserify users can use aliasify:
After aliasing
rc-moment-adapter
torc-date-fns-adapter
, all dates pass to callbacks should change to native date object as well.This change won't effects any users who don't want to change moment to other date library.
Drawbacks
Rely on build tool config.
Beta Was this translation helpful? Give feedback.
All reactions