prantlf / dayjs

Extended fork of Day.js - 2KB immutable date library alternative to Moment.js
https://github.com/prantlf/dayjs
MIT License
35 stars 5 forks source link

Huge bundled size #5

Open miriyalee opened 5 years ago

miriyalee commented 5 years ago

image

Hi, I found a bundle size problem.

parsed size : 177kb, it is biggest library in my react application.

I am using dayjs-ext 2.0.2, timezone-support 1.5.5 for showing UTC timestamp to user local time.

Is there any way to reduce size? Thank you.

prantlf commented 5 years ago

If you upgrade, there might be a way :-) Still, the size of the package will be decided by the time zone data, which you want to include. Also beware, that there was a bug detected in moment-timezone, which caused generation of incomplete time zone data. After fixing it, the size of the time zone data increased significantly, although it is already "packed" in strings.

The timeZone plugin in dayjs-ext imports the default "main" module from timezone-support, which supports all time zones. While timezone-support offers two other modules, which are limited to years 1900-2050 and 2012-2022 to save the package size, you cannot use them, if you import dayjs-ext/plugin/timeZone to a (compiled) React project, because the import "timezone-support" statement is hard-coded in the timeZone plugin. However, a simple web page with Githubissues.

  • Githubissues is a development platform for aggregating issues.