Skip to content

References are ignored #459

@incutonez

Description

@incutonez

Describe the bug

I have a custom tsconfig.build.json that I use in the tsconfigPath when configuring dts. However, it appears the references in my tsconfig file are just dropped. One of the references has an invalid path, which tsc complains about, but dts does not. It also does not generate any types whatsoever. If I switch to a different tsconfig file that uses includes instead, it does work.

vite.config.build.ts

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import dts from "vite-plugin-dts"

const UseReferences = true;

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue(), dts({
    tsconfigPath: UseReferences ? "tsconfig.build.json" : "tsconfig.json"
  })],
  build: {
    emptyOutDir: true,
    lib: {
      formats: ["es"],
      entry: {
        main: "src/main.ts"
      }
    }
  }
})

tsconfig.build.json

{
  "files": [],
  "references": [{
    "path": "this/does/not/exist.json"
  }, {
    "path": "src/tsconfig.build.json"
  }]
}

src/tsconfig.build.json

{
  "compilerOptions": {
    "target": "esnext",
    "composite": true,
    "rootDir": ".",
    "baseUrl": "."
  }
}

tsconfig.json

{
  "compilerOptions": {
    "target": "esnext",
    "composite": true,
    "rootDir": "src",
    "baseUrl": "."
  },
  "include": [
    "src/**/*.ts"
  ]
}

Reproduction

https://github.com/incutonez/issues/blob/main/vite%20dts%20plugin%20references%20not%20working.7z

Steps to reproduce

  • Download the zip file
  • npm i
  • npm run build
  • Notice that only a main.js file is in the dist dir
  • Open vite.config.build.ts and change the UseReferences bool to false
  • npm run build
  • Notice that there's now a main.d.ts file

System Info

Windows 11
Node: 22.21.1
npm: 10.9.4
@vitejs/plugin-vue: ^6.0.2 => 6.0.4
vite: ^7.2.7 => 7.3.1
vite-plugin-dts: ~4.5.4 => 4.5.4

Validations

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