egoist / egoist/tsup

tsup not respecting outDir and target (and probably more) from tsconfig.json

Open
#1,152 1 comment 8 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
274
PR merge metrics
No merged PRs in 30d

Description

### Current Behavior
When running `tsup`, the build output is generated in the `dist` directory instead of the `lib` directory as specified in my `tsconfig.json`. Similarly, the `target` option in `tsconfig.json` is not being respected.

### Expected Behavior
`tsup` should generate the build output in the `lib` directory and use the `es2022` target as defined in `tsconfig.json`.

### Steps to Reproduce

1. Set up a TypeScript project with the following `tsconfig.json`:

```json
{
"compilerOptions": {
"esModuleInterop": true,
"skipLibCheck": true,
"target": "es2022",
"allowJs": true,
"resolveJsonModule": true,
"moduleDetection": "force",
"isolatedModules": true,
"verbatimModuleSyntax": false,
"module": "ESNext",
"strict": true,
"noImplicitOverride": true,
"moduleResolution": "node",
"sourceMap": true,
"declaration": true,
"incremental": false,
"outDir": "lib",
"baseUrl": ".",
"paths": {
"@/*": [
"./src/*"
]
},
"lib": [
"es2022",
"dom"
]
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules",
"lib",
"coverage"
]
}
```

2. Configure `tsup` with the following `tsup.config.ts`:

```typescript
import { defineConfig } from 'tsup'

export default defineConfig({
entry: ['src/**/*.ts'],
dts: true,
shims: true,
clean: true,
skipNodeModulesBundle: true,
format: ['esm'],
tsconfig: './tsconfig.json' // this is rendundant since tsup and tsconfig are in the same dir(?)
})
```

3. Run the build command: `tsup`

### Environment
- `tsup` version: ^7.2.0
- Node.js version: 18

### Additional Context
Despite configuring `tsup` to use the settings from `tsconfig.json`, the build outputs to the `dist` directory, and the target is set to `esnext`.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the provided tsconfig.json and tsup.config.ts, then inspect how tsup loads and applies those configuration options. Done means the build writes to lib instead of dist and uses the es2022 target; verify both outcomes with the supplied project setup.

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.