Skip to content

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

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

Metadata

Metadata

Labels

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

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions