#1364·tsup

TS6307 error when building with tsup in monorepo package, but tsc works fine

Author: ktlshyaCreated Sep 13, 2025Updated Mar 13, 2026

Description:

I'm working in a monorepo setup. In my package, I have the following structure:

package
├── src/
│   ├── index.ts
│   └── ref.ts
├── package.json
├── tsconfig.json

My tsconfig.json includes:

json
{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "composite": true,
    "rootDir": "./src",
    "moduleResolution": "node",
    "outDir": "dist"
  },
  "include": ["src/**/*"]
}

My build script in package.json is:

json
"build": "tsup src/index.ts --clean --format cjs,esm --dts --tsconfig ./tsconfig.json"

When I run npm run build, I get the following error:

error TS6307: File '/package/src/ref.ts' is not listed within the file list of project ''. Projects must list all files or use an 'include' pattern.

However, running npx tsc -p tsconfig.json works perfectly and generates the expected declaration files.


What I've tried:

  • Changing moduleResolution between node and bundler
  • Adjusting the include pattern
  • Cleaning the dist and .tsbuildinfo files
  • Upgrading tsup and typescript
  • Restarting VS Code

Expected behavior:

tsup should build the package and generate declaration files without TS6307 errors, just like tsc does.


Actual behavior:

tsup fails with TS6307, but tsc works.


Environment:

  • tsup version: v8.5.0
  • typescript version: v5.9.2
  • Node.js version: v22.19.0

Additional context:

Is there a workaround or recommended way to use tsup for both JS and declaration file generation in this scenario?