Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library Size #144

Closed
ccurtin opened this issue Jan 31, 2019 · 12 comments
Closed

Library Size #144

ccurtin opened this issue Jan 31, 2019 · 12 comments

Comments

@ccurtin
Copy link

ccurtin commented Jan 31, 2019

First of all, really nice job! Exactly what I was looking for.

I just have a little concern with the size of the library, do you know why it's over 100KB when compressed? Are you utilizing another(larger) library?

Thanks!

@ccurtin
Copy link
Author

ccurtin commented Jan 31, 2019

Never mind, looks like it's because of moment-timezone

@lostpebble
Copy link

lostpebble commented Mar 8, 2019

Yea its massive. Surely there is a way to make it smaller? Do we need all the locales that come with moment-timezone? Isn't that mostly for language stuff.

This is a bit ridiculous:

image

Like what the heck is that data/packed thing? Its like 5 times the size of the original moment library!

Never mind: moment/moment-timezone#697

I see it is all the timezone data for the past however many years. Damn timezones... we should just get rid of them altogether (on this planet, I mean - not the library).

@lostpebble
Copy link

Good news for anyone using webpack and not using the timezone aspect of this library.

I put this in my webpack plugins (basically replaces moment-timezone with regular moment and removes all locales):

plugins: [
      new webpack.NormalModuleReplacementPlugin(
        /moment-timezone/,
        'moment'
      ),
      new webpack.IgnorePlugin({
        contextRegExp: /moment/,
        resourceRegExp: /^\.\/locale$/,
      }),
    ],

Much nicer:

image

@harrisiirak
Copy link
Owner

@lostpebble thanks for bringing this up! We could possibly remove moment-timezone dependency in the future (date-fns is rather lightweight and sane library I've been using instead of moment monolith lately). Therefore I'm not closing this issue atm.

@ghost
Copy link

ghost commented Mar 12, 2019

Day.Js is a nice alternative to me with etc support

⏰ Day.js 2KB immutable date library alternative to Moment.js with the same modern API

https://github.com/iamkun/dayjs

@lostpebble
Copy link

lostpebble commented Mar 12, 2019

@xxyuk the biggest issue is timezone support, which Day.Js doesn't seem to have: iamkun/dayjs#46

Supporting timezone is always going to be a massive amount of data because of the fact that every nation in the world has pulled a random number out of their ass to define an irrelevant time that they think the clock should display when the sun rises and sets (sometimes multiple numbers and the can be different at multiple times during the year too...).

Day.Js seems to have a better way of dealing with locales though, and the rest of the library is smaller as well I think. So its a good choice if there wasn't any need for timezone support.

@santigimeno
Copy link
Contributor

I think using something like https://github.com/yurikuzn/moment-timezone-data-build with moment-timezone might be acceptable for many.

wrt date-fns, it's very nice but last time I checked the tz support wasn't there. Is it now available?

@chiptus
Copy link

chiptus commented Sep 23, 2019

maybe just let the user supply instances for moment himself?

@tjk
Copy link

tjk commented Jan 13, 2020

I have a port to luxon here: https://github.com/tjk/cron-parser/tree/luxon

Can it help this library at all?

@harrisiirak
Copy link
Owner

@tjk looks nice... but isn't ´luxon´ even heavier (judging this based on the package size) than ´moment-timezone´?

@tjk
Copy link

tjk commented Jan 26, 2020

moment-timezone depends on moment, though. See here:

@harrisiirak
Copy link
Owner

With new cron-parser@3.0.0 (switched from moment-timezone to luxon, thanks @andytson) there are some good news, bundle size is reduce around 4x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants