egoist / egoist/tsup

Multiple empty lines in generated CJS file before the export statement, while exports are collapsed to one line

Open
#1,068 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
11.3k
Forks
274
PR merge metrics
No merged PRs in 30d

Description

I discovered there is empty lines before the exports statements in the generated CJS file. All the exports statement will be placed in one line.

Here are some examples:

2 exports, 3 empty line after previous non-empty.
![image](https://github.com/egoist/tsup/assets/59910575/181088bb-3701-4ed7-bfd8-ec01a05d0429)

3 exports, 4 empty line after previous non-empty.
![image](https://github.com/egoist/tsup/assets/59910575/012959fe-b346-4e8e-a1cf-d77fe2af450d)

7 exports, 8 empty line after previous non-empty.
![image](https://github.com/egoist/tsup/assets/59910575/520d9f17-1c05-4e98-acc0-0a639d82d9d0)

I am using the config like this:

```ts
import type { Options } from 'tsup';

const tsup_config: Options = {
splitting: true,
clean: true,
dts: true,
format: ["esm", "cjs"],
bundle: false,
skipNodeModulesBundle: true,
target: 'esnext',
outDir: 'dist',
entry: ['src/**/*.ts']
};

export default tsup_config
```

Can I ask is this behaviour a bug, or designed to be like this, or if there is a failure in my configuration ?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the TypeScript tsup configuration shown, especially CJS output with multiple exports and bundle disabled. Inspect the generated CJS output and the relevant build path; done means exports are not preceded by an export-count-dependent run of empty lines while preserving valid CJS output.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.