TW-Elements icon indicating copy to clipboard operation
TW-Elements copied to clipboard

Uneeded chart.js scripts after bundling

Open damsfx opened this issue 2 years ago • 2 comments

In my app.js file I just add :

import { Carousel, initTE } from 'tw-elements';
initTE({ Carousel }, { allowReinits: true });

So the only added component is Carousel.

When I run webpack bundling command I get two uneeded files.

In watch mode :

node_modules_tw-elements_dist_js_chart_es_js.js
node_modules_tw-elements_dist_js_chartjs-plugin-datalabels_es_js.js

In production :
The same files, just compressed and renamed (504.js and 655.js).

Have I missed a step? I can't see why the Chart.js scripts are included in my build.

damsfx avatar Nov 15 '23 16:11 damsfx

Hi! What bunder are you using? Vite seems to handle charts pretty well and do not include their unused file to the build. I think I've seen this issue with webpack.

Unfortunately, I think you will have to remove those files manually unless you can write a config that would skip those files.

For the future there is a possibility we will be changing the charts so that the component will be removed from the main package and would be used as a different module.

juujisai avatar Nov 16 '23 06:11 juujisai

Hi! What bunder are you using? Vite seems to handle charts pretty well and do not include their unused file to the build. I think I've seen this issue with webpack.

That's my case, I'm using Laravel Mix wich is an API for Webpack.

Unfortunately, I think you will have to remove those files manually unless you can write a config that would skip those files.

We're going to do that ... but unfortunately it's not a viable solution for all the teams.
I think we're going to have to turn to another collection.

damsfx avatar Nov 16 '23 11:11 damsfx