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

Is it possible to remove moment.js dependency? #4739

Closed
shankara403 opened this issue Sep 11, 2017 · 3 comments
Closed

Is it possible to remove moment.js dependency? #4739

shankara403 opened this issue Sep 11, 2017 · 3 comments

Comments

@shankara403
Copy link

I'm currently using chart.js for very simple and lightweight Bar and Pie generation with React using react-chartjs-2 Recently, I've noticed that the moment.js dependency of chart.js is biggest chunk in my webpack bundle as shown below:

Overall bundle

alt text

Moment.js depenencies

alt text

As per the docs: http://www.chartjs.org/docs/latest/axes/cartesian/time.html seems to be the reason why moment.js is included in the first place. But fortunately for me, I do use any time scales. All I use is bar and pie with non-time labels and data.

Question: I was wondering, if there is any solution to prevent this dependency from being loaded in all the non-time chart cases. Further, I wish to enquire if I can import only specific library from chart.js or does

import {Bar,Pie} from 'chart.js'

strictly imports only those 2 without any unwanted dependencies?

@benmccann
Copy link
Contributor

Also discussed in #4303

@etimberg
Copy link
Member

An alternative would be to block the loading of moment during build. Not ideal, but it might work

@etimberg
Copy link
Member

etimberg commented Oct 6, 2017

Closing as duplicate of #4303 since it's related.

@etimberg etimberg closed this as completed Oct 6, 2017
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

3 participants