egoist / egoist/tsup

DTS files copied from publicDir are deleted in dts step

Open
#1,366 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
274
PR merge metrics
No merged PRs in 30d

Description

I have a package with some legacy js which I need to copy verbatim which includes some basic d.ts files. When running the build with `clean` enabled the files are being copied to the output directory but then subsequently deleted, which upon investgation seems to be happening in the `dtsTask`.

I tried using the `onSuccess` hook but it has the same issue:

```
onSuccess: async () => {
fs.cpSync('./public', './dist/', { recursive: true });
},
```

I managed to workaround this issue by putting a delay in the onSuccess great than the DTS build step:
```
onSuccess: async () => {
setTimeout(() => {
fs.cpSync('./public', './dist/', { recursive: true });
}, 5000);
},
```

### Suggested resolution:

Run the `publicDir` and `onSuccess` tasks after the `dtsTask` and the `mainTasks` have completed. In fact I would think the `onSuccess` should be run after the `publicDir`.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the task orchestration around dtsTask, mainTasks, publicDir, and onSuccess, reproducing the reported build with clean enabled and copied .d.ts files. Done means publicDir and onSuccess run after dtsTask and mainTasks, with copied files remaining in the output directory without a delay.

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.