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

Source maps not working with nextjs@13

Open Siegrift opened this issue 2 years ago • 0 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. Clone https://github.com/Siegrift/material-ui/tree/broken-source-maps-repro
  2. cd examples/nextjs-with-typescript
  3. npm i
  4. npm run dev
  5. Open http://localhost:3000/ and open devtools
  6. Inspect the elements and the see that the CSS source maps are broken

Current behavior 😯

Devtools point to the bundled CSS and not to the source file where it's defined.

image image

Expected behavior 🤔

I'd expect devtools to point me to the actual file and the CSS definition like it does in https://emotion.sh/docs/source-maps

Context 🔦

I've migrated from material-ui@4 to v5 and while understanding the migration from JSS I noticed that source maps were not working. I've tried to look for this issue, but haven't found a solution... Two of the most promising things were:

  1. Use the babel emotion plugin for nextjs. This didn't work, because the next/font needs SWC compiler and the SWC compiler doesn't work when .babelrc is defined.
  2. Use emotion plugin for the SWC compiler, but this didn't help either.

Your environment 🌎

npx @mui/envinfo
Need to install the following packages:
  @mui/[email protected]
Ok to proceed? (y) y

  System:
    OS: macOS 13.0.1
  Binaries:
    Node: 18.12.1 - ~/.volta/tools/image/node/18.12.1/bin/node
    Yarn: 1.22.19 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 8.12.2 - ~/.volta/tools/image/npm/8.12.2/bin/npm
  Browsers:
    Chrome: 108.0.5359.98
    Edge: Not Found
    Firefox: Not Found
    Safari: 16.1
  npmPackages:
    @emotion/react: latest => 11.10.5
    @emotion/styled: latest => 11.10.5
    @mui/base:  5.0.0-alpha.109
    @mui/core-downloads-tracker:  5.10.17
    @mui/icons-material: latest => 5.10.16
    @mui/material: latest => 5.10.17
    @mui/private-theming:  5.10.16
    @mui/styled-engine:  5.10.16
    @mui/system:  5.10.17
    @mui/types:  7.2.2
    @mui/utils:  5.10.16
    @types/react: latest => 18.0.26
    react: latest => 18.2.0
    react-dom: latest => 18.2.0
    typescript: latest => 4.9.4

next.js version: 13.0.6

Siegrift avatar Dec 11 '22 15:12 Siegrift