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
- Pin react-resize-aware to v3.1.1 v3.1.2 introduces a `ReferenceError: jsx is not defined` error due to wrong configuration (see [issue](https://github.com/FezVrasta/react-resize-aware/issues/58)). We ... — committed to vivid-planet/comet by johnnyomair 2 years ago
- Pin react-resize-aware to 3.1.0 3.1.2 seems to have a broken build that references jsx without importing react: https://github.com/FezVrasta/react-resize-aware/issues/58 — committed to lewisl9029/highlight by lewisl9029 a year ago
- Pin react-resize-aware to 3.1.0 (#5879) ## Summary 3.1.2 seems to have a broken build that references jsx without importing react: https://github.com/FezVrasta/react-resize-aware/issues/58 Pin... — committed to highlight/highlight by lewisl9029 a year ago
- Mock out resizeObserver to avoid https://github.com/FezVrasta/react-resize-aware/issues/58 — committed to woocommerce/woocommerce-blocks by samueljseay 10 months ago
- Fixes for jest transpilation issues. (#10788) * Fix bug where is-plain-obj is not transpiled by Jest, update lock. * Update packages. * Mock useSelect for a handful of RichText selectors in test. ... — committed to woocommerce/woocommerce-blocks by samueljseay 10 months ago
@FezVrasta it seems that v3.1.2 breaks applications using the old JSX transform. I’m getting the error
ReferenceError: jsx is not defined
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.
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.