Skip to content

Commit

Permalink
Use get-tsconfig to resolve tsconfig settings (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x80 authored Jan 11, 2025
1 parent 8a36324 commit 6e1495e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"@pnpm/types": "^9.4.2",
"chalk": "^5.3.0",
"fs-extra": "^11.2.0",
"get-tsconfig": "^4.8.1",
"glob": "^10.4.5",
"outdent": "^0.8.0",
"pnpm_lockfile_file_v8": "npm:@pnpm/lockfile-file@8",
Expand Down
15 changes: 15 additions & 0 deletions pnpm-lock.yaml

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

13 changes: 5 additions & 8 deletions src/lib/output/get-build-output-dir.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import fs from "fs-extra";
import { getTsconfig } from "get-tsconfig";
import path from "node:path";
import outdent from "outdent";
import { useConfig } from "../config";
import { useLogger } from "../logger";
import { readTypedJson } from "../utils";

export async function getBuildOutputDir(targetPackageDir: string) {
const config = useConfig();
Expand All @@ -16,14 +15,12 @@ export async function getBuildOutputDir(targetPackageDir: string) {

const tsconfigPath = path.join(targetPackageDir, config.tsconfigPath);

if (fs.existsSync(tsconfigPath)) {
log.debug("Found tsconfig at:", config.tsconfigPath);
const tsconfig = getTsconfig(tsconfigPath);

const tsconfig = await readTypedJson<{
compilerOptions?: { outDir?: string };
}>(tsconfigPath);
if (tsconfig) {
log.debug("Found tsconfig at:", tsconfig.path);

const outDir = tsconfig.compilerOptions?.outDir;
const outDir = tsconfig.config.compilerOptions?.outDir;

if (outDir) {
return path.join(targetPackageDir, outDir);
Expand Down

0 comments on commit 6e1495e

Please sign in to comment.