Error with new JSX runtime in NextJS: `Can't resolve 'preact/jsx-dev-runtime'`
See original GitHub issueReproduction
Using NextJS 10 with:
- next-plugin-preact@3.0.3
- preact@10.5.12
- preact-render-to-string@5.1.12
- @preact/compat@0.0.4
And the following Babel config:
{
"presets": [
[
"next/babel",
{
"preset-react": {
"runtime": "automatic",
"importSource": "preact"
}
}
]
]
}
I get the following error:
Module not found: Can't resolve 'preact/jsx-dev-runtime'
Steps to reproduce
- Install latest NextJS with plugin-preact
- Setup new JSX runtime according to Preact/Next docs
- See error
Expected Behavior
- Should support new JSX runtime via babel config
Actual Behavior
- Gives error and does not compile new JSX runtime
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Module not found: Can't resolve 'react/jsx-runtime' | bobbyhadz
To solve the error "Module not found: Error: Can't resolve 'react/jsx-runtime'", make sure to update the react package by opening your terminal in...
Read more >got Can't resolve 'react/jsx-runtime' error while use try to create ...
got Can't resolve 'react/jsx-runtime' error while use try to create the shared component with storybook in react-typescript ; es.js ; found: Error ......
Read more >Switching to Preact (from React)
Switching to Preact can be as easy as installing and aliasing preact-compat in for react and react-dom . This lets you continue writing...
Read more >JSX Pragma - Theme UI
By default the Babel plugin will convert JSX into calls to the jsx function imported from react/jsx-runtime , but libraries like Preact, MDX,...
Read more >TSConfig Option: jsxImportSource - TypeScript
With React 17 the library supports a new form of JSX transformation via a separate ... Would add preact/jsx-runtime as an import for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@JoviDeCroock setting
importSource
topreact/compat
fixes it, thanks! Might be worth noting the gotcha with Next somewhere in the docs? Just because it’s such a popular framework.Good point @madeleineostoja I’ll make a PR to
next-plugin-preact
as that seems to be an ideal location, thanks for pointing this out to us 🙌