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.

"@prefresh/vite" fails when using "jsxFactory" other than "h" from "preact"

See original GitHub issue

Problem

Emotion users need to be able to use a custom jsxFactory, when using one of the core features of emotion css prop.

When making this change (click to view)

Switching from the suggested:

  esbuild: {
    jsxFactory: `h`,
    jsxFragment: `Fragment`,
    jsxInject: `import { h, Fragment } from "preact";`,
  },

To:

  esbuild: {
    jsxFactory: `jsx`,
    jsxInject: `import { jsx } from "@emotion/react";`,
  },

The "@prefresh/vite" fails with the following error message:

  • I’m new to vite, so sorry for not being able to provide you w/ a more useful debug msg
Cannot read property '__e' of undefined

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
o-alexandrovcommented, Apr 14, 2021

Btw, as crazy as it sounds, the following addition ended up working. If you add more deps to the exclusion, vite/esbuild stops working properly throwing different errors related to the exports of the pkgs.

  optimizeDeps: {
    exclude: [
      `@prefresh/vite/runtime`,
      `@prefresh/vite/utils`,
    ],
  },

I’ll be closing it, as I don’t have any issues w/ the above.

0reactions
itsMapleLeafcommented, Apr 14, 2021

I see, and the “Cannot read __H of undefined” now shows up when I try to add the exclusions, as mentioned earlier:

	optimizeDeps: {
		exclude: [
			"react",
			"react-dom",
			"preact",
			"preact/compat",
			"preact/hooks",
			"@prefresh/core",
			"@prefresh/vite/runtime",
			"@prefresh/vite/utils",
		],
	},

So it sounds like an issue with Vite that can/should be fixed on their end?

EDIT: After removing this from my config and rerunning the dev server… the error went away 🤔 huh. Curious. There must be some non-determinism at play here

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript | Preact: Fast 3kb React alternative with the same ...
Using ref with any other element lets TypeScript thrown an error: import { h, Component, createRef } from "preact"; class Foo extends Component...
Read more >
import { h } from preact - when is it necessary - Stack Overflow
My understanding was that wherever I have a component defined with JSX, I need to have import { h } from 'preact' at...
Read more >
Vite with Preact and TypeScript - fettblog.eu
jsx to preserve , which means that TypeScript doesn't compile JSX. This is done by Vite anyway · jsxFactory is h . This...
Read more >
cannot read properties of undefined (reading '__h') - You.com
Invalid hooks call when using widget built with preact inside react app ... of undefined (reading '__H')' and the other is 'preact Uncaught...
Read more >
Moving React app to Preact in 10 minutes with Vite - Puru Vijay
#Is it true? In case you are wondering if my claim of moving an app this big from one framework to other in...
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