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

Suggestion: Use some other time library? #78

Closed
joshvanallen opened this issue Dec 7, 2018 · 17 comments
Closed

Suggestion: Use some other time library? #78

joshvanallen opened this issue Dec 7, 2018 · 17 comments

Comments

@joshvanallen
Copy link

Just as a suggestion, Moment is a fairly large library and there has been recent development in the time library area that can do 75-80% of what Moment can do. Might be worth looking into! If I can help in any way, please let me know!

@Agranom
Copy link
Owner

Agranom commented Dec 13, 2018

Hi. I've been thinking about working with locales and I guess Moment is good with that

@joshvanallen
Copy link
Author

From my understanding, date-fns is the closest time library to Moment.
date-fns/date-fns#275 (comment)

@Enngage
Copy link

Enngage commented Jan 16, 2019

@jvanallen93 Actually Luxon is closer. Its been developed by one of Moment maintainers and it eventually came under Moment umbrella. Its really, really good. Especially the way it handles locales, its immutability and the fact that its so much smaller than moment itself. API itself is also quite close to moment.

@Agranom The problem with moment (and its locales) is that its huge and it easily adds > 1MB to the angular's bundle size. This is the reason we are avoiding using Moment in Angular completely. Sure the size gets Gzipped a bit, but its still pretty heavy compared to say Luxon or date-fns. Would be really happy to see this library switch to something else so that we could include it in our project.

If I look at our app report, I find that moment + moment locales take up about 1.4 MB in parsed (minified) size:

2019-01-16 09_04_22-sqlquery1 sql - not connected_ - microsoft sql server management studio

Luxon on the other hand is 63 Kb.

@joshvanallen
Copy link
Author

@Enngage this is awesome to see and thanks for another date package to investigate!

@checketts
Copy link

I'm also interested in avoiding moment. We are already using date-fns for other calendaring/date features.

As a guess, how difficult would it be to swap out moment? Is it something I could PR?

@Agranom
Copy link
Owner

Agranom commented Jan 26, 2019

I'm totally agree with you guys. And I'll change the library once I have time. I hope it will be soon

@Enngage
Copy link

Enngage commented Jan 26, 2019

That would be really awesome, thanks! Maybe you could leverage material's DateAdapter (or create your own) so that one could use date-fns, moment or luxon or anything else should they wish to.

@Enngage
Copy link

Enngage commented Mar 1, 2019

Any news about this? Would like to switch to this lib when possible :-)

@Agranom
Copy link
Owner

Agranom commented Mar 2, 2019

Didn't have time for that. Going to start today.

@Agranom Agranom added the in progress started implementation label Mar 2, 2019
@ghost
Copy link

ghost commented Mar 4, 2019

@Agranom

Can't personally vouch for it but have read about Day.Js as an alternative

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

https://github.com/iamkun/dayjs

reference: moment/moment#2373 (comment)

@Enngage
Copy link

Enngage commented Mar 4, 2019

Nice overview of these libraries can be found here -> https://github.com/you-dont-need/You-Dont-Need-Momentjs

I'm using Luxon as (in my opinion) its the most modern and already quite mature library + I needed timezone support.

@katan
Copy link

katan commented Mar 6, 2019

Here another one interested to avoid Moment.js

@Agranom
Copy link
Owner

Agranom commented Mar 11, 2019

I've already started with luxon library

Agranom added a commit that referenced this issue Mar 17, 2019
* issue78: * change moment js to luxon

* issue78: ! fix converting time from 24h format to am/pm

* issue83: - remove forRoot() static method

* * update changelog and version

* - fix tests
@Agranom
Copy link
Owner

Agranom commented Mar 17, 2019

Done. Changed momentJs to luxon. But I'm not sure that size of the timepicker package's got smaller.
Can someone check?

@Agranom Agranom added in review awaiting feedback and removed in progress started implementation labels Mar 17, 2019
@Enngage
Copy link

Enngage commented Mar 17, 2019

@Agranom Awesome. I don't think the size of your library matters much - it's still very small. It's the moment dependencies that cause apps to bloat.

I'll switch to this library soon :-)

@katan
Copy link

katan commented Mar 18, 2019

Great work!
The angular's bundle size is reduced in ~250kb (Parsed)

Thanks a lot!

@Agranom
Copy link
Owner

Agranom commented Mar 18, 2019

Great. Hope those changes will not affect on functionality

@Agranom Agranom removed the in review awaiting feedback label Mar 23, 2019
@Agranom Agranom closed this as completed Mar 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants