Skip to content

Commit

Permalink
fix: check before setting the default tsconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
9romise committed Jul 4, 2024
1 parent d4fc236 commit bc7f328
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/normalizeOptions.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { createRequire } from 'node:module'
import { cwd } from 'node:process'
import type { NapiResolveOptions } from 'oxc-resolver'

Expand Down Expand Up @@ -68,9 +69,12 @@ const defaultOptions: NapiResolveOptions = {

export function normalizeOptions(options: NapiResolveOptions | null = {}): NapiResolveOptions {
if (!options?.tsconfig) {
defaultOptions.tsconfig = {
configFile: './tsconfig.json',
references: 'auto',
const configFile = createRequire(cwd()).resolve('./tsconfig.json', { paths: [cwd()] })
if (configFile) {
defaultOptions.tsconfig = {
configFile,
references: 'auto',
}
}
}
return {
Expand Down

0 comments on commit bc7f328

Please sign in to comment.