Skip to content

Commit

Permalink
fix: ensure parseNative result is correctly handled
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Dec 6, 2024
1 parent eea1c17 commit 593a611
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import _debug from 'debug'
import * as fs from 'fs'
import globRex from 'globrex'
import { resolve } from 'path'
import type { TSConfckParseOptions, TSConfckParseResult } from 'tsconfck'
import type {
TSConfckParseNativeResult,
TSConfckParseOptions,
TSConfckParseResult,
} from 'tsconfck'
import type { CompilerOptions } from 'typescript'
import { inspect } from 'util'
import { normalizePath, Plugin, searchForWorkspaceRoot } from 'vite'
Expand Down Expand Up @@ -218,7 +222,14 @@ export default (opts: PluginOptions = {}): Plugin => {
compilerOptions?: CompilerOptions
}

function resolvePathsRootDir(project: TSConfckParseResult): string {
function resolvePathsRootDir(
project: TSConfckParseResult | TSConfckParseNativeResult
): string {
if ('result' in project) {
return (
project.result.options?.pathsBasePath ?? dirname(project.tsconfigFile)
)
}
const baseUrl = (project.tsconfig as TsConfig).compilerOptions?.baseUrl
if (baseUrl) {
return baseUrl
Expand All @@ -229,7 +240,9 @@ export default (opts: PluginOptions = {}): Plugin => {
return dirname((projectWithPaths ?? project).tsconfigFile)
}

function createResolver(project: TSConfckParseResult): Resolver | null {
function createResolver(
project: TSConfckParseResult | TSConfckParseNativeResult
): Resolver | null {
const configPath = normalizePath(project.tsconfigFile)
const config = project.tsconfig as TsConfig

Expand Down

0 comments on commit 593a611

Please sign in to comment.