Dynamic require of "react" is not supported
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 275
- PR merge metrics
- No merged PRs in 30d
Description
I created a modal with createPortal, using react-dom, react and inline css. I get this error when running on a project. My config:
```ts
import { defineConfig } from 'tsup'
export default defineConfig({
entry: ['src/index.ts'],
format: ['cjs', 'esm'],
target: 'es2021',
splitting: false,
minify:true,
treeshake:true,
clean: true,
dts: true,
external:['react', 'react-dom']
})
```
Contributor guide
Research direction
Start with the provided tsup configuration and the src/index.ts entry point, then reproduce the modal build using both CJS and ESM formats. Inspect the generated output to identify why react is dynamically required despite being external, and consider the issue done when the build runs without this error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100