question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error with new JSX runtime in NextJS: `Can't resolve 'preact/jsx-dev-runtime'`

See original GitHub issue

Reproduction

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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
madeleineostojacommented, Feb 21, 2021

@JoviDeCroock setting importSource to preact/compat fixes it, thanks! Might be worth noting the gotcha with Next somewhere in the docs? Just because it’s such a popular framework.

0reactions
JoviDeCroockcommented, Feb 21, 2021

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 🙌

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found