mui / mui-x

MUI X: Build complex and data-rich applications using a growing list of advanced React components, like the Data Grid, Date and Time Pickers, Charts, and more!
https://mui.com/x/
4.14k stars 1.29k forks source link

[core] Flatten imports to speed up webpack build & node resolution #10354

Open oliviertassinari opened 1 year ago

oliviertassinari commented 1 year ago

Summary 💡

Same as https://github.com/mui/material-ui/issues/35840 but for MUI X.

We also miss an eslint rule to fail the build, but this is likely missing from the main eslint configuration, so a bit outside of the scope of X.

Examples 🌈

We should be able to import deep in:

https://github.com/mui/mui-x/blob/8757e19e01795eacd190a6027ef7bb2caccfa9bc/packages/grid/x-data-grid/src/hooks/features/sorting/useGridSorting.ts#L2

https://github.com/mui/mui-x/blob/8757e19e01795eacd190a6027ef7bb2caccfa9bc/packages/x-date-pickers/src/DateTimePicker/dateTimePickerTabsClasses.ts#L4

https://github.com/mui/mui-x/blob/8757e19e01795eacd190a6027ef7bb2caccfa9bc/packages/x-charts/src/ChartsAxis/axisClasses.ts#L4

Motivation 🔦

It was raised in https://github.com/mui/mui-x/pull/10215.

Note that https://www.notion.so/mui-org/mui-utils-purpose-9a9fc9da3a004864b6c4e1f4d1f24f95 is a different problem/discussion. But regardless of either we import from base or utils, barrel imports shouldn't happen.

cc @romgrk maybe the type of performance topics you enjoy 😁. It's not about runtime performance though, mostly in dev mode.

romgrk commented 1 year ago

Just to be sure, by "importing deep" you mean being able to

import xxx from '@mui/utils/xxx';

instead of

import { xxx } from '@mui/utils';

, right?

oliviertassinari commented 1 year ago

@romgrk Correct