Open chandu opened 4 months ago
As a developer using vite-plugin-dts I want to be able to use the ${configDir} template variable in tsconfig.json (added in typescript 5.5 - https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#the-configdir-template-variable-for-configuration-files ), specially when using a shared tsconfig in monorepo.
${configDir}
In it's current version, vite-plugin-dts is not generating any type defintiion files, when ${configDir} is used in the include property of tsconfig.json files.
include
tsconfig.json
The repo @ https://github.com/chandu/vite-dts-config-dir-test demonstrates the issue. Clone the repo and then issue the following commands:
pnpm i
pnpm run build // Prints Dts File Exists: true
pnpm run build
pnpm run build-config-dir // Prints Dts File Exists: false, this script is running the build using the tsconfig that has the ${configDir} reference
pnpm run build-config-dir
The issue happens to be because the newly introduced configDir template variable nuances are not used/leveared by the @vue/language-core package.
configDir
@vue/language-core
Where the configFileSpecs is assigned: https://github.com/microsoft/TypeScript/blob/main/src/compiler/commandLineParser.ts#L2945
Where the updated configFileSpecs is not leveraged: https://github.com/vuejs/language-tools/blob/7d44d8e844ef4f51407e57ce39e5570c9c9b6ece/packages/language-core/lib/utils/ts.ts#L84
Where the createParsedCommandLine function of @vue/language-core is called: https://github.com/qmhc/vite-plugin-dts/blob/main/src/plugin.ts#L261
createParsedCommandLine
I am not sure what is the right fix/solution.
One possible way is to modify the @vue/language-core to also return 'configFileSpecs' populated on the config object at https://github.com/vuejs/language-tools/blob/7d44d8e844ef4f51407e57ce39e5570c9c9b6ece/packages/language-core/lib/utils/ts.ts#L84 and the propagate that to the vite-plugin-dts where the include/exclude could be rightly used when calling the createFilter, ut would span updating more than one package.
config
vite-plugin-dts
createFilter
or
use the tsconfig file/content to parse the file, get the configFileSpecs and use the validatedIncludeSpecs and validatedExcludeSpecs to create the filter at https://github.com/qmhc/vite-plugin-dts/blob/main/src/plugin.ts#L323
configFileSpecs
validatedIncludeSpecs
validatedExcludeSpecs
I am sure there could be better solutions, but this is what I could think of with limited insights into the typescript tsconfig parsing.
For now, I am passing the resolved/hardcoded include/exlcude as the dts plugin options.
No response
Hey @chandu, any chance you could give a try with my solution ? I'm not a vue user so I can't validate that it's also matching you use case ?
Description
As a developer using vite-plugin-dts I want to be able to use the
${configDir}
template variable in tsconfig.json (added in typescript 5.5 - https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#the-configdir-template-variable-for-configuration-files ), specially when using a shared tsconfig in monorepo.In it's current version, vite-plugin-dts is not generating any type defintiion files, when ${configDir} is used in the
include
property oftsconfig.json
files.The repo @ https://github.com/chandu/vite-dts-config-dir-test demonstrates the issue. Clone the repo and then issue the following commands:
pnpm i
pnpm run build
// Prints Dts File Exists: truepnpm run build-config-dir
// Prints Dts File Exists: false, this script is running the build using the tsconfig that has the ${configDir} referenceSuggested solution
The issue happens to be because the newly introduced
configDir
template variable nuances are not used/leveared by the@vue/language-core
package.Where the configFileSpecs is assigned: https://github.com/microsoft/TypeScript/blob/main/src/compiler/commandLineParser.ts#L2945
Where the updated configFileSpecs is not leveraged: https://github.com/vuejs/language-tools/blob/7d44d8e844ef4f51407e57ce39e5570c9c9b6ece/packages/language-core/lib/utils/ts.ts#L84
Where the
createParsedCommandLine
function of@vue/language-core
is called: https://github.com/qmhc/vite-plugin-dts/blob/main/src/plugin.ts#L261I am not sure what is the right fix/solution.
One possible way is to modify the
@vue/language-core
to also return 'configFileSpecs' populated on theconfig
object at https://github.com/vuejs/language-tools/blob/7d44d8e844ef4f51407e57ce39e5570c9c9b6ece/packages/language-core/lib/utils/ts.ts#L84 and the propagate that to thevite-plugin-dts
where the include/exclude could be rightly used when calling thecreateFilter
, ut would span updating more than one package.or
use the tsconfig file/content to parse the file, get the
configFileSpecs
and use thevalidatedIncludeSpecs
andvalidatedExcludeSpecs
to create the filter at https://github.com/qmhc/vite-plugin-dts/blob/main/src/plugin.ts#L323I am sure there could be better solutions, but this is what I could think of with limited insights into the typescript tsconfig parsing.
Alternative
For now, I am passing the resolved/hardcoded include/exlcude as the dts plugin options.
Additional context
No response
Validations