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

Not working with mui icons 6 #5

Open
cwagner22 opened this issue Nov 23, 2024 · 1 comment
Open

Not working with mui icons 6 #5

cwagner22 opened this issue Nov 23, 2024 · 1 comment

Comments

@cwagner22
Copy link

cwagner22 commented Nov 23, 2024

After updating to mui 6, I get

Directory import 'node_modules/@mui/material/utils' is not supported resolving ES modules imported from node_modules/@mui/icons-material/esm/utils/createSvgIcon.js
Did you mean to import "@mui/material/node/utils/index.js"?

It seems to be due to mui/material-ui#43624 which uses ESM by default. I'm thinking it's causing an issue because @mui/material doesn't use ESM yet.
I've had this issue with every SSR framework I tried. I'm logging it here in case there is a solution...

From node_modules/@mui/icons-material/package.json:

  "exports": {
    ".": {
      "types": "./index.d.ts",
      "import": "./esm/index.js",
      "require": "./index.js"
    },
    "./*": {
      "types": "./*.d.ts",
      "import": "./esm/*.js",
      "require": "./*.js"
    },
    "./esm/*": "./esm/*.js",
    "./esm/*.js": "./esm/*.js"
  },

If I remove exports it works, or if I replace "import": "./esm/index.js", by "import": "./index.js",

It also works if I add

  ssr: {
    noExternal: ["@mui/icons-material"],
  },

to vite.config.ts but I think this will increase my bundle size.

@khera
Copy link

khera commented Nov 25, 2024

Using the noExternal configuration above lets it work in development mode. Once you build and deploy it will fail to load many other parts of MUI, in an endless and ultimately unfixable cycle of adding more and more of the MUI parts to the noExternal setting.

Someone suggesting using Vite's alias feature, but that doesn't seem applicable, or I couldn't figure out exactly what they meant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants