We should remove moment from the public API and just use timestamps and Dates
We should also consider dropping support for Moment entirely since it's purely worse than Luxon. I would especially like to get rid of Moment since it lacks timezone support and is very large
I've been switching everything over to Luxon, but cannot switch web apps that use Chart.js since Chart.js needs Moment anyway. How much of Moment does Chart.js actually use? And could it be replaced with a (much smaller) utility?
@jazoom you may be interested in https://github.com/chartjs/Chart.js/pull/5522
@benmccann Thanks for pointing that out. I searched the issues but didn't find that one for some reason.
@benmccann any idea what the hold-up is for accepting #5522 pull request?
The reviewers are all busy and doing this just as a volunteer effort on top of their day jobs
OK, thanks for clarifying, just wondering if there was some deeper refactoring required or if it somehow hinged on a future major release. Looking forward to its acceptance so that moment.js stops bloating production builds!
Hi, I don't know Luxon but you could consider dayjs?
In my app I just did a search and replace moment -> dayjs and everything worked fine.
@AoDev did the same. It hasn't been a simple search and replace but I was able to migrate the whole app from moment to dayjs within 15minutes (the only issue i encountered: en-gb locale which worked in moment has to be renamed to en in day js).
Now I need to get rid of the moment dependency of chartjs
date-fns would be a good option since you can require/import just the functions you need without bundling the entire library... I am able to get chart.js to work fine using chartjs-adapter-date-fns but I have to add moment as an external in the webpack config to prevent it from getting bunded (because of chart.js). This is more of a nuisance then it sounds since I'm using create-react-app
Edit: referenced the wrong package in the original comment
Perhaps using dayjs, which offers the same functionalities as moment.js, but with a fraction of the bundle size, would be a better option IMHO
I'm going to consider this as fixed since Chart.js has datetime adapters now and the use of moment is now optional
In v3 moment is no longer be specified as an npm dependency
Most helpful comment
date-fns would be a good option since you can require/import just the functions you need without bundling the entire library... I am able to get
chart.jsto work fine using chartjs-adapter-date-fns but I have to addmomentas an external in the webpack config to prevent it from getting bunded (because ofchart.js). This is more of a nuisance then it sounds since I'm using create-react-appEdit: referenced the wrong package in the original comment