A plugin to make authoring with MUI components efficient, both for humans and bundlers.
✍️ What you write | 👏 What your bundler sees |
---|---|
import {
AppBar,
List, ListItem, ListItemAction,
makeStyles
} from "@material-ui/core";
import { Add } from '@material-ui/icons'; |
import AppBar from "@material-ui/core/esm/AppBar";
import List from "@material-ui/core/esm/List";
import ListItem from "@material-ui/core/esm/ListItem";
import ListItemAction from "@material-ui/core/esm/ListItemAction";
import { makeStyles } from "@material-ui/core/esm/styles";
import Add from "@material-ui/icons/esm/Add"; |
- Get it from npm:
npm i babel-plugin-transform-mui-imports
- Put it in your Babel config:
{ "plugins": ["transform-mui-imports"] }
@Cretezy @BjoernRave If you have a way to apply the plugin only to Next.js client bundle builds, it should work. The server build doesn't bundle
node_modules
, so ES Modules usage is not allowed there. A quick Babel preset wrapper might do the trick (no guarantees):