material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

I'm using mui v5.11.0, After install that some errors are occurred in my project

Open rajagopal1997 opened this issue 2 years ago • 9 comments

Duplicates

  • [X] I have searched the existing issues

Latest version

  • [X] I have tested the latest version

Steps to reproduce 🕹

Link to live example:

Steps:

1.Check my Images 2.how to solve that issue

Screenshot (54) Screenshot (55)

Current behavior 😯

No response

Expected behavior 🤔

No response

Context 🔦

No response

Your environment 🌎

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

rajagopal1997 avatar Dec 14 '22 12:12 rajagopal1997

@FjVillar i'm using mui v5.11.0, but errors are occurred if you have any doubts, check my above images

rajagopal1997 avatar Dec 14 '22 12:12 rajagopal1997

Please share a repository that we can reproduce.

siriwatknp avatar Dec 15 '22 07:12 siriwatknp

In my library I'm getting reports that my debounce import is no longer valid https://github.com/KevinVandy/material-react-table/issues/257

Apparently, this no longer works

import debounce from '@mui/material/utils/debounce';

I'm pushing an emergency fix with this

import { debounce } from '@mui/material/utils';

But I'm going to get a log of complaints while devs install incompatible versions

KevinVandy avatar Dec 15 '22 13:12 KevinVandy

Hi @siriwatknp,
I confirm, this is pretty serious 🥵, it affect all Next.js setups.

Reproduction:

git clone https://github.com/garronej/react-dsfr-next-demo  
cd react-dsfr-next-demo
yarn
yarn dev

The repo is pinned on @mui/material: 5.10 so it work. Now if you update @mui/material to 5.11 you'll get the errors.

image

Reason of the bug: Since 5.11 it's pulling an ESM distribution of MUI instead of CJS. There are ways to tell Next.js to transpile specific dependencies but by default it doesn't.

garronej avatar Dec 15 '22 21:12 garronej

@garronej Thanks! We are figuring out what happened.

siriwatknp avatar Dec 16 '22 03:12 siriwatknp

See #35489 for an explanation of what happened. Long story short - the current format is the one we had before 5.10.3. So it should work the same way as the older versions.

@garronej A brand new Next.js project with Material UI 5.11.0 works fine. Some custom config value likely causes problems after upgrading. I'm investigating it.

https://mui.com/material-ui/guides/minimizing-bundle-size/#option-one-use-path-imports

Apparently, this no longer works import debounce from '@mui/material/utils/debounce';

@KevinVandy You're not supposed to use such deep imports. As noted in https://mui.com/material-ui/guides/minimizing-bundle-size/#option-one-use-path-imports, we only support up to 2nd level of subpaths.

@garronej It seems that react-dsfr suffers from the same issue: https://github.com/codegouvfr/react-dsfr/blob/main/src/mui.tsx#L14

michaldudak avatar Dec 16 '22 07:12 michaldudak

@garronej It seems that react-dsfr suffers from the same issue: https://github.com/codegouvfr/react-dsfr/blob/main/src/mui.tsx#L14

With react DSFR this is by design, the lib does not provide ESM distribution (to be able to import assets internally) and explicitely provides setup instructions to make it work.

image

garronej avatar Dec 16 '22 09:12 garronej

I meant that it has the same issue as @KevinVandy's code - it imports from a path three levels deep.

michaldudak avatar Dec 16 '22 11:12 michaldudak

I meant that it has the same issue as @KevinVandy's code - it imports from a path three levels deep.

Ah ok! Thank you very much.
Indeed, if I avoid importing from path I'm not supposed to be importing things works.
I can't import the default shadows directly though but that's no big deal...

Sorry for the falsly alarmin report and thank you for the quick explaination.

garronej avatar Dec 16 '22 14:12 garronej

It sounds like @KevinVandy and @garronej issues are answered but might not be related to the main issue. Waiting for @rajagopal1997 for more details.

siriwatknp avatar Dec 19 '22 03:12 siriwatknp

yeah @siriwatknp it's solved my problem, im installing npm i @mui/material --force after installing forcely errors are resolved...

rajagopal1997 avatar Dec 19 '22 05:12 rajagopal1997

Thanks for the info. I'm closing this issue then.

siriwatknp avatar Dec 19 '22 08:12 siriwatknp