Unable to load/import 'preact/jsx-dev-runtime'
See original GitHub issueThe 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
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:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top 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 >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
I filed an issue with Browserify: https://github.com/browserify/browserify/issues/1995
@devongovett is adding support for the
exports
field inpackage.json
on parcel’s roadmap? With libraries switching over to ESM there might be more issues like this in the future. Supporting theexports
field would solve all those problems at once for parcel.