bug: resolve TypeScript 7 build breakage caused by tsup/rollup-plugin-dts incompatibility during d.ts generation
Author: be-free-snowboyCreated Jul 9, 2026Updated Jul 14, 2026
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.
- Bundling (
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) [email protected][email protected][email protected]
- Node:
- Root dependency:
typescript: "7.0.2"
- Forced version:
overrides: { "typescript": "7.0.2" }
3. How it happens
- Install root dependencies and run
pnpm build. - Turbo runs package
buildtasks in parallel. tsupcompiles JS output for multiple packages successfully.- In packages with
dts: true,tsupinternally invokes rollup +rollup-plugin-dts. rollup-plugin-dtspath in runtime points to:node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/...
- The plugin crashes accessing
useCaseSensitiveFileNameson an undefined object, aborting build.
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.
tsupin this repo is pinned to8.5.1, whose runtime bundle references[email protected].- In the active lock and logs,
rollup-plugin-dtsis resolved with a TypeScript variant tied to5.7.3, while the project root is forcing[email protected]. [email protected]is not aligned with TypeScript 7 API expectations in this environment (or gets passed undefined due to internal resolution mismatch), producing theuseCaseSensitiveFileNamesfailure.
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.
Source: egoist/tsup