The Wayback Machine - https://web.archive.org/web/20220422132404/https://github.com/gregnb/mui-datatables/issues/1676
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@material-ui/core import should not be a Top-Level import #1676

Open
ghost opened this issue Mar 4, 2021 · 4 comments
Open

@material-ui/core import should not be a Top-Level import #1676

ghost opened this issue Mar 4, 2021 · 4 comments

Comments

@ghost
Copy link

@ghost ghost commented Mar 4, 2021

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 say that Library Authors should use path imports like this:

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:

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
@wdh2100
Copy link
Collaborator

@wdh2100 wdh2100 commented Mar 9, 2021

ref : #1603

gooood! 👍

@ghost
Copy link
Author

@ghost ghost commented Mar 11, 2021

Thanks for making the change! How often are changes made to the main product? Just curious when we can expect to see this in mui-datatables npm registry.

@wdh2100
Copy link
Collaborator

@wdh2100 wdh2100 commented Apr 3, 2021

@tylerg-smt

sorry

release 3.7.7

@wdh2100 wdh2100 closed this Apr 3, 2021
@ghost
Copy link
Author

@ghost ghost commented Apr 9, 2021

Hello, I believe we should re-open this issue as I found 5 more files importing the Top-Level @material-ui/core. Please see my PR #1698

Alternatively I can create a new issue if that is preferable.

@wdh2100 wdh2100 reopened this Apr 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant