egoist / egoist/tsup

bug: resolve TypeScript 7 build breakage caused by tsup/rollup-plugin-dts incompatibility during d.ts generation

Open
#1,405 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
275
PR merge metrics
No merged PRs in 30d

Description

## 1. Symptom

Running `pnpm build` fails with multiple package tasks aborted by the same runtime error:

- Error:
- `TypeError [Error]: Cannot read properties of undefined (reading 'useCaseSensitiveFileNames')`
- Stack root:
- `node_modules/tsup/dist/rollup.js -> .../rollup-plugin-dts/dist/rollup-plugin-dts.cjs`
- Build shape:
- Bundling (`ESM/CJS`) starts successfully.
- Failure happens when d.ts-related rollup phase is initialized.

```log
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in ~/node_modules/~/package.json
at exportsNotFound (node:internal/modules/esm/resolve:314:10)
at packageExportsResolve (node:internal/modules/esm/resolve:661:9)
at resolveExports (node:internal/modules/cjs/loader:639:36)
at Function._findPath (node:internal/modules/cjs/loader:728:31)
at Function._resolveFilename (node:internal/modules/cjs/loader:1211:27)
at Function.resolve (node:internal/modules/helpers:146:19)
at resolveTsConfigFromExtends (~/node_modules/load-tsconfig/d
ist/index.cjs:163:18)
at loadTsConfigInternal (~/node_modules/load-tsconfig/dist/in
dex.cjs:169:26)
at loadTsConfigInternal (~/node_modules/load-tsconfig/dist/in
dex.cjs:185:28)
at loadTsConfigInternal (~/node_modules/load-tsconfig/dist/in
dex.cjs:185:28)
```

---

## 2. Current Environment

- Tooling:
- Node: `v22.14.0` (from log)
- `pnpm@10.20.0`
- `turbo@2.10.4`
- `tsup@8.5.1`
- Root dependency:
- `typescript: "7.0.2"`
- Forced version:
- `overrides: { "typescript": "7.0.2" }`

---

## 3. How it happens

1. Install root dependencies and run `pnpm build`.
2. Turbo runs package `build` tasks in parallel.
3. `tsup` compiles JS output for multiple packages successfully.
4. In packages with `dts: true`, `tsup` internally invokes rollup + `rollup-plugin-dts`.
5. `rollup-plugin-dts` path in runtime points to:
- `node_modules/.pnpm/rollup-plugin-dts@6.1.1_rollup@4.53.2_typescript@5.7.3/node_modules/...`
6. The plugin crashes accessing `useCaseSensitiveFileNames` on an undefined object, aborting build.

```tsup.config.ts
import { defineConfig } from 'tsup'

export default defineConfig((options) => ({
entry: {
index: 'src/index.ts',
},
watch: options.watch ? ['src/**/*'] : false,
clean: false,
dts: true,
outDir: 'dist',
target: 'esnext',
format: ['cjs', 'esm'],
sourcemap: false,
}))
```

---

## 4. Root cause analysis and suggestion

I think this is a **toolchain compatibility regression**, not library code.

- `tsup` in this repo is pinned to `8.5.1`, whose runtime bundle references `rollup-plugin-dts@6.1.1`.
- In the active lock and logs, `rollup-plugin-dts` is resolved with a TypeScript variant tied to `5.7.3`, while the project root is forcing `typescript@7.0.2`.
- `rollup-plugin-dts@6.1.1` is not aligned with TypeScript 7 API expectations in this environment (or gets passed undefined due to internal resolution mismatch), producing the `useCaseSensitiveFileNames` failure.

So the failure is caused by mixed toolchain state:
- Project-level TS = 7.0.2
- tsup+dts internal plugin bundle = TS-linked older expectations (5.7.3-like compatibility path)

This is why only build-time declaration generation is impacted, while TS transpilation itself appears to complete.

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with `pnpm build`, then inspect the shown `tsup.config.ts` and the active lock resolution for tsup, rollup-plugin-dts, and TypeScript. Compare the versions involved in packages using `dts: true`; done means declaration generation completes across the affected package build tasks without the reported runtime error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rollup, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.