Skip to content

[HOLD for payment 2023-11-22] [Feature request] Replace the moment library with some lightweight date utility library #19810

Closed

Description

@mountiny

### Problem

Coming from this Slack thread and Callstack proposal.

The moment library is a powerful library but has performance disadvantages that comes from its OOP design. This design makes it fail working with tree-shaking, so it’s bundle size it’s huge (especially with internalisation or timezone support enabled) - this impacts mostly the web version of Expensify app.

Moreover, the moment library is now a “legacy project in maintenance mode” so it is not actively developed anymore.

More about above here: https://momentjs.com/docs/#/-project-status/

Solution

There are some other powerful yet lightweight date libraries like day.js (the most lightweight) or date-fns (supports tree-shaking) that could successfully replace the moment library in our app. My personal preference is date-fns because of its support for tree-shaking and wider popularity among community, but using day.js may be easier from the Expensify codebase perspective because of its API that is quite similar to the moment one (e.g. parsing date strings using constructor or day/month/year getters etc. - please check the link I’ve posted below for more details).

Context/Examples/Screenshots/Notes: More about the subject, containing the comparison of the most popular moment replacements can be found here: https://github.com/you-dont-need/You-Dont-Need-Momentjs/blob/master/README.md

  • Add an eslint rule once we are done which will prohibit adding the library back

Activity

  1. self-assigned this
    on May 30, 2023
  2. melvin-bot commented on May 30, 2023

    @melvin-bot
  3. mountiny commented on May 30, 2023

    @mountiny
    ContributorAuthor

    No need to action here now Anu, Callstack will work on this

  4. burczu commented on May 30, 2023

    @burczu
    Contributor

    Hey! It's Bartek from Callstack - expert contributor group - I'll be working on this one.

  5. mountiny commented on May 30, 2023

    @mountiny
    ContributorAuthor

    Thanks, please, first post a plan of how to exectute this migration before you go ahead.

  6. mountiny commented on Jun 7, 2023

    @mountiny
    ContributorAuthor

    @burczu would you be bale to share a plan for this project and some ETA, thanks!

  7. burczu commented on Jun 9, 2023

    @burczu
    Contributor

    Hey @mountiny! Sorry for being silent in this issue - I'm 100% involved in the Secure Logins issue (migration to use accountID's instead of emails in personal details) right now and had no time for anything else. I'll do my best to share some plan for this issue today or on Monday.

  8. 96 remaining items

  9. mountiny commented on Nov 14, 2023

    @mountiny
    ContributorAuthor

    Thanks for continued work on this ❤️

  10. changed the title [-][Feature request] Replace the moment library with some lightweight date utility library[/-] [+][HOLD for payment 2023-11-22] [Feature request] Replace the moment library with some lightweight date utility library[/+] on Nov 15, 2023
  11. melvin-bot commented on Nov 15, 2023

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  12. melvin-bot commented on Nov 15, 2023

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.99-0 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2023-11-22. 🎊

    After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

    • External issue reporter
    • Contributor that fixed the issue
    • Contributor+ that helped on the issue and/or PR

    For reference, here are some details about the assignees on this issue:

    • @burczu does not require payment (Contractor)
    • @allroundexperts does not require payment (Eligible for Manual Requests)
    • @waterim does not require payment (Contractor)
  13. melvin-bot commented on Nov 15, 2023

    @melvin-bot

    BugZero Checklist: The PR adding this new feature has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

    • [@burczu / @allroundexperts] Please propose regression test steps to ensure the new feature will work correctly on production in further releases.
    • [@anmurali] Link the GH issue for creating/updating the regression test once above steps have been agreed upon.
  14. mountiny commented on Nov 16, 2023

    @mountiny
    ContributorAuthor

    @allroundexperts could you please summarize what needs to be paid here to you, it was couple of PRs.

    No Testrail cases are needed fo this, it was a migration of a package for performance reasons and no new behaviour has been added in this issue

  15. allroundexperts commented on Nov 26, 2023

    @allroundexperts
    Contributor

    Hi @mountiny!

    It's been a long issue but I've tried to summarise the payment below. Please let me know if I missed something.

    1. Datetime polyfill, removed moment.tz.guess() #26248 (This caused a regression but it was found after 7 days it was deployed to production) -> Flat review ($500)
    2. [NoQA] feat: Remove moment from the project (Except Datepicker) #28175 -> Flat review ($500)
    3. Feat: Remove moment from datepicker #29062 -> Had a regression and was reverted and then redone here. The second go had regressions as well. So the penalty doubles. ($125)
    4. [NoQA] Feature: Remove moment fully #31071 -> Flat review ($500)
  16. mountiny commented on Nov 27, 2023

    @mountiny
    ContributorAuthor

    Sounds good to me, Could you please request $1625 on NewDot and note here, then we can close this issue. Thanks!

  17. allroundexperts commented on Nov 27, 2023

    @allroundexperts
    Contributor

    All done @mountiny!

  18. mountiny commented on Nov 28, 2023

    @mountiny
    ContributorAuthor

    Thanks, we should be all good here and we can close, thanks @waterim and @burczu and @allroundexperts for the effort here

  19. JmillsExpensify commented on Dec 13, 2023

    @JmillsExpensify
    Contributor

    $1,625 payment approved based on this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionNewFeatureSomething to build that is a new item.WeeklyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions