1

I'm using node.js, next.js and @mui with type: "module" in package.json

import Add from "@mui/icons-material/Add";
console.log(Add)
{
    default: {
    '$$typeof': Symbol(react.memo),
    type: { '$$typeof': Symbol(react.forward_ref), render: [Function] },  
    compare: null
    }
}

is it possible to automatically return Add.default without having to remove type="module" in package.json?

if i use import { Add } from "@mui/icons-material" it works as it should, however it loads all icons which in development leads to big performance issues

user3075373
  • 44
  • 1
  • 4
  • 19
  • Are you using Typescript? – James Lawson Dec 04 '22 at 21:13
  • @JamesLawson nope. – user3075373 Dec 05 '22 at 08:15
  • In case you haven't already found this, there is an [open GitHub Issue](https://github.com/mui/material-ui/issues/35233) discussing a similar problem. Unfortunately, right now there is not much activity but might be worth watching this Issue / contributing in case an answer appears there. – James Lawson Dec 05 '22 at 14:50
  • This seems to be a relatively new issue with ESM that is currently trending. After searching around I'm seeing a few other people discuss this: [(1)](https://github.com/ajv-validator/ajv/issues/1381) , [(2)](https://github.com/luin/ioredis/issues/1642) , [(3)](https://stackoverflow.com/questions/74083446/typescript-import-esm-default-export) , [(4)](https://stackoverflow.com/questions/68940391/how-do-i-make-a-esm-cjs-module-that-doesnt-require-adding-default-to-the-i) , [(5)](https://stackoverflow.com/a/69694837/3649209) – James Lawson Dec 05 '22 at 14:53

0 Answers0