![]() It’s bundle size is not the smallest, but compared to the 513KB of moment + moment-timezone, it’s still a huge improvement.Ĭheck out Part 2 (coming soon) for how we migrated the actual library.There is a logical difference between time math and date math. ![]() It has all of the utilities, timezone support and locale support that we need. A little more than a day of effort allowed us to have full confidence in our choice of luxon as our library moving forward. It was not a very long journey to arrive here honestly. The most critical of which does not calculate offset properly when entering or leaving DST. It turns out the day.js does not support daylight savings time very well, and there are numerous open issues around it on the repo. We were able to learn how both libraries worked for our use cases as well as finding a critical failure in day.js. This yielded a set of function names that we then needed to fulfill with day.js and luxon. We first started by writing the test suite against moment to have a “static” source of truth for values we trusted. Starting outside DST and adding time to end up outside DST.Starting in DST and adding time to end up in DST.Apply same timezone (time shouldn’t change).Subtracting (minutes, hours, days, weeks, months, years).Adding (minutes, hours, days, weeks, months, years).The best way we could come up with to accomplish this is to write a test suite to exercise moment’s features, then run each library through that gauntlet. The next step is to vet the remaining two libraries for the functionality we need. luxon - 71KB, Everything is included, and it relies on the INTL api for locales.spacetime - Eliminate early due to this DST comment in the readme.We need a single source of truth for IWA, and did not want to have to maintain a build process.ĭay.js - 2KB, but also needs the utc and timezone plugins (4KB), and all locales (26 KB) Eliminated due to lack of pre-built bundle.Moment - 327KB, but also needs moment-timezone (185KB)ĭate-fns - 37.3 KB, but also needs date-fns-timezone (2KB), and all locales (26 KB) Once we compiled our list of options, we got the bundle size for each of the packages including all required plugins/addons to support timezones and locales. ![]() Keep in mind that there was a time constraint, so we couldn’t examine every option. We started with recommendations from the moment deprecation guide and tossed in some fan favorites to make sure we made the best choice we could. With that in mind let’s check out the contenders. ![]() Localization, timezone, and offset support are all critical. The other major consideration is that I work for an international company with clients in 13 different languages, and countless timezones. This helps ensure the only changes between staging and production are basic configuration values. The TL DR here is that we deliver fully qualified versions of dependencies and built assets. My team chooses to deploy our web apps following the Immutable Web Apps philosophy. Moment offers a lot of functionality, and when combined with moment-timezone, the challenge is even greater. In the case of moment, this is no trivial task. The start of any journey to replace a deprecated library has to begin with finding a replacement. The old king is dead, but who’s the new king? With that I began a journey during a Hackathon to replace moment in a core library at my company. This is a big deal for the javascript community who actively downloads moment almost 15 million times a week. MomentJs recently announced that the library is now deprecated.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |