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.

Unable to load/import 'preact/jsx-dev-runtime'

See original GitHub issue

The package.json for preact version 10.5.12 lists preact/jsx-dev-runtime as submodule:

"./jsx-dev-runtime": {
	"browser": "./jsx-runtime/dist/jsxRuntime.module.js",
	"umd": "./jsx-runtime/dist/jsxRuntime.umd.js",
	"require": "./jsx-runtime/dist/jsxRuntime.js",
	"import": "./jsx-runtime/dist/jsxRuntime.mjs"
},

However, I am unable to load/import it.

Babel preset-react has a couple of option to use runtime: "automatic" and importSource: "preact". When these options are enable, babel loads jsx-runtime on production or jsx-dev-runtime on development environment.

This is my .babelrc:

{
  "presets": [
    [
      "@babel/preset-react",
      {
        "runtime": "automatic",
        "importSource": "preact"
      }
    ],
  "env": {
    "development": {
      "presets": [
        [
          "@babel/preset-react",
          {
            "development": true,
            "runtime": "automatic",
            "importSource": "preact"
          }
        ]
      ]
    }
  }
}

Steps to reproduce

  1. import { jsx } from "preact/jsx-dev-runtime";

See also the error here: https://codesandbox.io/s/affectionate-paper-bo98u?file=/index.js

Expected behavior

I should be able be able to import the preact/jsx-dev-runtime

Actual behavior

preact/jsx-dev-runtime can not be imported.

Babel reports: Error: Can't walk dependency graph: Cannot find module 'preact/jsx-dev-runtime'

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
esanzgarcommented, Feb 5, 2021

I filed an issue with Browserify: https://github.com/browserify/browserify/issues/1995

0reactions
marvinhagemeistercommented, Feb 13, 2022

@devongovett is adding support for the exports field in package.json on parcel’s roadmap? With libraries switching over to ESM there might be more issues like this in the future. Supporting the exports field would solve all those problems at once for parcel.

Read more comments on GitHub >

github_iconTop Results From Across the Web

preact-jsx-runtime - npm
Preact JSX runtime definition for use with automatic JSX import. Latest version: 1.2.0, last published: 2 years ago.
Read more >
Error with JSX in my React Library when Switching to Preact
The issue was running the library through a compiler. The library should have been written as a just a Higher Order Component and...
Read more >
Getting Started | Preact: Fast 3kb React alternative with the ...
New to Preact? New to Virtual DOM? Check out the tutorial. This guide helps you get up and running to start developing Preact...
Read more >
babel/preset-react
Automatic runtime (since v7.9.0 ) adds the functionality for these plugins automatically when the development option is enabled.
Read more >
API - esbuild
It can also be used to import code in node at run time from a package that cannot be ... In the browser,...
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