Skip to content

Commit

Permalink
refactor: migrate from jsonc-parser to unjs/confbox (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 authored Apr 17, 2024
1 parent 20c42e6 commit e74df30
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit e74df30

Please sign in to comment.