Skip to content

Commit

Permalink
fix: lazily import tsconfck
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Jan 16, 2024
1 parent afe1fed commit cb9b582
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _debug from 'debug'
import * as fs from 'fs'
import globRex from 'globrex'
import { resolve } from 'path'
import * as tsconfck from 'tsconfck'
import type { TSConfckParseOptions, TSConfckParseResult } from 'tsconfck'
import type { CompilerOptions } from 'typescript'
import { inspect } from 'util'
import { normalizePath, Plugin, searchForWorkspaceRoot } from 'vite'
Expand Down Expand Up @@ -51,6 +51,8 @@ export default (opts: PluginOptions = {}): Plugin => {
workspaceRoot = root
}

const tsconfck = await import('tsconfck')

const projects = opts.projects
? opts.projects.map((file) => {
if (!file.endsWith('.json')) {
Expand Down Expand Up @@ -86,7 +88,7 @@ export default (opts: PluginOptions = {}): Plugin => {

let firstError: any

const parseOptions: tsconfck.TSConfckParseOptions = {
const parseOptions: TSConfckParseOptions = {
cache: new tsconfck.TSConfckCache(),
}

Expand Down Expand Up @@ -187,9 +189,7 @@ export default (opts: PluginOptions = {}): Plugin => {
},
}

function createResolver(
project: tsconfck.TSConfckParseResult
): Resolver | null {
function createResolver(project: TSConfckParseResult): Resolver | null {
const configPath = normalizePath(project.tsconfigFile)
const config = project.tsconfig as {
files?: string[]
Expand Down

0 comments on commit cb9b582

Please sign in to comment.