@@ -10,6 +10,7 @@ import {
1010 Resolver ,
1111 ResolverFactory ,
1212} from 'enhanced-resolve'
13+ import { hashObject } from 'eslint-module-utils/hash.js'
1314import { createPathsMatcher , getTsconfig } from 'get-tsconfig'
1415import type { TsConfigResult } from 'get-tsconfig'
1516import isCore from 'is-core-module'
@@ -114,7 +115,8 @@ const fileSystem = fs as FileSystem
114115const JS_EXT_PATTERN = / \. (?: [ c m ] j s | j s x ? ) $ /
115116const RELATIVE_PATH_PATTERN = / ^ \. { 1 , 2 } (?: \/ .* ) ? $ /
116117
117- let previousOptions : TsResolverOptions | null | undefined
118+ let previousOptionsHash : string
119+ let optionsHash : string
118120let cachedOptions : InternalResolverOptions | undefined
119121
120122let mappersCachedOptions : InternalResolverOptions
@@ -123,6 +125,9 @@ let mappers: Array<((specifier: string) => string[]) | null> | undefined
123125let resolverCachedOptions : InternalResolverOptions
124126let resolver : Resolver | undefined
125127
128+ const digestHashObject = ( value : object | null | undefined ) =>
129+ hashObject ( value ?? { } ) . digest ( 'hex' )
130+
126131/**
127132 * @param source the module to resolve; i.e './some-module'
128133 * @param file the importing file's full path; i.e. '/usr/local/bin/file.js'
@@ -137,8 +142,11 @@ export function resolve(
137142 found : boolean
138143 path ?: string | null
139144} {
140- if ( ! cachedOptions || previousOptions !== options ) {
141- previousOptions = options
145+ if (
146+ ! cachedOptions ||
147+ previousOptionsHash !== ( optionsHash = digestHashObject ( options ) )
148+ ) {
149+ previousOptionsHash = optionsHash
142150 cachedOptions = {
143151 ...options ,
144152 conditionNames : options ?. conditionNames ?? defaultConditionNames ,
0 commit comments