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

Canary version breaks @mui/material based project #51872

Closed
1 task done
weyert opened this issue Jun 27, 2023 · 3 comments · Fixed by #51953
Closed
1 task done

Canary version breaks @mui/material based project #51872

weyert opened this issue Jun 27, 2023 · 3 comments · Fixed by #51953
Labels
bug Issue was opened via the bug report template. locked

Comments

@weyert
Copy link

weyert commented Jun 27, 2023

Verify canary release

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

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000
    Binaries:
      Node: 18.15.0
      npm: 7.24.2
      Yarn: 1.22.19
      pnpm: 7.30.3
    Relevant packages:
      next: 13.4.8-canary.5
      eslint-config-next: 12.3.4
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.0.2

Which area(s) of Next.js are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue or a replay of the bug

n/a

To Reproduce

Create a project which uses @mui/material e.g. a component like below, with the dependencies:

  • "@mui/material": "^5.10.15",
/* eslint-disable react/no-unstable-nested-components */
import { Box, useMediaQuery, useTheme } from '@mui/material'
import React, { PropsWithChildren } from 'react'

export function PageLayout({ children }: PropsWithChildren<{}>) {
  const theme = useTheme()
  const isSmUp = useMediaQuery(theme.breakpoints.up('sm'))

  return (
    <>
      <Box
        sx={
          isSmUp
            ? {
                display: 'flex',
                flexDirection: 'column',
                alignItems: 'center',
              }
            : {
                display: 'flex',
                flexDirection: 'column',
                flex: 1,
                alignItems: 'center',
                backgroundColor: 'common.white',
              }
        }
      >
        {children}
      </Box>
    </>
  )
}

Describe the Bug

When you upgrade to the canary version and have an existing project that uses @material/ui the build step breaks with the following error:

./src/Layouts/PageLayout.tsx
Module not found: Can't resolve '@mui/material/useTheme'

https://nextjs.org/docs/messages/module-not-found

Expected Behavior

Able to compile existing code without new build errors

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@weyert weyert added the bug Issue was opened via the bug report template. label Jun 27, 2023
@Haseebshah936
Copy link

They are fixing the overall app router. If you want to still develop using app router than you can go with ^13.3

@weyert
Copy link
Author

weyert commented Jun 27, 2023

I am not using the app router yet. Just good old pages router

ijjk added a commit that referenced this issue Jun 29, 2023
Fixes #51872. We were exploring in
mui/material-ui#35457 the option to move the
`modularizeImports` config to our Next.js examples to fix
mui/material-ui#35450 however, we never got to
complete the work.

We are not yet in a position where we can apply modularizeImports to
`@mui/material`. We still have folders to create to make it work.

Maybe we should close mui/material-ui#35457?

Co-authored-by: JJ Kasper <jj@jjsweb.site>
@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. 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 locked as resolved and limited conversation to collaborators Jul 29, 2023
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. locked
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants