4 ms·
Established projects using Moment.js a lot might have a hard time migrating to something else. Quite unfortunate because there are now much nicer / better optim
by dSebastien 5y ago
Established projects using Moment.js a lot might have a hard time migrating to something else. Quite unfortunate because there are now much nicer / better optimized libraries/APIs out there today like date-fns, the new Temporal API, Luxon, etc.
For those still stuck with Moment, it's worth exploring means to reduce the impact on bundle sizes. I wrote about that a while ago: https://dsebastien.net/blog/2020-07-12-removing-moment-js-locales-from-your-angular-app-js-bundles https://dsebastien.net/blog/2020-07-12-removing-moment-js-lo...
- Alex3917 5y agoDay.js is basically a drop in replacement, and is 97% smaller. You still need to regression test, but imho it's one of the highest impact ways to spend a few hours if you care at all about performance.
- jpomykala 5y agoYa, but testing dates and times is very hard. It’s easy to miss something.
- Alex3917 5y agoTrue. But in this case the regression testing is mainly for if you miss an import, since some of the formatters require plugins. Fortunately if that happens it will be fairly obvious since iirc there will be random letters in the middle of the time string.
- dSebastien 5y agoYep, indeed there are ways to migrate, but it's not necessarily easy. For instance in my last project, we used moment-timezone, and integrated other libraries such as https://github.com/urish/ngx-moment https://github.com/urish/ngx-moment to format date/times in component templates. Of course it's possible to move away from that, but it would take time away from more useful work.