tremorlabs / tremor

React components to build charts and dashboards
https://npm.tremor.so
Apache License 2.0
16.11k stars 465 forks source link

Large Bundle Size + Modules #489

Open kevinmitch14 opened 1 year ago

kevinmitch14 commented 1 year ago

Hey team, I have been playing around with Tremor and noticed that hot reload times really increased. After doing a bit of digging I found that the bundle size is quite large.

The bundle seems to increase by the same amount regardless if one component is being used or all components are being used.

In my Next.js v13.4.4 build, the page size in /app dir increases by about 318.6kb. This is the case if I just use <CategoryBar /> or if I use <CategoryBar /> along with other components such as <Legend /> and <Button />.

Is this expected behaviour, is there any recommendations to reduce this bundle size/the # of modules when compiling? If this is unexpected, I can create a small repo for you!

pingustar commented 1 year ago

given that the documentation says to add the whole tremor library to be purged by tailwind, I assume we are adding all styles for all components, even if you use none, one or all tremor components

in tailwind.config.js you have this line:

"./node_modules/@tremor/**/*.{js,ts,jsx,tsx}", // Tremor module

you could try to do some tree-shaking type of inclusion of the styles...

eg.

"./node_modules/@tremor/react/dist/components/input-elements/Button/**/*.{js,ts,jsx,tsx}", // Button component

I have not tested this, and it is pretty much the reason I did not decide to use tremor even though I think it is pretty cool!

mitrotasios commented 1 year ago

thanks for pointing this out, we'll have a look on how we can reduce the overhead.

dvrfluxchat commented 1 year ago
import Metric from "@tremor/react/dist/components/text-elements/Metric/Metric";
import Tab from "@tremor/react/dist/components/input-elements/Tabs/Tab";
import TabGroup from "@tremor/react/dist/components/input-elements/Tabs/TabGroup";
import TabList from "@tremor/react/dist/components/input-elements/Tabs/TabList";

This works for me. Facing the same issue.