egoist / egoist/tsup

Stop emitting empty files

Open
#966 0 comments 9 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
274
PR merge metrics
No merged PRs in 30d

Description

Minimal reproduction -

File structure

![File structure](https://github.com/egoist/tsup/assets/96779207/ac00d740-5133-4a72-9a80-b0488070f82c)

tsup.config.ts
```ts
import { defineConfig } from 'tsup'

export default defineConfig({
entry: ['lib', 'types'],
dts: true,
})
```

types/helpers.ts (only contains types)

```ts
export type Optional = T | null | undefined
```

lib/index.ts

```ts
import { Optional } from '../types/helpers'

export function log(message?: Optional) {
console.log(message ?? '')
}
```

This will output helpers.js with empty exports or full empty file if using esm format

![Dist folder](https://github.com/egoist/tsup/assets/96779207/95f28a43-c708-42d6-8d53-e91935ee867c)

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the shown tsup.config.ts, types/helpers.ts, and lib/index.ts, then inspect how the two entry points are processed and why a type-only entry produces helpers.js. Compare the generated ESM and other outputs; done means the type-only entry emits no empty JavaScript file while lib/index.ts still builds correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.