Skip to content

Commit

Permalink
fix: replace custom tsConfig resolver with xtends
Browse files Browse the repository at this point in the history
closes #174
  • Loading branch information
antongolub committed Oct 31, 2024
1 parent a46afa4 commit 9ef4877
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"publish:rc": "npm publish --no-git-tag-version --tag rc"
},
"dependencies": {
"@topoconfig/extends": "^0.16.2",
"depseek": "^0.4.1",
"fast-glob": "^3.3.2",
"fs-extra": "^11.2.0",
Expand Down
19 changes: 4 additions & 15 deletions src/main/ts/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { dirname, resolve } from 'node:path'

import fse from 'fs-extra'
import json5 from 'json5'
import { populateSync } from "@topoconfig/extends";

import { TSConfig } from './interface'

Expand All @@ -24,21 +25,9 @@ export const remove = fse.unlinkSync

export const unixify = (path: string): string => path.replace(/\\/g, '/')

export const resolveTsConfig = (file: string): TSConfig => {
const data = readJson<TSConfig>(file)

if (data.extends) {
const parent = resolveTsConfig(resolve(dirname(file), data.extends))

return {
...parent,
...data,
compilerOptions: { ...parent.compilerOptions, ...data.compilerOptions },
}
}

return data
}
export const resolveTsConfig = (file: string): TSConfig => populateSync(file, {
compilerOptions: 'merge'
})

export const omitUndefinedKeys = <T extends Record<string, any>>(obj: T): T =>
Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== undefined)) as T
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,11 @@
dependencies:
"@sinonjs/commons" "^3.0.0"

"@topoconfig/extends@^0.16.2":
version "0.16.2"
resolved "https://registry.yarnpkg.com/@topoconfig/extends/-/extends-0.16.2.tgz#0741dbe5198a28f306a116498f7ded1089d0fadc"
integrity sha512-sTF+qpWakr5jf1Hn/kkFSi833xPW15s/loMAiKSYSSVv4vDonxf6hwCGzMXjLq+7HZoaK6BgaV72wXr1eY7FcQ==

"@trivago/prettier-plugin-sort-imports@^4.1.1":
version "4.3.0"
resolved "https://registry.yarnpkg.com/@trivago/prettier-plugin-sort-imports/-/prettier-plugin-sort-imports-4.3.0.tgz#725f411646b3942193a37041c84e0b2116339789"
Expand Down

0 comments on commit 9ef4877

Please sign in to comment.