diff --git a/package.json b/package.json index fa9be6c..9f9cddf 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "test:types": "tsc --noEmit --module esnext --skipLibCheck --moduleResolution node ./test/*.test.ts" }, "dependencies": { - "jsonc-parser": "^3.2.1", + "confbox": "^0.1.6", "mlly": "^1.6.1", "pathe": "^1.1.2" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ba0ca0b..9740f02 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,9 +8,9 @@ importers: .: dependencies: - jsonc-parser: - specifier: ^3.2.1 - version: 3.2.1 + confbox: + specifier: ^0.1.6 + version: 0.1.6 mlly: specifier: ^1.6.1 version: 1.6.1 diff --git a/src/index.ts b/src/index.ts index af08349..e3198d1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,6 +3,7 @@ import { dirname, resolve, isAbsolute } from "pathe"; import { ResolveOptions as _ResolveOptions, resolvePath } from "mlly"; import { findFile, FindFileOptions, findNearestFile } from "./utils"; import type { PackageJson, TSConfig } from "./types"; +import { parseJSONC } from "confbox"; export * from "./types"; export * from "./utils"; @@ -97,9 +98,8 @@ export async function readTSConfig( if (options.cache && cache.has(resolvedPath)) { return cache.get(resolvedPath)!; } - const blob = await fsp.readFile(resolvedPath, "utf8"); - const jsonc = await import("jsonc-parser"); - const parsed = jsonc.parse(blob) as TSConfig; + const text = await fsp.readFile(resolvedPath, "utf8"); + const parsed = parseJSONC(text) as TSConfig; cache.set(resolvedPath, parsed); return parsed; }