Never write your own date parsing library. Never. No exceptions. Never have I ever… So… I’ve written my own date parsing library. Why? Our story begins seven years ago in the year 2018. I made the very sensible choice to adopt luxon as the Date Parsing library for Eleventy. This parsing behavior is used when Eleventy finds a String for the date value in the Data Cascade (though YAML front matter will bypass this behavior when encountering a YAML-compatible date). This choice was good for Eleventy’s Node.js-only requirements at the time: accurate and not too big (relatively speaking). Eleventy has used luxon since @0.2.12 and has grown with the dependency all the way through @3.7.1. Now that’s what I call a high quality dependency! As we move Eleventy to run in more JavaScript environments and runtimes (including on the client) we’ve had to take a hard look at our use of Luxon, currently our largest dependency: 4.7 MB of 21.3 MB (22%) of @11ty/eleventy node_modules 229 kB of 806 kB (28%) of @11ty/client (not yet released!) bundle size (unminified) Given that our use of Luxon is strictly limited to the DateTime.fromISO function for ISO 8601 date parsing (not formatting or display), it would have been nice to enable tree-shaking on the Luxon library to reduce its size in the bundle (though that wouldn’t have helped the node_modules size, I might have settled for that trade-off). Unfortunately, Luxon does not yet support tree-shaking so it’s an all or nothing for the bundle. The Search Begins I did the next sensible thing and looked at a few alternatives: Package Type Disk Size Bundle Size luxon@3.7.1 Dual 4.59 MB 81.6 kB (min) moment@2.30.1 CJS 4.35 MB 294.9 kB (min) dayjs@1.11.13 CJS 670 kB 6.9 kB (min) date-fns@4.1.0 Dual 22.6 MB 77.2 kB (min) The next in line to the throne was clearly dayjs, which is small on disk and in bundle size. Unfortunately I found it to be inaccurate: dayjs fails about 80 of the 228 tests in the test suite I’m using moving forward. As an asi...
First seen: 2025-07-25 18:09
Last seen: 2025-07-26 16:14