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

Next 14.0.4 breaks Mui integration that worked with 14.0.3 and older versions #59804

Closed
1 task done
schimi-dev opened this issue Dec 20, 2023 · 17 comments · Fixed by #60685
Closed
1 task done

Next 14.0.4 breaks Mui integration that worked with 14.0.3 and older versions #59804

schimi-dev opened this issue Dec 20, 2023 · 17 comments · Fixed by #60685
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked

Comments

@schimi-dev
Copy link

schimi-dev commented Dec 20, 2023

Link to the code that reproduces this issue

https://github.com/schimi-dev/next-mui-bug-reproduction

To Reproduce

  1. Run the application with npm run dev
  2. Go to http://localhost:3000

Current vs. Expected behavior

Current behavior

The console log:

Internal error: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:43345)
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:43088)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46298)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at a_ (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:50165)
    at ak (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:49406)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46647)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:41727)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46298)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:41727)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46298)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at ag (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:7923)
    at C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:13014
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:13038)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46298)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at ag (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:7923)
    at C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:13014
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:13038)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46298)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at ag (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:7923)
    at C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:13014
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:13038)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46298)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at ag (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:7923)
    at C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:13014
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:13038)
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:43088)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46298)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:41727)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46298)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at ag (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:7923)
    at C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:13014
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:13038)
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:43088)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46298)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at a_ (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:50165)
    at C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:38901
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:39374)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46298)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at a_ (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:50165)
 ⨯ Internal error: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:43345)
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:43088)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46298)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at a_ (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:50165)
    at ak (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:49406)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46647)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:41727)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46298)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:41727)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46298)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at ag (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:7923)
    at C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:13014
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:13038)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46298)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at ag (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:7923)
    at C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:13014
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:13038)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46298)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at ag (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:7923)
    at C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:13014
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:13038)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46298)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at ag (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:7923)
    at C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:13014
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:13038)
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:43088)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46298)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:41727)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46298)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at ag (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:7923)
    at C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:13014
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:13038)
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:43088)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46298)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at a_ (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:50165)
    at C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:38901
    at ab (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:39374)
    at e (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:46298)
    at aS (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:48276)
    at a_ (C:\Users\schimpelsberger\schimi_dev\next-mui-bug-reproduction\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:35:50165)

The UI in the browser:
next-mui-error

Expected behavior

No error is logged to the console.
The UI in the browser is displayed without an error.
(That's how the app behaved with 14.0.3)

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
Binaries:
  Node: 20.10.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.0.5-canary.19
  eslint-config-next: 14.0.5-canary.19
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Additional context

The integration between Mui and the App Router was done according to:
https://mui.com/material-ui/guides/nextjs/

These issues might be related:
#59386
#59535

This discussion is related:
#59534

NEXT-1967

@schimi-dev schimi-dev added the bug Issue was opened via the bug report template. label Dec 20, 2023
@OlegLustenko
Copy link

OlegLustenko commented Dec 20, 2023

We have the same issue!

It was introduced with this PR #59254

So 14.0.4-canary.41 version is fine, but everything higher than this breaks MUI

ccing folks who worked in the relevant PRs

cc: @shuding @huozhi

@shuding
Copy link
Member

shuding commented Dec 20, 2023

Thanks for the reproduction! Also cross-posting it here: #59254 (comment). We will be taking a look.

@maklavani
Copy link

maklavani commented Dec 25, 2023

MUI created a new page for installation on Next.js.
Next.js Integration.

Installing the dependencies

npm install @mui/material-nextjs @emotion/cache

Configuration

Inside app/layout.tsx, import the AppRouterCacheProvider and wrap all elements under the <body> with it:

 // app/layout.tsx
+ import { AppRouterCacheProvider } from '@mui/material-nextjs/v13-appRouter'; // or `v14-appRouter` if you are using Next.js v14

 export default function RootLayout(props) {
   const { children } = props;
   return (
     <html lang="en">
       <body>
+        <AppRouterCacheProvider>{children}</AppRouterCacheProvider>
       </body>
     </html>
   );
 }

@schimi-dev
Copy link
Author

schimi-dev commented Dec 26, 2023

@maklavani

Yes I know that, my reproduction setup includes the new way of integration. But with Next 14.0.4 it works neither way. The 'old' way where you have to write your own ThemeRegistry and the new way, that is included in the reproduction lead to the same error.

@maklavani
Copy link

maklavani commented Dec 26, 2023

@schimi-dev
I had the same issue then I added 'use client' on every page where I used MUI and it worked.

@kiranvj
Copy link

kiranvj commented Dec 27, 2023

Having the same issue with "next": "14.0.4", "@mui/material": "^5.15.2", "@mui/material-nextjs": "^5.15.0"

image

I could fix it with below work arounds, but the expectation is to work without these.

Fix 1 : Use default exports

import Box from '@mui/material/Box';

instead of

import { Box } from '@mui/material';

Fix 2: Use use client; where ever you use named export like below.

'use client';
import React from 'react';
import { Box } from '@mui/material';

@astrodomas
Copy link

astrodomas commented Dec 29, 2023

@schimi-dev I had the same issue then I added 'use client' on every page where I used MUI and it worked.

But that's not a solution.

Experiencing the same issues also.

@joshke
Copy link

joshke commented Dec 29, 2023

+1 same issue. None of the two fixes are viable solutions for my project.

@astrodomas
Copy link

Also, does anyone know if @mui/lab, @mui/system, @mui/base are covered with Nextjs out of the box @mui package optimization?

@2chanhaeng
Copy link

I also fixed this error with @kiranvj 's way like this fork.
This is a pretty good workaround and may be a clue to solving the issue… well I think?

@mwskwong
Copy link

mwskwong commented Jan 2, 2024

So basically, the issue is reproducible when using optimizePackageImports with several libraries (@mui/maetrial in this case, but also noticed some others commented antd). From my testing, this issue won't immediately appear as soon as an MUI component is used but requires a certain combination of things to trigger.

Workarounds (note that these are NOT solutions)

  1. Instead of using named import in RSC, use default import, i.e.

    - import { Typography } '@mui/material';
    + import Typography '@mui/material/Typography' ;

    Why this works. Because we are essentially NOT using optimizePackageImports here since we are no longer importing components from the barrel file.

  2. Make all components that use MUI components Client Components, i.e.

    + 'use client';
    import { Typography } '@mui/material';

    Why this works. Because yet again, we are NOT using optimizePackageImports here. When the parent component is a client component, Webpack takes over and uses the usual tree shaking here.

@feedthejim feedthejim added the linear: next Confirmed issue that is tracked by the Next.js team. label Jan 3, 2024
@bjfresh
Copy link

bjfresh commented Jan 6, 2024

FWIW I'm encountering this issue in both a large legacy app and a much smaller starter kit that I've been working on with 14.0.4, in a repo that doesn't use MUI.

Everything works when using next dev, but fails when invoking dev using the --turbo option

EDIT: put together a minimal PR:

@DonikaV
Copy link

DonikaV commented Jan 10, 2024

"@mui/material-nextjs": "^5.15.4",
After update to latest version
import { AppRouterCacheProvider } from '@mui/material-nextjs/v14-appRouter'; this throw error 'Can not find a module'

@francoisjacques
Copy link

For @DonikaV and other who might be having issues with @mui/material-nextjs, 5.15.4 has a known bug which is unrelated to the rendering regressions discussed in this issue.

Simply pick the previous version instead. See linked ticket on MUI repo for discussion on when the fix should be made available.

huozhi added a commit that referenced this issue Jan 16, 2024
As Barrel Optimization might split one file into multiple different
modules, i.e. when you import different values from it, the target file
might be transformed differently, we can no longer rely on the file path
as the identifier of the client reference.

This fix adds a suffix (`'@' + this._module.matchResource`) to the
identifier so it looks like
`/filepath/file.js@__barrel_optimize__?names=Foo`.

Here's also a quick diagram to explain:


![CleanShot-2024-01-16-QzlxzMKy@2x](https://github.com/vercel/next.js/assets/3676859/99f25975-b965-4ae0-91f2-269a6a0d7458)

Closes #59804.
Closes NEXT-2108.

---------

Co-authored-by: Jiachi Liu <[email protected]>
@huozhi
Copy link
Member

huozhi commented Jan 18, 2024

The fix is landed in latest canary 🙏

@astrodomas
Copy link

The fix is landed in latest canary 🙏

to be specific: canary-60

Copy link
Contributor

github-actions bot commented Feb 1, 2024

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot added the locked label Feb 1, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked
Projects
None yet
Development

Successfully merging a pull request may close this issue.