material-react-table icon indicating copy to clipboard operation
material-react-table copied to clipboard

Is their a reason @mui/x-date-pickers is in my bundle when I don't have it enabled or imported?

Open MylesWardell opened this issue 1 year ago • 8 comments

material-react-table version

3.0.1

react & react-dom versions

19.0.0

Describe the bug and the steps to reproduce it

I am using vite with the rollup-plugin-visualizer. Just curious if this is intended or if I have misconfigured the table?

Minimal, Reproducible Example - (Optional, but Recommended)

  1. Install and use material react table with a bundle analyzer
  2. See that @mui/x-date-pickers and its full bundle is included

Screenshots or Videos (Optional)

image

Do you intend to try to help solve this bug with your own PR?

None

Terms

  • [X] I understand that if my bug cannot be reliably reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.

MylesWardell avatar Dec 16 '24 03:12 MylesWardell

MRT imports it

KevinVandy avatar Dec 16 '24 03:12 KevinVandy

@KevinVandy maybe a feature request then? Why is this in the bundle? Can it be injected instead?

MylesWardell avatar Dec 16 '24 04:12 MylesWardell

Maybe in the future

KevinVandy avatar Dec 16 '24 04:12 KevinVandy

Experimenting with config options on my own rollup but their potentially is a import leak here

node_modules\material-react-table\dist\index.d.ts image

I cant see any other reason for the whole package to be imported

MylesWardell avatar Dec 18 '24 06:12 MylesWardell

Your prod bundle should only be importing the actual components used by MRT, not the entire library. Are you saying that's what's happening?

KevinVandy avatar Dec 22 '24 06:12 KevinVandy

Yes that's what's happening. Sounds like it might be an issue that only I am facing? I'll pull up a separate repo end experiment when I get back from holiday

MylesWardell avatar Dec 22 '24 06:12 MylesWardell

Experimenting with config options on my own rollup but their potentially is a import leak here

node_modules\material-react-table\dist\index.d.ts image

I cant see any other reason for the whole package to be imported

Can confirm this is an issue - x-date-pickers alone is 471kb. Image

In a minimalist example alone of only rendering MRT + grid and no other MUI components and < 10 rows of data + 5 columns (following the most basic example), I get a bundle size of 521kb (146kb gzip).

Image

Mui-modern preference does not seem to help with tree shaking so the only thing that can be done to help at all is lazy-loading.

rob2d avatar Apr 08 '25 13:04 rob2d

If I comment out these lines from node_modules/material-react-table/dist/index.esm.js

//import { DatePicker } from '@mui/x-date-pickers/DatePicker';                                                                                                               
//import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';                                                                                                       
//import { TimePicker } from '@mui/x-date-pickers/TimePicker'; 

then my bundle size goes down by 219kb. I assume this breaks something if I was using the date picker features but I don't think I am.

singpolyma avatar Nov 20 '25 06:11 singpolyma