From 6d78d4e9637020837997166a94d2fa09e1f7ad6b Mon Sep 17 00:00:00 2001 From: Luke Murray Date: Tue, 28 Mar 2023 07:15:26 -0400 Subject: [PATCH] fix: check if cwd changed to bust mapper cache --- src/index.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 54d17cc..438dd69 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 @@ -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'