In Mui’s documentation here they recommend using
import Button from '@mui/material/Button';
import TextField from '@mui/material/TextField';
style imports instead of
import { Button, TextField } from '@mui/material';
The reason for this, as I understand it, is that that @mui/material
style import will ultimately go through a barrel file – and bundlers like Webpack:
- May not be able to treeshake accurately for production bundles
- Will not treeshake for development bundles, giving slower development build times.
Webpack respects a exports
property in the package.json (documentation here) to declare submodules accessed via @mui/material/Button
style imports.
However, Mui doesn’t actually appear to use these in their package.json
So how are these imports working?
You need to sign in to view this answers
Leave feedback about this