### 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
### Problem
Coming from this Slack thread and Callstack proposal.
The
momentlibrary 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
momentlibrary 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) ordate-fns(supports tree-shaking) that could successfully replace the moment library in our app. My personal preference isdate-fnsbecause of its support for tree-shaking and wider popularity among community, but usingday.jsmay 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