egoist / egoist/tsup

Option to specify `outExtension` for generated dts files?

Open
#939 4 comments 26 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
275
PR merge metrics
No merged PRs in 30d

Description

Like we can modify output extension of JavaScript files is there also a way to do the same for type definition files?

I tried returning this because `dts` was showing up in the autocomplete return options but it doesn't work.

```ts
format: ['cjs', 'esm'],
outExtension({ format }) {
switch (format) {
case 'cjs': {
return { js: '.cjs', dts: '.d.cts' };
}
case 'esm': {
return { js: '.mjs', dts: '.d.mts' };
}
default: {
return { js: '.js', dts: '.d.ts' };
}
}
}
```

Output type definition files generated after building have extensions `.d.ts` and `.d.cts` which is the default since my package is of type module. Is there a way to do this?

Contributor guide

Open the contributing guide

Research direction

No files or tests are named. Start by tracing how tsup handles the existing outExtension callback for JavaScript and how declaration files are generated; determine where the dts output extension is selected. Done means the requested .d.cts and .d.mts extensions can be selected consistently for the cjs and esm formats, with coverage for the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system
Issue type
Feature
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.