Microbundle: Runtime error: Uncaught ReferenceError: h is not defined

Created on 15 Apr 2019  路  2Comments  路  Source: developit/microbundle

Problem

I'm trying to pack-up a (react) module i made using this program but when i try to use the generated js files i'm getting this error: Uncaught ReferenceError: h is not defined.
I'm not familiar with creating JS modules and this is my first ever JS module so this issue might be a bit stupid.

What i have dune

  • transformed a react component into a module using this program
  • imported the generated .js file into my project

Example code:

I've tried to show reproduced the issue with as minimal code as possible here:
https://github.com/mjarkk/microbundle-example

  • The / folder contains the module
  • The /example/ folder contains a simple react project with the module imported.

In the real project where this issue started i'm using webpack in staid of parcel but the issue is exactly the same there.

Most helpful comment

Thanks that did the trick.

All 2 comments

JSX transpiration defaults to using h as the constructor function. With react you need to set it to React.createElement instead. This can be done via the --jsx flag.

Thanks that did the trick.

Was this page helpful?
0 / 5 - 0 ratings