Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add conditionNames support #114

Merged
merged 1 commit into from
Jun 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ const defaultMainFields = [
'main',
]

const defaultConditionNames = [
'types',
'import',
'require',
'node',
'node-addons',
'browser',
'default',
]

export const interfaceVersion = 2

export interface TsResolverOptions
Expand All @@ -63,6 +73,7 @@ export interface TsResolverOptions
project?: string[] | string
extensions?: string[]
packageFilter?: (pkg: Record<string, string>) => Record<string, string>
conditionNamesMapper?: Record<string, string[]>
}

const fileSystem = fs as FileSystem
Expand All @@ -88,6 +99,7 @@ export function resolve(
...options,
extensions: options?.extensions ?? defaultExtensions,
mainFields: options?.mainFields ?? defaultMainFields,
conditionNames: options?.conditionNames ?? defaultConditionNames,
fileSystem,
useSyncFileSystemCalls: true,
}
Expand Down