egoist / egoist/tsup

require.main + multiple entrypoints

Open
#914 0 comments 0 reactions 0 assignees View on GitHub
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.

![image](https://github.com/egoist/tsup/assets/5336472/da2e29ad-9a0a-497f-8ab0-46a9d6391030)
![image](https://github.com/egoist/tsup/assets/5336472/ddf91278-0073-4436-9bf5-edd497645f4e)

Contributor guide

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.