From 0d0b255ad2731746a3ad2b484ee756cd92994651 Mon Sep 17 00:00:00 2001 From: qmhc <40221744+qmhc@users.noreply.github.com> Date: Mon, 15 Jan 2024 16:49:01 +0800 Subject: [PATCH] fix: manually collect compiler options for types rollup fix #297 --- src/plugin.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plugin.ts b/src/plugin.ts index fe6171e..94cc5e9 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -24,6 +24,7 @@ import { ensureAbsolute, ensureArray, findTypesPath, + getTsConfig, isNativeObj, isRegExp, normalizePath, @@ -648,6 +649,9 @@ export function dtsPlugin(options: PluginOptions = {}): import('vite').Plugin { } const rollupFiles = new Set() + const compilerOptions = configPath + ? getTsConfig(configPath, host.readFile).compilerOptions + : rawCompilerOptions if (multiple) { for (const name of entryNames) { @@ -656,7 +660,7 @@ export function dtsPlugin(options: PluginOptions = {}): import('vite').Plugin { rollupDeclarationFiles({ root, configPath, - compilerOptions: rawCompilerOptions, + compilerOptions, outDir, entryPath: path, fileName: basename(path), @@ -672,7 +676,7 @@ export function dtsPlugin(options: PluginOptions = {}): import('vite').Plugin { rollupDeclarationFiles({ root, configPath, - compilerOptions: rawCompilerOptions, + compilerOptions, outDir, entryPath: typesPath, fileName: basename(typesPath),