[BUG] React runtime resolution issue caused by outdated hardcoded jsx-runtime path
- Dominant language
- JavaScript
- Stars
- 1.1k
- Forks
- 397
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 25
Description
### Describe the bug.
## React runtime resolution issue caused by outdated hardcoded jsx-runtime path
### Problem
The current React version used in `generator-react-sdk` is outdated and is no longer aligned with other dependent AsyncAPI libraries such as `@asyncapi/html-template`.
The code currently hardcodes an internal React runtime path:
```js
'react/jsx-runtime': require.resolve(
'react/cjs/react-jsx-runtime.production.min'
).replace(/\\/g, '/'),
```
However, this internal path is no longer exposed through React package exports in newer React versions.
This causes runtime resolution failures such as:
```txt
Error: Package subpath './cjs/react-jsx-runtime.production.min'
is not defined by "exports"
```
Example stack trace references packages like:
```txt
node_modules/.pnpm/@asyncapi/html-...
```
### Suggested discussion points
* Should AsyncAPI packages align on a consistent React version strategy?
* Should the implementation switch to the public runtime entrypoint instead?
Example:
```js
require.resolve('react/jsx-runtime')
```
* Is backward compatibility with older React versions still required?
I wanted to open this issue first to discuss the preferred direction with maintainers before continuing with a PR implementation.
### Expected behavior
running
### Screenshots
Error: Package subpath './cjs/react-jsx-runtime.production.min' is not defined by "exports" in node_modules.pnpm@asyncapi+html-template@3.5_38169f94417d5abe6c7e65de49492da1\node_modules\react\package.json at exportsNotFound (node:internal/modules/esm/resolve:313:10)
dependencies:
nestjs-asyncapi 2.0.1
├─┬ @asyncapi/generator 2.11.0
│ ├─┬ @asyncapi/generator-components 0.6.0
│ │ └─┬ @asyncapi/generator-react-sdk 0.2.25
│ │ └── react 17.0.2
│ └─┬ @asyncapi/generator-react-sdk 0.2.25
│ └── react 17.0.2
└─┬ @asyncapi/html-template 3.5.6
├─┬ @asyncapi/generator-react-sdk 1.1.3
│ └── react 17.0.2
├─┬ @asyncapi/react-component 3.1.3
│ ├── react 18.3.1 peer
│ ├─┬ react-dom 18.3.1 peer
│ │ └── react 18.3.1 peer
│ ├─┬ react-error-boundary 4.1.2
│ │ └── react 18.3.1 peer
│ └─┬ use-resize-observer 9.1.0
│ ├── react 18.3.1 peer
│ └─┬ react-dom 18.3.1 peer
│ └── react 18.3.1 peer
├── react 18.3.1
└─┬ react-dom 18.3.1
└── react 18.3.1 peer
### How to Reproduce
1. I first did this
2. I then did this
3. And so on . . .
### 🖥️ Device Information [optional]
- Operating System (OS):win 11 pnpm10
- Browser:
- Browser Version:
### 👀 Have you checked for similar open issues?
- [x] I checked and didn't find similar issue
### 🏢 Have you read the Contributing Guidelines?
- [x] I have read the [Contributing Guidelines](https://github.com/asyncapi/.github/blob/master/CONTRIBUTING.md)
### Are you willing to work on this issue ?
Yes I am willing to submit a PR!
Contributor guide
Research direction
Start by locating the hardcoded require.resolve('react/cjs/react-jsx-runtime.production.min') expression in generator-react-sdk and reproduce the failure with the React 17.0.2 and 18.3.1 dependency trees described here. Confirm the preferred compatibility strategy with maintainers; done means the generator resolves the JSX runtime without the exports error for the supported React versions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs, react
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 45/100