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

gatsby-plugin-preact: Can't resolve 'react/jsx-runtime' with @mui/material #35145

Closed
2 tasks done
mikhin opened this issue Mar 16, 2022 · 2 comments · Fixed by #35156
Closed
2 tasks done

gatsby-plugin-preact: Can't resolve 'react/jsx-runtime' with @mui/material #35145

mikhin opened this issue Mar 16, 2022 · 2 comments · Fixed by #35156
Labels
topic: plugins Related to plugin system, themes & catch-all for plugins that don't have a label type: bug An issue or pull request relating to a bug in Gatsby

Comments

@mikhin
Copy link

mikhin commented Mar 16, 2022

Preliminary Checks

Description

Hi. I get an error when using gatsby-plugin-preact with @mui/material:

"@mui/material": "^5.4.1",
"gatsby": "^4.7.1",
"gatsby-plugin-preact": "^6.9.0",
"preact": "^10.6.6",
"preact-render-to-string": "^5.1.20",
"gatsby-plugin-sharp": "^4.7.0",
"gatsby-transformer-sharp": "^4.7.0",

Reproduction Link

https://github.com/mikhin/my-gatsby-site

Steps to Reproduce

  1. Import some component in project, import Slider from "@mui/material/Slider";
  2. Run npx gatsby build
  3. Get a lot of errors like that:
 ERROR #98124  WEBPACK

Generating JavaScript bundles failed

Can't resolve 'react/jsx-runtime' in '/node_modules/@mui/system/esm/cssVars'

If you're trying to use a package make sure that 'react/jsx-runtime' is
installed. If you're trying to use a local file make sure that the path is
correct.

File: node_modules/@mui/system/esm/cssVars/getInitColorSchemeScript.js:2:0

not finished Running gatsby-plugin-sharp.IMAGE_PROCESSING jobs - 26.385s

Expected Result

Successful build

Actual Result

Build process finished with error

Environment

macos 12.12.1
node 16.14.0
yarn 1.22.17

Config Flags

No response

EDIT:

Adding of code

actions.setWebpackConfig({
    resolve: {
      alias: {
        "react": "preact/compat",
        "react/jsx-runtime": "preact/jsx-runtime"
      }
    }
  })

to gatsby-node.js solves this issue, but it is a redundant measure, isn't it?

@mikhin mikhin added the type: bug An issue or pull request relating to a bug in Gatsby label Mar 16, 2022
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Mar 16, 2022
@LekoArts LekoArts added status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Mar 16, 2022
@LekoArts
Copy link
Contributor

Hi!

Sorry to hear you're running into an issue. To help us best begin debugging the underlying cause, it is incredibly helpful if you're able to create a minimal reproduction. This is a simplified example of the issue that makes it clear and obvious what the issue is and how we can begin to debug it.

If you're up for it, we'd very much appreciate if you could provide a minimal reproduction and we'll be able to take another look.

Thanks for using Gatsby! 💜

@mikhin
Copy link
Author

mikhin commented Mar 16, 2022

Hi! Here it is — https://github.com/mikhin/my-gatsby-site

Thank you!

@marvinjude marvinjude added topic: plugins Related to plugin system, themes & catch-all for plugins that don't have a label and removed status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. labels Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: plugins Related to plugin system, themes & catch-all for plugins that don't have a label type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants