egoist / egoist/tsup

7.1: Does not match the `legacyOutput` mode

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

Description

In 7.1, #934 made declaration files for each format.

Here is my `tsup.config.ts` file:

```ts
export default defineConfig({
entry: ["src/index.ts"],
format: ["cjs", "esm"],
legacyOutput: true,
splitting: false,
sourcemap: false,
clean: true,
dts: true,
minify: true,
});
```

I'm using `legacyOutput` mode, which
> Outputs different formats to different folder instead of using different extensions

And here is the list of the files produced:

```
$ ls dist
esm index.d.mts index.d.ts index.js
$ ls dist/esm
index.js
```

Meaning, that the `esm` bundle is located in the corresponding folder.
However, its declaration file (`index.d.mts`) is not.

Moreover, it's impossible to use `onSuccess` callback for running `fs.rename` (in order to move `index.d.mts` into `esm` folder), since that callback is being fired BEFORE making declarations.

Could you please fix it by placing the declaration files into the same directories where you put the bundles?

**Also, in legacy mode, the declaration filename should be `.d.ts` instead of `.d.mts`.**

CC @andrewbranch

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the provided tsup.config.ts and inspect the generated dist contents, including the esm directory and declaration files. Trace the legacyOutput declaration-generation path and its interaction with onSuccess. Done means declarations are placed beside their corresponding bundles and legacy mode uses .d.ts filenames.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.