require.main + multiple entrypoints
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 274
- PR merge metrics
- No merged PRs in 30d
Description
I believe this is a tsup issue, not an esbuild one, since CJS code splitting is a checked in esbuild plugin and uses sucrase.
The issue is that with multiple entry points, the generated `__require` helpers get put into their own chunk which breaks the `require.main === module` check.


Contributor guide
Research direction
Start by reproducing a tsup build with multiple entry points and CJS code splitting, then inspect the generated chunks and the placement of the __require helpers. Done means the generated output preserves the require.main === module check instead of moving the helpers into a separate chunk.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100