#1405·tsup

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.
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


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:
  6. The plugin crashes accessing useCaseSensitiveFileNames on an undefined object, aborting build.
bash
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 [email protected].
  • 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 [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 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.