Cherry-pick PR #46209 into release-4.4 (#46230)

Component commits:
228679871a Limit package.json realpath lookup to only successful resolutions

Co-authored-by: Wesley Wigham <t-weswig@microsoft.com>
This commit is contained in:
TypeScript Bot 2021-10-05 17:42:01 -07:00 committed by GitHub
parent bbb31bb109
commit 34988fd49e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -873,7 +873,7 @@ namespace ts {
);
state.lastCachedPackageJsonLookups.set(projectPath, state.moduleResolutionCache && map(
state.moduleResolutionCache.getPackageJsonInfoCache().entries(),
([path, data]) => ([state.host.realpath ? toPath(state, state.host.realpath(path)) : path, data] as const)
([path, data]) => ([state.host.realpath && data ? toPath(state, state.host.realpath(path)) : path, data] as const)
));
if (state.watch) {