Skip to content

Commit 329387d

Browse files
authored
Fix missing failed lookup locations when resolving bare-specifier package.json "imports" (#60924)
1 parent 51d9a98 commit 329387d

File tree

3 files changed

+462
-0
lines changed

3 files changed

+462
-0
lines changed

src/compiler/moduleNameResolver.ts

+5
Original file line numberDiff line numberDiff line change
@@ -2756,6 +2756,11 @@ function getLoadModuleFromTargetExportOrImport(extensions: Extensions, state: Mo
27562756
traceIfEnabled(state, Diagnostics.Using_0_subpath_1_with_target_2, "imports", key, combinedLookup);
27572757
traceIfEnabled(state, Diagnostics.Resolving_module_0_from_1, combinedLookup, scope.packageDirectory + "/");
27582758
const result = nodeModuleNameResolverWorker(state.features, combinedLookup, scope.packageDirectory + "/", state.compilerOptions, state.host, cache, extensions, /*isConfigLookup*/ false, redirectedReference, state.conditions);
2759+
// Note: we cannot safely reassign `state.failedLookupLocations` during a request;
2760+
// `nodeModuleNameResolverWorker` relies on the `state` property remaining reference-equal
2761+
// to the one it initializes.
2762+
state.failedLookupLocations?.push(...result.failedLookupLocations ?? emptyArray);
2763+
state.affectingLocations?.push(...result.affectingLocations ?? emptyArray);
27592764
return toSearchResult(
27602765
result.resolvedModule ? {
27612766
path: result.resolvedModule.resolvedFileName,

0 commit comments

Comments
 (0)