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
Replace remaining moment-js calls with date-fns #13728
Conversation
Codecov Report
@@ Coverage Diff @@
## master #13728 +/- ##
==========================================
- Coverage 54.33% 54.32% -0.01%
==========================================
Files 1197 1197
Lines 30596 30594 -2
Branches 5563 5562 -1
==========================================
- Hits 16623 16621 -2
Misses 12164 12164
Partials 1809 1809
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So happy to see moment go :D nice job!
@@ -1008,7 +1008,7 @@ exports[`<CreatePage /> renders and matches the snapshot 1`] = ` | |||
id="textarea-1" | |||
name="description" | |||
> | |||
Created 2021–01–30T12:34:56+00:00 | |||
Created April 1st, 2020 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want that change ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is ok, for 2 reasons:
- before the value was mocked
strapi/packages/core/admin/admin/src/pages/SettingsPage/pages/Roles/EditPage/tests/index.test.js
Lines 58 to 60 in 377597f
moment() .format.mockReturnValueOnce('2021–01–30T12:34:56+00:00') .mockReturnValueOnce('01–30-2021'); - this acts as a comment when you create a new role; the text is added to the description field on a new role, so the format difference doesn't matter that much imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Works well 👍
What does it do?
#13579 made me curious why we do have
moment-js
next todate-fns
in our codebase. Turns out: only because of one call that can easily be replaced bydate-fns
. This should remove approx. 290kb / 70kb (gzipped) from the frontend bundle and makes it clear that we are usingdate-fns
primarily for handle dates.I think it is safe to remove the check and corresponding test for
removeKeyInObject
: the function is only called by theEditViewDataManager
, which (at least since v4) should not pass around moment-js dates anymore.Why is it needed?
To keep the dependencies clean (moment-js still needs to be installed as sub-dependency though) and keep the bundle size small.
How to test it?