Consider alternatives to moment.js

Bug #1990083 reported by Jane Sandberg
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Evergreen
New
Undecided
Unassigned

Bug Description

Moment.js has an informative page on their site about the project being in maintenance mode: https://momentjs.com/docs/#/-project-status/

Including moment and moment-tz in the Angular client adds a solid 870 KB to our bundle size, the majority of which is locale information for locales Evergreen doesn't support. This makes it slower for the staff client to load for users, and also likely slows down our build time.

Two of moment's suggested replacements -- date-fns and luxon -- seem worth investigating.

If we do decide to stay with moment.js, it would be worth doing something like this to only import the locales that Evergreen actually supports (which could be overriden by an installation that needs an unsupported locale, of course): https://github.com/jmblog/how-to-optimize-momentjs-with-webpack#using-ignoreplugin

You can check moment.js's contribution to our bundle size with:
- npm i webpack-bundle-analyzer
- ng build --stats-json
- npx webpack-bundle-analyzer ../../web/eg2/en-US/stats.json

description: updated
Revision history for this message
Jane Sandberg (sandbergja) wrote :

A note that date-fns and luxon both use different date format tokens than Moment does. I wonder if we could somehow migrate the date format strings in the library settings?

* Luxon's tokens: https://moment.github.io/luxon/#/parsing?id=table-of-tokens
* date-fns tokens (they use a specific unicode standard): https://github.com/date-fns/date-fns/blob/main/docs/unicodeTokens.md
* MomentJs tokens: https://momentjs.com/docs/#/parsing/string-format/

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.