Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: migrate from jsonc-parser to unjs/confbox #174

Merged
merged 6 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading