@@ -10,6 +10,7 @@ import {
10
10
Resolver ,
11
11
ResolverFactory ,
12
12
} from 'enhanced-resolve'
13
+ import { hashObject } from 'eslint-module-utils/hash.js'
13
14
import { createPathsMatcher , getTsconfig } from 'get-tsconfig'
14
15
import type { TsConfigResult } from 'get-tsconfig'
15
16
import isCore from 'is-core-module'
@@ -114,7 +115,8 @@ const fileSystem = fs as FileSystem
114
115
const JS_EXT_PATTERN = / \. (?: [ c m ] j s | j s x ? ) $ /
115
116
const RELATIVE_PATH_PATTERN = / ^ \. { 1 , 2 } (?: \/ .* ) ? $ /
116
117
117
- let previousOptions : TsResolverOptions | null | undefined
118
+ let previousOptionsHash : string
119
+ let optionsHash : string
118
120
let cachedOptions : InternalResolverOptions | undefined
119
121
120
122
let mappersCachedOptions : InternalResolverOptions
@@ -123,6 +125,9 @@ let mappers: Array<((specifier: string) => string[]) | null> | undefined
123
125
let resolverCachedOptions : InternalResolverOptions
124
126
let resolver : Resolver | undefined
125
127
128
+ const digestHashObject = ( value : object | null | undefined ) =>
129
+ hashObject ( value ?? { } ) . digest ( 'hex' )
130
+
126
131
/**
127
132
* @param source the module to resolve; i.e './some-module'
128
133
* @param file the importing file's full path; i.e. '/usr/local/bin/file.js'
@@ -137,8 +142,11 @@ export function resolve(
137
142
found : boolean
138
143
path ?: string | null
139
144
} {
140
- if ( ! cachedOptions || previousOptions !== options ) {
141
- previousOptions = options
145
+ if (
146
+ ! cachedOptions ||
147
+ previousOptionsHash !== ( optionsHash = digestHashObject ( options ) )
148
+ ) {
149
+ previousOptionsHash = optionsHash
142
150
cachedOptions = {
143
151
...options ,
144
152
conditionNames : options ?. conditionNames ?? defaultConditionNames ,
0 commit comments