-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
@wordpress/date
: Moving away from moment
and the role of the package
#43533
Comments
Great idea. We tried something similar before. Unfortunately, the previous attempt to replace
|
Cc'ing @vcanales and @swissspidy who collaborated on the previous attempt |
I wouldn't mind working on this, but not until after 6.1. I’m a little bit familiar with |
I doubt we'd design a better API than
Yeah at this stage this is my preferred approach. Let me elaborate a little bit. Basically Gutenberg and third party plugins should use Then,
|
Regarding |
Thank your for all your work on this, @noisysocks! 👍 Regarding As such, the decision we should make, as I see it, is whether we want Neither of those options is a clear choice for me, to be honest 😕 The former is good from an engineering perspective, but it involves a lot of upfront work and loses much of its value once the migration to The latter saves us a bunch of upfront work, but punts it to the future, and assumes there will be interest and availability in migrating away from Tough choice 😕 |
Well put @sgomes! There are only two parts of the entire codebase that have ever used Also I don't think there will be any urgency to migrate from So the only value we would get from creating a wrapper around We're going to have to continue to support If we create a wrapper, we will be encouraging plugins to switch from If, however, plugins switch to tl;dr: I agree with your framing of cost of maintenance vs. cost of migration way of framing the issue but think that the cost of maintenance is very high and the cost of migration is fairly low 😀 |
Can we simply require these plugins to enqueue Having an implicit Ideally, the only endpoints we'd expose would be our own, to provide some level of insulation against changes in implementation details, such as libraries or native features used.
This is a great approach that solves the above, going forward 👍 |
Yeah definitely something to explore. Probably something to discuss in a Core JS meeting. I know we've been flexible in the past about backwards compatibility when it comes to deprecated JavaScript libraries. For instance we "broke backwards compatibility" by upgrading jQuery but did it in a fairly slow methodical way. |
With PR #43005 merged, the
@wordpress/components
package replaced its dependency onmoment
withdate-fns
.Since
moment
andmoment-timezone
are large dependencies, it would be great if we could migrate away from them entirely. The only package left requiring them is@wordpress/date
.I believe that, in order to decide on the next steps, we need to answer two questions:
What should the role of the
@wordpress/date
package be?Potential approaches:
@wordpress/date
as the centralized datetime-utils library of Gutenberg. All other packages requiring datetime-related utilities would import@wordpress/date
@wordpress/date
as complimentary to a date util library (e.g.date-fns
), which should only provide:wp_date
in PHP.\As suggested by @gziolo in #43533 (comment), in order to minimize the chance of introducing breaking changes, we could keep the
@wordpress/date
untouched, mark it as deprecated, and potentially create a new package instead (following any of the approaches proposed above).How should we replace
moment
?In the components package, so far
moment
has been partially replaced withdate-fns
(partially, because internationalization/formatting for each locale and timezones are still handled via@wordpress/date
, which internally usesmoment
).For the future, it looks like the
Temporal
APIs may be a great fit (as suggested by @griffbrad and @sgomes in #41385 (comment))The text was updated successfully, but these errors were encountered: