Never write your own date parsing library
9 months ago
- #JavaScript
- #Eleventy
- #date-parsing
- The author initially adopted Luxon as the date parsing library for Eleventy, which was a good choice at the time.
- Luxon's large size (4.7 MB in node_modules, 229 kB in bundle) became a problem as Eleventy expanded to more JavaScript environments.
- The author searched for alternatives but found issues with accuracy (dayjs failed 80 out of 228 tests).
- The decision was made to tighten date parsing requirements, aligning with RFC 9557, which is compatible with the upcoming Temporal API.
- A new library, @11ty/parse-date-strings, was created to replace Luxon, focusing on RFC 9557 compatibility and reducing bundle size significantly.
- The new library saves ~230 kB in the bundle and reduces node_modules size from 21.3 MB to 16.6 MB.
- Other alternatives like @js-temporal/polyfill and temporal-polyfill were also considered but not chosen for Eleventy's needs.