react-resize-aware: React is not defined: auto jsx runtime

Hi, I depend on this package as a dependency of another npm package and I believe this issue: https://github.com/FezVrasta/react-resize-aware/issues/57 is seeing the same problem I see.

When I build with Vite with the auto jsx runtime available in React 17 I cannot use this package due to its microbundle distribution. and I get the error React is not defined.

I found that if I updated microbundle to latest and made an adjusted build for the jsx runtime, that I could use patch-package and still use this dependency.

The modified build command would be something like microbundle --name useResizeAware --jsx jsx --jsxImportSource react --globals react/jsx-runtime=jsx This was based on a suggestion here: https://github.com/developit/microbundle/issues/763#issuecomment-778848944

I was just wondering if you would consider releasing a package with support for the auto jsx runtime? At least for my situation turning off the auto JSX runtime is not an option I have right now. I would be happy to submit a PR with the build changes, but my only concern would be testing it for other environments.

Thanks! ✌🏻

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 23 (8 by maintainers)

Commits related to this issue

Most upvoted comments

@FezVrasta it seems that v3.1.2 breaks applications using the old JSX transform. I’m getting the error ReferenceError: jsx is not defined

@timothyallan whats the issue with just sticking with 3.1.1? If you look at the releases, there are no functional changes that you need.

Primarily because 3.1.2 is a bigger number than 3.1.1, therefore it must be better, and I want my package.json to have the biggest numbers in town for everything.

PRs are more than welcome 🙏

I’m sorry, we decided to use ResizeObserver instead. 🙃

This seems to be an issue still. 3.1.1 resolves this, but this is coming up deep in a dependency tree from some other packages we’re using, and 3.1.2 is being installed by default, which makes it fail. I’ve manually installed 3.1.1 to override the one from the package we’re using. I lost sooooo many hours trying to diagnose what was happening here.

4.0.0 should address this problem

I haven’t changed that in the last release. But I plan to work on it tomorrow.