question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Import Chart.js without moment

See original GitHub issue

Expected Behavior

If I import chart.js over import Chart from 'chart.js' it should grab the standalone version without moment.js and with import Chart from 'chart.js/dist/Chartjs.bundled.js' it should grab the bundled one.

Current Behavior

import Chart from 'chart.js'

grabs the bundled version.

Possible Solution

Multiple entry points.

import Chart from 'chart.js' // grabs standalone
import Chart from 'chart.js/bundled' // grabs bundled

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:21
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

58reactions
codeofsumitcommented, Feb 27, 2018

it’d be great to have chartJS move from moment to date-fns though. It would be quite the file size reduction.

27reactions
aperturelesscommented, Feb 6, 2018

Well you can import the standalone

import Chart from 'chart.js/dist/Chart.js'

Or you can set an alias in your webpack.config

resolve: {
    alias: {
      'chart.js': 'chart.js/dist/Chart.js'
    }
}

Then it would pick the standalone if you import Chart from 'chart.js'

However I think it should be the default behaviour to pick the standalone version without moment.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Integration | Chart.js
Chart.js is tree-shakeable, so it is necessary to import and register the controllers, elements, scales and plugins you are going to use. # ......
Read more >
Remove Moment.js as Dependency / Reduce Bundle Size ...
You can import standalone version - not bundled one with the following line: import Chart from 'chart.js/dist/Chart.js'.
Read more >
chartjs-adapter-moment - npm Package Health Analysis - Snyk
This adapter allows the use of Moment.js with Chart.js. Moment.js is a very heavy library and thus not recommended for client-side development. However,...
Read more >
Changing from moment to Day.js — how, why and fixing vue ...
If you simply import dayjs and Chart.js in your entry file and start messing with plugins and adapters, the code splitting system isn't ......
Read more >
How to Use Different Date Formats in Chart.js - YouTube
jsIn this video we will explore how to user different date formats in Chart. js. Adding dates in Chart. js should be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found