victorgarciaesgi / vue-chart-3

📊 A simple wrapper around Chart.js 3 for Vue 2 & 3
https://vue-chart-3.netlify.app/
MIT License
309 stars 108 forks source link

Tree shaking chart.js #89

Closed lsnow99 closed 2 years ago

lsnow99 commented 2 years ago

Describe the bug

Having trouble getting tree-shaking to work with Chart.js and vue-chart-3

To Reproduce

In my main.js:

// Import depedencies for vue-chart-3 from chart.js
import {
  Chart,
  BarElement,
  Tooltip,
  Legend,
  BarController,
  CategoryScale,
  LinearScale,
  PieController,
  ArcElement,
} from "chart.js";
Chart.register(
  BarController,
  BarElement,
  Tooltip,
  Legend,
  CategoryScale,
  LinearScale,
  PieController,
  ArcElement
);

I am getting this result when I analyze my vendor bundle: image

In vue-chart-3/dist/components.js I see this (line 7 for me): const chart_js_1 = require("chart.js");

So is it possible vue-chart-3 isn't using tree shaking?

Version of vue-chart-3

v3.0.9

Version of Vue

3.2.29

lsnow99 commented 2 years ago

Looking into it more, it may be that my visualizer tool does not have great support for treeshaking: https://github.com/btd/rollup-plugin-visualizer/issues/96