这是indexloc提供的服务,不要输入任何密码
Skip to content

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

@ktlshya

Description

@ktlshya

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:

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

My build script in package.json is:

"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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions