gregnb / gregnb/mui-datatables
@material-ui/core import should not be a Top-Level import
- Dominant language
- JavaScript
- Stars
- 2.7k
- Forks
- 906
- PR merge metrics
- No merged PRs in 30d
Description
I'm having an issue with my bundle size, my project is using @material-ui core components as well as mui-datatables. I'm working on shrinking my bundle size, but noticed that the entire esm library for @material-ui/core is getting bundled. I tracked down what is importing the @material-ui/core/esm/index.js module (all the components) and it was mui-datatables. This is happening because the `import { Paper, Table as MuiTable, Tooltip as MuiTooltip } from '@material-ui/core';` in `mui-datatables/src/MUIDataTable.js` is a top-level import and without tree-shaking, the entire MUI component base is pulled into the bundle.
If you think the change is allowable, I can create a PR for it.
## Expected Behavior
The [@material-ui/core docs](https://material-ui.com/guides/minimizing-bundle-size/#option-1) say that Library Authors should use path imports like this:
```js
import Paper from '@material-ui/core/Paper';
import MuiTable from '@material-ui/core/Table';
import MuiTooltip from '@material-ui/core/Tooltip';
```
## Current Behavior
Currently, in `mui-datatables/src/MUIDataTable.js`, the @material-ui/core components are imported from the top level, like this:
```js
import { Paper, Table as MuiTable, Tooltip as MuiTooltip } from '@material-ui/core';
```
## Your Environment
| Tech | Version |
|--------------|---------|
| Material-UI | 4.11.3 |
| MUI-datatables | 3.6.7 |
| React | 17.0.1 |
| browser | |
| etc | |
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.