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

moment is bundled with chart.js when installed from npm #7804

Closed
simonbrent opened this issue Sep 17, 2020 · 4 comments
Closed

moment is bundled with chart.js when installed from npm #7804

simonbrent opened this issue Sep 17, 2020 · 4 comments
Milestone

Comments

@simonbrent
Copy link

Expected Behavior

npm install chart.js --save should not install moment to node_modules
dist/Chart.min.js should not require moment

Current Behavior

npm install chart.js --save installs moment to node_modules
dist/Chart.min.js requires moment

Possible Solution

Do not include moment as a dependency in the npm distribution (I note it is only a devDependency in this repo)

Steps to Reproduce

  • Make a new folder
  • npm init
  • npm install chart.js --save
  • Look in the node_modules folder, see that moment has been installed
  • Look at the source code in node_modules/chart.js/dist/Chart.min.js, see require("moment")

Context

I am trying to remove usage of moment from a project which uses chart.js/dist/Chart.min.js, and am being blocked in this aim by that file's use of require('moment').

Environment

  • Chart.js version: 2.9.3
@numerized
Copy link

I think I have a related issue:

TypeError: moment.hasOwnProperty is not a function
    at mindlife-scale.entry.js:5708
    at mindlife-scale.entry.js:5703
    at mindlife-scale.entry.js:5706
    at createCommonjsModule (mindlife-scale.entry.js:16)
    at mindlife-scale.entry.js:5695
consoleError @ index-64582da5.js:2688
Promise.then (async)
loadModule @ index-64582da5.js:2706
initializeComponent @ index-64582da5.js:1924
connectedCallback @ index-64582da5.js:2083
(anonymous) @ index-64582da5.js:2416
jmp @ index-64582da5.js:23
connectedCallback @ index-64582da5.js:2416
(anonymous) @ index-64582da5.js:2451
bootstrapLazy @ index-64582da5.js:2451
(anonymous) @ mindlife-custom-scale.esm.js:121
Promise.then (async)
(anonymous) @ mindlife-custom-scale.esm.js:119

@Scan0815
Copy link

same issue ....

index-1b1ff084.js:2688 TypeError: moment.hasOwnProperty is not a function at chart-graph.entry.js:18 at chart-graph.entry.js:13 at chart-graph.entry.js:16 at createCommonjsModule (_commonjsHelpers-91fffb88.js:14) at chart-graph.entry.js:5

@etimberg
Copy link
Member

This will be fixed in the next major version (v3) which currently has a beta release available. It cannot be fixed in v2 since removing it is a breaking change. However, we do provide adapters to switch to date-fns or luxon. https://www.chartjs.org/docs/latest/axes/cartesian/time.html#date-adapters

@etimberg etimberg added this to the Version 3.0 milestone Sep 21, 2020
@Scan0815
Copy link

@etimberg right! with v3 beta it works. thx

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

4 participants