egoist / egoist/tsup

Dynamic require of "react" is not supported

Open
#927 10 comments 17 reactions 0 assignees View on GitHub
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.