Skip to content

Commit 593a611

Browse files
committed
fix: ensure parseNative result is correctly handled
1 parent eea1c17 commit 593a611

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/index.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import _debug from 'debug'
22
import * as fs from 'fs'
33
import globRex from 'globrex'
44
import { resolve } from 'path'
5-
import type { TSConfckParseOptions, TSConfckParseResult } from 'tsconfck'
5+
import type {
6+
TSConfckParseNativeResult,
7+
TSConfckParseOptions,
8+
TSConfckParseResult,
9+
} from 'tsconfck'
610
import type { CompilerOptions } from 'typescript'
711
import { inspect } from 'util'
812
import { normalizePath, Plugin, searchForWorkspaceRoot } from 'vite'
@@ -218,7 +222,14 @@ export default (opts: PluginOptions = {}): Plugin => {
218222
compilerOptions?: CompilerOptions
219223
}
220224

221-
function resolvePathsRootDir(project: TSConfckParseResult): string {
225+
function resolvePathsRootDir(
226+
project: TSConfckParseResult | TSConfckParseNativeResult
227+
): string {
228+
if ('result' in project) {
229+
return (
230+
project.result.options?.pathsBasePath ?? dirname(project.tsconfigFile)
231+
)
232+
}
222233
const baseUrl = (project.tsconfig as TsConfig).compilerOptions?.baseUrl
223234
if (baseUrl) {
224235
return baseUrl
@@ -229,7 +240,9 @@ export default (opts: PluginOptions = {}): Plugin => {
229240
return dirname((projectWithPaths ?? project).tsconfigFile)
230241
}
231242

232-
function createResolver(project: TSConfckParseResult): Resolver | null {
243+
function createResolver(
244+
project: TSConfckParseResult | TSConfckParseNativeResult
245+
): Resolver | null {
233246
const configPath = normalizePath(project.tsconfigFile)
234247
const config = project.tsconfig as TsConfig
235248

0 commit comments

Comments
 (0)