diff --git a/CHANGELOG.md b/CHANGELOG.md index b5c0e2298881..b433bfc61233 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ### Features - `[jest-haste-map]` ignore Sapling vcs directories (`.sl/`) ([#13674](https://github.com/facebook/jest/pull/13674)) -- `[jest-resolve]` Support subpath imports ([#13705](https://github.com/facebook/jest/pull/13705)) +- `[jest-resolve]` Support subpath imports ([#13705](https://github.com/facebook/jest/pull/13705), [#13723](https://github.com/facebook/jest/pull/13723)) - `[jest-runtime]` Add `jest.isolateModulesAsync` for scoped module initialization of asynchronous functions ([#13680](https://github.com/facebook/jest/pull/13680)) - `[jest-test-result]` Added `skipped` and `focused` status to `FormattedTestResult` ([#13700](https://github.com/facebook/jest/pull/13700)) diff --git a/copy.mjs b/copy.mjs deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/packages/jest-resolve/src/defaultResolver.ts b/packages/jest-resolve/src/defaultResolver.ts index 4672c6ce6e41..91dc2b00a152 100644 --- a/packages/jest-resolve/src/defaultResolver.ts +++ b/packages/jest-resolve/src/defaultResolver.ts @@ -164,14 +164,19 @@ function resolveByPathInModule( const resolvedValues = Array.isArray(resolved) ? resolved : [resolved]; + let lastError: Error; for (const resolved of resolvedValues) { const resolvedPath = resolveByPath(resolved); + try { return resolveSync(resolvedPath, options); - } catch (e) { + } catch (e: any) { + lastError = e; continue; } } + // eslint-disable-next-line no-throw-literal + throw lastError!; function resolveByPath(resolved: string) { if (resolved.startsWith('.')) {