Skip to content

Commit 8a30939

Browse files
committed
chore: add default tsconfig
1 parent 9431d75 commit 8a30939

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/index.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,24 @@ const defaultOptions: NapiResolveOptions = {
6767
roots: [cwd()],
6868
}
6969

70+
function normalizeOptions(options: NapiResolveOptions): NapiResolveOptions {
71+
if (!options.tsconfig) {
72+
defaultOptions.tsconfig = {
73+
configFile: './tsconfig.json',
74+
references: 'auto',
75+
}
76+
}
77+
return {
78+
...defaultOptions,
79+
...options,
80+
}
81+
}
82+
7083
let resolver: ResolverFactory | undefined
71-
export function resolve(
72-
source: string,
73-
file: string,
74-
options: NapiResolveOptions = {},
75-
): { found: boolean, path?: string } {
84+
export function resolve(source: string, file: string, options: NapiResolveOptions = {}): { found: boolean, path?: string } {
7685
if (!resolver) {
77-
resolver = new ResolverFactory({
78-
...defaultOptions,
79-
...options,
80-
})
86+
options = normalizeOptions(options)
87+
resolver = new ResolverFactory(options)
8188
}
8289

8390
const result = resolver.sync(file, source)

0 commit comments

Comments
 (0)