Skip to content

Commit

Permalink
fix: check if cwd changed to bust mapper cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Murray authored and JounQin committed Mar 29, 2023
1 parent 996d3b0 commit 6d78d4e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/index.ts
Expand Up @@ -119,6 +119,8 @@ let previousOptionsHash: string
let optionsHash: string
let cachedOptions: InternalResolverOptions | undefined

let prevCwd: string

let mappersCachedOptions: InternalResolverOptions
let mappers: Array<((specifier: string) => string[]) | null> | undefined

Expand Down Expand Up @@ -347,9 +349,14 @@ function getMappedPath(
}

function initMappers(options: InternalResolverOptions) {
if (mappers && mappersCachedOptions === options) {
if (
mappers &&
mappersCachedOptions === options &&
prevCwd === process.cwd()
) {
return
}
prevCwd = process.cwd()

const configPaths =
typeof options.project === 'string'
Expand Down

0 comments on commit 6d78d4e

Please sign in to comment.