Skip to content

Commit 9062260

Browse files
committed
fix: catch error when options is null
got the error when set `{ settings: { 'import-x/resolver': 'oxc' } }`
1 parent d48902a commit 9062260

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ResolverFactory } from 'oxc-resolver'
33
import { normalizeOptions } from './nomalizeOptions'
44

55
let resolver: ResolverFactory | undefined
6-
export function resolve(source: string, file: string, options: NapiResolveOptions = {}): { found: boolean, path?: string } {
6+
export function resolve(source: string, file: string, options: NapiResolveOptions | null = {}): { found: boolean, path?: string } {
77
if (!resolver) {
88
options = normalizeOptions(options)
99
resolver = new ResolverFactory(options)

src/nomalizeOptions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ const defaultOptions: NapiResolveOptions = {
6666
roots: [cwd()],
6767
}
6868

69-
export function normalizeOptions(options: NapiResolveOptions = {}): NapiResolveOptions {
70-
if (!options.tsconfig) {
69+
export function normalizeOptions(options: NapiResolveOptions | null = {}): NapiResolveOptions {
70+
if (!options?.tsconfig) {
7171
defaultOptions.tsconfig = {
7272
configFile: './tsconfig.json',
7373
references: 'auto',

0 commit comments

Comments
 (0)