@typescript-deploys/pr-build 5.9.0-pr-61732-3 → 5.9.0-pr-61739-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/typescript.js CHANGED
@@ -323,7 +323,6 @@ __export(typescript_exports, {
323
323
  computeLineOfPosition: () => computeLineOfPosition,
324
324
  computeLineStarts: () => computeLineStarts,
325
325
  computePositionOfLineAndCharacter: () => computePositionOfLineAndCharacter,
326
- computeRedirectsCacheKey: () => computeRedirectsCacheKey,
327
326
  computeSignatureWithDiagnostics: () => computeSignatureWithDiagnostics,
328
327
  computeSuggestionDiagnostics: () => computeSuggestionDiagnostics,
329
328
  computedOptions: () => computedOptions,
@@ -448,7 +447,6 @@ __export(typescript_exports, {
448
447
  createScanner: () => createScanner,
449
448
  createSemanticDiagnosticsBuilderProgram: () => createSemanticDiagnosticsBuilderProgram,
450
449
  createSet: () => createSet,
451
- createSharedResolutionCache: () => createSharedResolutionCache,
452
450
  createSolutionBuilder: () => createSolutionBuilder,
453
451
  createSolutionBuilderHost: () => createSolutionBuilderHost,
454
452
  createSolutionBuilderWithWatch: () => createSolutionBuilderWithWatch,
@@ -516,8 +514,6 @@ __export(typescript_exports, {
516
514
  emptyFileSystemEntries: () => emptyFileSystemEntries,
517
515
  emptyMap: () => emptyMap,
518
516
  emptyOptions: () => emptyOptions,
519
- emptyResolution: () => emptyResolution,
520
- enableSharingModuleOrTypeReferenceResolutionCache: () => enableSharingModuleOrTypeReferenceResolutionCache,
521
517
  endsWith: () => endsWith,
522
518
  ensurePathIsNonModuleName: () => ensurePathIsNonModuleName,
523
519
  ensureScriptKind: () => ensureScriptKind,
@@ -655,7 +651,6 @@ __export(typescript_exports, {
655
651
  getAssignmentDeclarationKind: () => getAssignmentDeclarationKind,
656
652
  getAssignmentDeclarationPropertyAccessKind: () => getAssignmentDeclarationPropertyAccessKind,
657
653
  getAssignmentTargetKind: () => getAssignmentTargetKind,
658
- getAutomaticTypeDirectiveContainingFile: () => getAutomaticTypeDirectiveContainingFile,
659
654
  getAutomaticTypeDirectiveNames: () => getAutomaticTypeDirectiveNames,
660
655
  getBaseFileName: () => getBaseFileName,
661
656
  getBinaryOperatorPrecedence: () => getBinaryOperatorPrecedence,
@@ -715,6 +710,7 @@ __export(typescript_exports, {
715
710
  getDiagnosticsWithinSpan: () => getDiagnosticsWithinSpan,
716
711
  getDirectoryPath: () => getDirectoryPath,
717
712
  getDirectoryToWatchFailedLookupLocation: () => getDirectoryToWatchFailedLookupLocation,
713
+ getDirectoryToWatchFailedLookupLocationFromTypeRoot: () => getDirectoryToWatchFailedLookupLocationFromTypeRoot,
718
714
  getDocumentPositionMapper: () => getDocumentPositionMapper,
719
715
  getDocumentSpansEqualityComparer: () => getDocumentSpansEqualityComparer,
720
716
  getESModuleInterop: () => getESModuleInterop,
@@ -1682,9 +1678,6 @@ __export(typescript_exports, {
1682
1678
  isRegularExpressionLiteral: () => isRegularExpressionLiteral,
1683
1679
  isRequireCall: () => isRequireCall,
1684
1680
  isRequireVariableStatement: () => isRequireVariableStatement,
1685
- isResolvedWithGlobalCachePass: () => isResolvedWithGlobalCachePass,
1686
- isResolvedWithGlobalCachePassButStillUnresolved: () => isResolvedWithGlobalCachePassButStillUnresolved,
1687
- isResolvedWithoutGlobalCachePass: () => isResolvedWithoutGlobalCachePass,
1688
1681
  isRestParameter: () => isRestParameter,
1689
1682
  isRestTypeNode: () => isRestTypeNode,
1690
1683
  isReturnStatement: () => isReturnStatement,
@@ -1804,7 +1797,6 @@ __export(typescript_exports, {
1804
1797
  isUnaryExpressionWithWrite: () => isUnaryExpressionWithWrite,
1805
1798
  isUnicodeIdentifierStart: () => isUnicodeIdentifierStart,
1806
1799
  isUnionTypeNode: () => isUnionTypeNode,
1807
- isUnresolvedOrResolvedToJs: () => isUnresolvedOrResolvedToJs,
1808
1800
  isUrl: () => isUrl,
1809
1801
  isValidBigIntString: () => isValidBigIntString,
1810
1802
  isValidESSymbolDeclaration: () => isValidESSymbolDeclaration,
@@ -1889,7 +1881,6 @@ __export(typescript_exports, {
1889
1881
  mutateMap: () => mutateMap,
1890
1882
  mutateMapSkippingNewValues: () => mutateMapSkippingNewValues,
1891
1883
  needsParentheses: () => needsParentheses,
1892
- needsResolutionFromGlobalCache: () => needsResolutionFromGlobalCache,
1893
1884
  needsScopeMarker: () => needsScopeMarker,
1894
1885
  newCaseClauseTracker: () => newCaseClauseTracker,
1895
1886
  newPrivateEnvironment: () => newPrivateEnvironment,
@@ -2247,7 +2238,6 @@ __export(typescript_exports, {
2247
2238
  typeDirectiveIsEqualTo: () => typeDirectiveIsEqualTo,
2248
2239
  typeKeywords: () => typeKeywords,
2249
2240
  typeParameterNamePart: () => typeParameterNamePart,
2250
- typeReferenceResolutionNameAndModeGetter: () => typeReferenceResolutionNameAndModeGetter,
2251
2241
  typeToDisplayParts: () => typeToDisplayParts,
2252
2242
  unchangedPollThresholds: () => unchangedPollThresholds,
2253
2243
  unchangedTextChangeRange: () => unchangedTextChangeRange,
@@ -2263,6 +2253,7 @@ __export(typescript_exports, {
2263
2253
  updateErrorForNoInputFiles: () => updateErrorForNoInputFiles,
2264
2254
  updateLanguageServiceSourceFile: () => updateLanguageServiceSourceFile,
2265
2255
  updateMissingFilePathsWatch: () => updateMissingFilePathsWatch,
2256
+ updateResolutionField: () => updateResolutionField,
2266
2257
  updateSharedExtendedConfigFileWatcher: () => updateSharedExtendedConfigFileWatcher,
2267
2258
  updateSourceFile: () => updateSourceFile,
2268
2259
  updateWatchingWildcardDirectories: () => updateWatchingWildcardDirectories,
@@ -2295,7 +2286,7 @@ module.exports = __toCommonJS(typescript_exports);
2295
2286
 
2296
2287
  // src/compiler/corePublic.ts
2297
2288
  var versionMajorMinor = "5.9";
2298
- var version = `${versionMajorMinor}.0-insiders.20250519`;
2289
+ var version = `${versionMajorMinor}.0-insiders.20250520`;
2299
2290
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2300
2291
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2301
2292
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -6803,10 +6794,10 @@ var LanguageVariant = /* @__PURE__ */ ((LanguageVariant4) => {
6803
6794
  LanguageVariant4[LanguageVariant4["JSX"] = 1] = "JSX";
6804
6795
  return LanguageVariant4;
6805
6796
  })(LanguageVariant || {});
6806
- var WatchDirectoryFlags = /* @__PURE__ */ ((WatchDirectoryFlags4) => {
6807
- WatchDirectoryFlags4[WatchDirectoryFlags4["None"] = 0] = "None";
6808
- WatchDirectoryFlags4[WatchDirectoryFlags4["Recursive"] = 1] = "Recursive";
6809
- return WatchDirectoryFlags4;
6797
+ var WatchDirectoryFlags = /* @__PURE__ */ ((WatchDirectoryFlags3) => {
6798
+ WatchDirectoryFlags3[WatchDirectoryFlags3["None"] = 0] = "None";
6799
+ WatchDirectoryFlags3[WatchDirectoryFlags3["Recursive"] = 1] = "Recursive";
6800
+ return WatchDirectoryFlags3;
6810
6801
  })(WatchDirectoryFlags || {});
6811
6802
  var CharacterCodes = /* @__PURE__ */ ((CharacterCodes2) => {
6812
6803
  CharacterCodes2[CharacterCodes2["EOF"] = -1] = "EOF";
@@ -43973,40 +43964,19 @@ function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName
43973
43964
  alternateResult
43974
43965
  );
43975
43966
  }
43976
- function updateResultFromCache(resultFromCache, failedLookupLocations, affectingLocations, diagnostics) {
43977
- resultFromCache.failedLookupLocations = updateResolutionField(resultFromCache.failedLookupLocations, failedLookupLocations);
43978
- resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations);
43979
- resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics);
43980
- }
43981
- function updatePrimaryAndGlobalCacheResolution(primaryWithGlobalCacheResult, failedLookupLocations, affectingLocations, diagnostics) {
43982
- updateResultFromCache(primaryWithGlobalCacheResult, failedLookupLocations, affectingLocations, diagnostics);
43983
- if (primaryWithGlobalCacheResult.globalCacheResolution.globalResult.resolvedModule) {
43984
- updateResultFromCache(primaryWithGlobalCacheResult.globalCacheResolution.globalResult, failedLookupLocations, affectingLocations, diagnostics);
43985
- } else {
43986
- primaryWithGlobalCacheResult.globalCacheResolution.globalResult.failedLookupLocations = primaryWithGlobalCacheResult.failedLookupLocations;
43987
- primaryWithGlobalCacheResult.globalCacheResolution.globalResult.affectingLocations = primaryWithGlobalCacheResult.affectingLocations;
43988
- primaryWithGlobalCacheResult.globalCacheResolution.globalResult.resolutionDiagnostics = primaryWithGlobalCacheResult.resolutionDiagnostics;
43989
- }
43990
- }
43991
43967
  function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache, cache, alternateResult) {
43992
- var _a;
43993
43968
  if (resultFromCache) {
43994
43969
  if (!(cache == null ? void 0 : cache.isReadonly)) {
43995
- if (isResolvedWithGlobalCachePass(resultFromCache)) {
43996
- updatePrimaryAndGlobalCacheResolution(resultFromCache.globalCacheResolution.primary, failedLookupLocations, affectingLocations, diagnostics);
43997
- } else if ((_a = resultFromCache.globalCacheResolution) == null ? void 0 : _a.globalResult) {
43998
- updatePrimaryAndGlobalCacheResolution(resultFromCache, failedLookupLocations, affectingLocations, diagnostics);
43999
- } else {
44000
- updateResultFromCache(resultFromCache, failedLookupLocations, affectingLocations, diagnostics);
44001
- }
43970
+ resultFromCache.failedLookupLocations = updateResolutionField(resultFromCache.failedLookupLocations, failedLookupLocations);
43971
+ resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations);
43972
+ resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics);
44002
43973
  return resultFromCache;
44003
43974
  } else {
44004
43975
  return {
44005
- resolvedModule: resultFromCache.resolvedModule,
43976
+ ...resultFromCache,
44006
43977
  failedLookupLocations: initializeResolutionFieldForReadonlyCache(resultFromCache.failedLookupLocations, failedLookupLocations),
44007
43978
  affectingLocations: initializeResolutionFieldForReadonlyCache(resultFromCache.affectingLocations, affectingLocations),
44008
- resolutionDiagnostics: initializeResolutionFieldForReadonlyCache(resultFromCache.resolutionDiagnostics, diagnostics),
44009
- alternateResult: resultFromCache.alternateResult
43979
+ resolutionDiagnostics: initializeResolutionFieldForReadonlyCache(resultFromCache.resolutionDiagnostics, diagnostics)
44010
43980
  };
44011
43981
  }
44012
43982
  }
@@ -44260,14 +44230,16 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
44260
44230
  affectingLocations: initializeResolutionField(affectingLocations),
44261
44231
  resolutionDiagnostics: initializeResolutionField(diagnostics)
44262
44232
  };
44263
- if (containingDirectory) {
44264
- cache == null ? void 0 : cache.setPerDirectoryAndNonRelativeNameCacheResult(
44233
+ if (containingDirectory && cache && !cache.isReadonly) {
44234
+ cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(
44265
44235
  typeReferenceDirectiveName,
44236
+ /*mode*/
44266
44237
  resolutionMode,
44267
- containingDirectory,
44268
- redirectedReference,
44269
44238
  result
44270
44239
  );
44240
+ if (!isExternalModuleNameRelative(typeReferenceDirectiveName)) {
44241
+ cache.getOrCreateCacheForNonRelativeName(typeReferenceDirectiveName, resolutionMode, redirectedReference).set(containingDirectory, result);
44242
+ }
44271
44243
  }
44272
44244
  if (traceEnabled) traceResult(result);
44273
44245
  return result;
@@ -44468,9 +44440,6 @@ function compilerOptionValueToString(value) {
44468
44440
  function getKeyForCompilerOptions(options, affectingOptionDeclarations) {
44469
44441
  return affectingOptionDeclarations.map((option) => compilerOptionValueToString(getCompilerOptionValue(options, option))).join("|") + `|${options.pathsBasePath}`;
44470
44442
  }
44471
- function computeRedirectsCacheKey(options) {
44472
- return getKeyForCompilerOptions(options, moduleResolutionOptionDeclarations);
44473
- }
44474
44443
  function createCacheWithRedirects(ownOptions, optionsToRedirectsKey) {
44475
44444
  const redirectsMap = /* @__PURE__ */ new Map();
44476
44445
  const redirectsKeyToMap = /* @__PURE__ */ new Map();
@@ -44481,11 +44450,7 @@ function createCacheWithRedirects(ownOptions, optionsToRedirectsKey) {
44481
44450
  getOrCreateMapOfCacheRedirects,
44482
44451
  update,
44483
44452
  clear: clear2,
44484
- forEach: forEach2,
44485
- compact: compact2,
44486
- getOwnMap: () => ownMap,
44487
- getOwnOptions: () => ownOptions,
44488
- redirectsKeyToMap
44453
+ getOwnMap: () => ownMap
44489
44454
  };
44490
44455
  function getMapOfCacheRedirects(redirectedReference) {
44491
44456
  return redirectedReference ? getOrCreateMap(
@@ -44543,33 +44508,10 @@ function createCacheWithRedirects(ownOptions, optionsToRedirectsKey) {
44543
44508
  function getRedirectsCacheKey(options) {
44544
44509
  let result = optionsToRedirectsKey.get(options);
44545
44510
  if (!result) {
44546
- optionsToRedirectsKey.set(options, result = computeRedirectsCacheKey(options));
44511
+ optionsToRedirectsKey.set(options, result = getKeyForCompilerOptions(options, moduleResolutionOptionDeclarations));
44547
44512
  }
44548
44513
  return result;
44549
44514
  }
44550
- function forEach2(cb) {
44551
- ownMap.forEach((value, key) => cb(
44552
- value,
44553
- key,
44554
- /*redirectsCacheKey*/
44555
- void 0,
44556
- ownMap
44557
- ));
44558
- redirectsKeyToMap.forEach((map2, redirectsCacheKey) => {
44559
- if (map2 !== ownMap) map2.forEach((value, key) => cb(value, key, redirectsCacheKey, map2));
44560
- });
44561
- }
44562
- function compact2(availableOptions) {
44563
- const toDeleteRedirectsCacheKeys = new Set(redirectsKeyToMap.keys());
44564
- optionsToRedirectsKey.forEach((key, options) => {
44565
- if (options === ownOptions || availableOptions.has(options)) {
44566
- toDeleteRedirectsCacheKeys.delete(key);
44567
- } else {
44568
- redirectsMap.delete(options);
44569
- }
44570
- });
44571
- toDeleteRedirectsCacheKeys.forEach((key) => redirectsKeyToMap.delete(key));
44572
- }
44573
44515
  }
44574
44516
  function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
44575
44517
  let cache;
@@ -44596,7 +44538,7 @@ function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create)
44596
44538
  }
44597
44539
  return result;
44598
44540
  }
44599
- function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options, optionsToRedirectsKey, getValidResolution) {
44541
+ function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, options, optionsToRedirectsKey) {
44600
44542
  const directoryToModuleNameMap = createCacheWithRedirects(options, optionsToRedirectsKey);
44601
44543
  return {
44602
44544
  getFromDirectoryCache,
@@ -44618,7 +44560,7 @@ function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileNam
44618
44560
  function getFromDirectoryCache(name, mode, directoryName, redirectedReference) {
44619
44561
  var _a, _b;
44620
44562
  const path = toPath(directoryName, currentDirectory, getCanonicalFileName);
44621
- return getValidResolution((_b = (_a = directoryToModuleNameMap.getMapOfCacheRedirects(redirectedReference)) == null ? void 0 : _a.get(path)) == null ? void 0 : _b.get(name, mode));
44563
+ return (_b = (_a = directoryToModuleNameMap.getMapOfCacheRedirects(redirectedReference)) == null ? void 0 : _a.get(path)) == null ? void 0 : _b.get(name, mode);
44622
44564
  }
44623
44565
  }
44624
44566
  function createModeAwareCacheKey(specifier, mode) {
@@ -44645,7 +44587,7 @@ function createModeAwareCache() {
44645
44587
  forEach(cb) {
44646
44588
  return underlying.forEach((elem, key) => {
44647
44589
  const [specifier, mode] = memoizedReverseKeys.get(key);
44648
- return cb(elem, specifier, mode, key);
44590
+ return cb(elem, specifier, mode);
44649
44591
  });
44650
44592
  },
44651
44593
  size() {
@@ -44660,20 +44602,18 @@ function createModeAwareCache() {
44660
44602
  }
44661
44603
  }
44662
44604
  function getOriginalOrResolvedModuleFileName(result) {
44663
- const resolvedModule = !result.globalCacheResolution ? result.resolvedModule : result.globalCacheResolution.primary.resolvedModule;
44664
- return resolvedModule && (resolvedModule.originalPath || resolvedModule.resolvedFileName);
44605
+ return result.resolvedModule && (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
44665
44606
  }
44666
44607
  function getOriginalOrResolvedTypeReferenceFileName(result) {
44667
44608
  return result.resolvedTypeReferenceDirective && (result.resolvedTypeReferenceDirective.originalPath || result.resolvedTypeReferenceDirective.resolvedFileName);
44668
44609
  }
44669
- function createNonRelativeNameResolutionCache(currentDirectory, getCanonicalFileName, options, getResolvedFileName, optionsToRedirectsKey, getValidResolution) {
44610
+ function createNonRelativeNameResolutionCache(currentDirectory, getCanonicalFileName, options, getResolvedFileName, optionsToRedirectsKey) {
44670
44611
  const moduleNameToDirectoryMap = createCacheWithRedirects(options, optionsToRedirectsKey);
44671
44612
  return {
44672
44613
  getFromNonRelativeNameCache,
44673
44614
  getOrCreateCacheForNonRelativeName,
44674
44615
  clear: clear2,
44675
- update,
44676
- moduleNameToDirectoryMap
44616
+ update
44677
44617
  };
44678
44618
  function clear2() {
44679
44619
  moduleNameToDirectoryMap.clear();
@@ -44684,79 +44624,38 @@ function createNonRelativeNameResolutionCache(currentDirectory, getCanonicalFile
44684
44624
  function getFromNonRelativeNameCache(nonRelativeModuleName, mode, directoryName, redirectedReference) {
44685
44625
  var _a, _b;
44686
44626
  Debug.assert(!isExternalModuleNameRelative(nonRelativeModuleName));
44687
- return (_b = (_a = moduleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) == null ? void 0 : _a.get(
44688
- createModeAwareCacheKey(nonRelativeModuleName, mode)
44689
- )) == null ? void 0 : _b.get(directoryName);
44627
+ return (_b = (_a = moduleNameToDirectoryMap.getMapOfCacheRedirects(redirectedReference)) == null ? void 0 : _a.get(createModeAwareCacheKey(nonRelativeModuleName, mode))) == null ? void 0 : _b.get(directoryName);
44690
44628
  }
44691
44629
  function getOrCreateCacheForNonRelativeName(nonRelativeModuleName, mode, redirectedReference) {
44692
44630
  Debug.assert(!isExternalModuleNameRelative(nonRelativeModuleName));
44693
- return getOrCreateCache(
44694
- moduleNameToDirectoryMap,
44695
- redirectedReference,
44696
- createModeAwareCacheKey(nonRelativeModuleName, mode),
44697
- createPerModuleNameCache
44698
- );
44631
+ return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, createModeAwareCacheKey(nonRelativeModuleName, mode), createPerModuleNameCache);
44699
44632
  }
44700
44633
  function createPerModuleNameCache() {
44701
44634
  const directoryPathMap = /* @__PURE__ */ new Map();
44702
- return { get, set, deleteByPath, directoryPathMap };
44635
+ return { get, set };
44703
44636
  function get(directory) {
44704
- return getByPath(toPath(directory, currentDirectory, getCanonicalFileName));
44705
- }
44706
- function getByPath(directoryPath, primary, forSet) {
44707
- const result = getValidResolution(directoryPathMap.get(directoryPath), forSet);
44708
- return !result || result === primary ? void 0 : result;
44637
+ return directoryPathMap.get(toPath(directory, currentDirectory, getCanonicalFileName));
44709
44638
  }
44710
- function deleteByPath(directory) {
44711
- const existing = directoryPathMap.get(directory);
44712
- if (existing) {
44713
- directoryPathMap.delete(directory);
44714
- withCommonPrefix(
44715
- directory,
44716
- getCommonPrefix(directory, existing),
44717
- (parent2) => directoryPathMap.delete(parent2)
44718
- );
44719
- }
44720
- }
44721
- function set(directory, result, primary) {
44639
+ function set(directory, result) {
44722
44640
  const path = toPath(directory, currentDirectory, getCanonicalFileName);
44723
- if (getByPath(
44724
- path,
44725
- primary,
44726
- /*forSet*/
44727
- true
44728
- )) {
44641
+ if (directoryPathMap.has(path)) {
44729
44642
  return;
44730
44643
  }
44731
- if (!primary) deleteByPath(path);
44732
44644
  directoryPathMap.set(path, result);
44733
- withCommonPrefix(
44734
- path,
44735
- getCommonPrefix(path, result),
44736
- (parent2) => directoryPathMap.set(parent2, result),
44737
- primary
44738
- );
44739
- }
44740
- function withCommonPrefix(path, commonPrefix, action, primary) {
44645
+ const resolvedFileName = getResolvedFileName(result);
44646
+ const commonPrefix = resolvedFileName && getCommonPrefix(path, resolvedFileName);
44741
44647
  let current = path;
44742
44648
  while (current !== commonPrefix) {
44743
44649
  const parent2 = getDirectoryPath(current);
44744
- if (parent2 === current || getByPath(
44745
- parent2,
44746
- primary,
44747
- /*forSet*/
44748
- true
44749
- )) {
44650
+ if (parent2 === current || directoryPathMap.has(parent2)) {
44750
44651
  break;
44751
44652
  }
44752
- action(parent2);
44653
+ directoryPathMap.set(parent2, result);
44753
44654
  current = parent2;
44754
44655
  }
44755
44656
  }
44756
44657
  function getCommonPrefix(directory, resolution) {
44757
- const resolvedFileName = getResolvedFileName(resolution);
44758
- if (!resolvedFileName) return void 0;
44759
- const resolutionDirectory = toPath(getDirectoryPath(resolvedFileName), currentDirectory, getCanonicalFileName);
44658
+ const resolutionDirectory = toPath(getDirectoryPath(resolution), currentDirectory, getCanonicalFileName);
44760
44659
  let i = 0;
44761
44660
  const limit = Math.min(directory.length, resolutionDirectory.length);
44762
44661
  while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
@@ -44777,130 +44676,69 @@ function createNonRelativeNameResolutionCache(currentDirectory, getCanonicalFile
44777
44676
  }
44778
44677
  }
44779
44678
  }
44780
- function createModuleOrTypeReferenceResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, getResolvedFileName, optionsToRedirectsKey, getValidResolution) {
44679
+ function createModuleOrTypeReferenceResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, getResolvedFileName, optionsToRedirectsKey) {
44781
44680
  optionsToRedirectsKey ?? (optionsToRedirectsKey = /* @__PURE__ */ new Map());
44782
- getValidResolution ?? (getValidResolution = identity);
44783
44681
  const perDirectoryResolutionCache = createPerDirectoryResolutionCache(
44784
44682
  currentDirectory,
44785
44683
  getCanonicalFileName,
44786
44684
  options,
44787
- optionsToRedirectsKey,
44788
- getValidResolution
44685
+ optionsToRedirectsKey
44789
44686
  );
44790
44687
  const nonRelativeNameResolutionCache = createNonRelativeNameResolutionCache(
44791
44688
  currentDirectory,
44792
44689
  getCanonicalFileName,
44793
44690
  options,
44794
44691
  getResolvedFileName,
44795
- optionsToRedirectsKey,
44796
- getValidResolution
44692
+ optionsToRedirectsKey
44797
44693
  );
44798
44694
  packageJsonInfoCache ?? (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
44799
- const cache = {
44695
+ return {
44800
44696
  ...packageJsonInfoCache,
44801
44697
  ...perDirectoryResolutionCache,
44802
44698
  ...nonRelativeNameResolutionCache,
44803
44699
  clear: clear2,
44804
44700
  update,
44805
- gc,
44806
- compact: compact2,
44807
- setPerDirectoryAndNonRelativeNameCacheResult,
44808
- options: () => options,
44809
44701
  getPackageJsonInfoCache: () => packageJsonInfoCache,
44810
- optionsToRedirectsKey,
44811
- print
44702
+ clearAllExceptPackageJsonInfoCache,
44703
+ optionsToRedirectsKey
44812
44704
  };
44813
- return cache;
44814
44705
  function clear2() {
44815
- perDirectoryResolutionCache.clear();
44816
- nonRelativeNameResolutionCache.clear();
44706
+ clearAllExceptPackageJsonInfoCache();
44817
44707
  packageJsonInfoCache.clear();
44818
44708
  }
44819
- function update(updatedOptions) {
44820
- options = updatedOptions;
44821
- perDirectoryResolutionCache.update(updatedOptions);
44822
- nonRelativeNameResolutionCache.update(updatedOptions);
44823
- }
44824
- function gc(setOrMapToCheckPresence) {
44825
- perDirectoryResolutionCache.directoryToModuleNameMap.forEach((resolutions, dir, redirectsCacheKey, directoryToModuleNameMap) => {
44826
- resolutions.forEach((resolution, name, mode, key) => {
44827
- if (setOrMapToCheckPresence.has(resolution)) return;
44828
- resolutions.delete(name, mode);
44829
- if (!isExternalModuleNameRelative(name)) {
44830
- const moduleNameToDirectoryMap = !redirectsCacheKey ? nonRelativeNameResolutionCache.moduleNameToDirectoryMap.getOwnMap() : nonRelativeNameResolutionCache.moduleNameToDirectoryMap.redirectsKeyToMap.get(redirectsCacheKey);
44831
- const directoryMap = moduleNameToDirectoryMap == null ? void 0 : moduleNameToDirectoryMap.get(key);
44832
- directoryMap == null ? void 0 : directoryMap.deleteByPath(dir);
44833
- if (!(directoryMap == null ? void 0 : directoryMap.directoryPathMap.size)) moduleNameToDirectoryMap.delete(key);
44834
- }
44835
- });
44836
- if (!resolutions.size()) directoryToModuleNameMap.delete(dir);
44837
- });
44838
- }
44839
- function compact2(availableOptions = new Set(optionsToRedirectsKey.keys()), skipOptionsToRedirectsKeyCleanup) {
44840
- perDirectoryResolutionCache.directoryToModuleNameMap.compact(availableOptions);
44841
- nonRelativeNameResolutionCache.moduleNameToDirectoryMap.compact(availableOptions);
44842
- if (!skipOptionsToRedirectsKeyCleanup) {
44843
- optionsToRedirectsKey.forEach(
44844
- (_redirectsKey, options2) => {
44845
- if (!availableOptions.has(options2)) optionsToRedirectsKey.delete(options2);
44846
- }
44847
- );
44848
- }
44849
- }
44850
- function setPerDirectoryAndNonRelativeNameCacheResult(name, mode, directoryName, redirectedReference, result, primary) {
44851
- if (cache.isReadonly) return;
44852
- cache.getOrCreateCacheForDirectory(directoryName, redirectedReference).set(name, mode, result);
44853
- if (!isExternalModuleNameRelative(name)) {
44854
- cache.getOrCreateCacheForNonRelativeName(name, mode, redirectedReference).set(directoryName, result, primary);
44855
- }
44709
+ function clearAllExceptPackageJsonInfoCache() {
44710
+ perDirectoryResolutionCache.clear();
44711
+ nonRelativeNameResolutionCache.clear();
44856
44712
  }
44857
- function print() {
44858
- console.log(`directoryToModuleNameMap::`);
44859
- perDirectoryResolutionCache.directoryToModuleNameMap.forEach((moduleNameMap, directoryPath, redirectsCacheKey) => {
44860
- if (!redirectsCacheKey) console.log(" OwnMap");
44861
- else console.log(` redirectsCacheKey:: ${redirectsCacheKey}`);
44862
- console.log(` directoryPath:: ${directoryPath}`);
44863
- moduleNameMap.forEach((value, key, mode) => {
44864
- console.log(` ${key} ${mode} ${JSON.stringify(value, void 0, " ")}`);
44865
- });
44866
- });
44867
- console.log(`moduleNameToDirectoryMap::`);
44868
- nonRelativeNameResolutionCache.moduleNameToDirectoryMap.forEach((perNonRelativeNameCache, key, redirectsCacheKey) => {
44869
- if (!redirectsCacheKey) console.log(" OwnMap");
44870
- else console.log(` redirectsCacheKey:: ${redirectsCacheKey}`);
44871
- console.log(` modeAwareCacheKey:: ${key}`);
44872
- perNonRelativeNameCache.directoryPathMap.forEach((value, key2) => {
44873
- console.log(` ${key2} ${JSON.stringify(value, void 0, " ")}`);
44874
- });
44875
- });
44713
+ function update(options2) {
44714
+ perDirectoryResolutionCache.update(options2);
44715
+ nonRelativeNameResolutionCache.update(options2);
44876
44716
  }
44877
44717
  }
44878
- function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, optionsToRedirectsKey, getValidResolution) {
44718
+ function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, optionsToRedirectsKey) {
44879
44719
  const result = createModuleOrTypeReferenceResolutionCache(
44880
44720
  currentDirectory,
44881
44721
  getCanonicalFileName,
44882
44722
  options,
44883
44723
  packageJsonInfoCache,
44884
44724
  getOriginalOrResolvedModuleFileName,
44885
- optionsToRedirectsKey,
44886
- getValidResolution
44725
+ optionsToRedirectsKey
44887
44726
  );
44888
44727
  result.getOrCreateCacheForModuleName = (nonRelativeName, mode, redirectedReference) => result.getOrCreateCacheForNonRelativeName(nonRelativeName, mode, redirectedReference);
44889
44728
  return result;
44890
44729
  }
44891
- function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, optionsToRedirectsKey, getValidResolution) {
44730
+ function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, optionsToRedirectsKey) {
44892
44731
  return createModuleOrTypeReferenceResolutionCache(
44893
44732
  currentDirectory,
44894
44733
  getCanonicalFileName,
44895
44734
  options,
44896
44735
  packageJsonInfoCache,
44897
44736
  getOriginalOrResolvedTypeReferenceFileName,
44898
- optionsToRedirectsKey,
44899
- getValidResolution
44737
+ optionsToRedirectsKey
44900
44738
  );
44901
44739
  }
44902
44740
  function getOptionsForLibraryResolution(options) {
44903
- return { moduleResolution: 2 /* Node10 */, traceResolution: options == null ? void 0 : options.traceResolution };
44741
+ return { moduleResolution: 2 /* Node10 */, traceResolution: options.traceResolution };
44904
44742
  }
44905
44743
  function resolveLibrary(libraryName, resolveFrom, compilerOptions, host, cache) {
44906
44744
  return resolveModuleName(libraryName, resolveFrom, getOptionsForLibraryResolution(compilerOptions), host, cache);
@@ -44963,13 +44801,12 @@ function resolveModuleName(moduleName, containingFile, compilerOptions, host, ca
44963
44801
  default:
44964
44802
  return Debug.fail(`Unexpected moduleResolution: ${moduleResolution}`);
44965
44803
  }
44966
- cache == null ? void 0 : cache.setPerDirectoryAndNonRelativeNameCacheResult(
44967
- moduleName,
44968
- resolutionMode,
44969
- containingDirectory,
44970
- redirectedReference,
44971
- result
44972
- );
44804
+ if (cache && !cache.isReadonly) {
44805
+ cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference).set(moduleName, resolutionMode, result);
44806
+ if (!isExternalModuleNameRelative(moduleName)) {
44807
+ cache.getOrCreateCacheForNonRelativeName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result);
44808
+ }
44809
+ }
44973
44810
  }
44974
44811
  if (traceEnabled) {
44975
44812
  if (result.resolvedModule) {
@@ -45261,7 +45098,7 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
45261
45098
  result = tryResolve(extensions, state);
45262
45099
  }
45263
45100
  let alternateResult;
45264
- if (!state.resultFromCache && state.resolvedPackageDirectory && !isConfigLookup && !isExternalModuleNameRelative(moduleName)) {
45101
+ if (state.resolvedPackageDirectory && !isConfigLookup && !isExternalModuleNameRelative(moduleName)) {
45265
45102
  const wantedTypesButGotJs = (result == null ? void 0 : result.value) && extensions & (1 /* TypeScript */ | 4 /* Declaration */) && !extensionIsOk(1 /* TypeScript */ | 4 /* Declaration */, result.value.resolved.extension);
45266
45103
  if (((_a = result == null ? void 0 : result.value) == null ? void 0 : _a.isExternalLibraryImport) && wantedTypesButGotJs && features & 8 /* Exports */ && (conditions == null ? void 0 : conditions.includes("import"))) {
45267
45104
  traceIfEnabled(state, Diagnostics.Resolution_of_non_relative_name_failed_trying_with_modern_Node_resolution_features_disabled_to_see_if_npm_library_needs_configuration_update);
@@ -45541,14 +45378,12 @@ function loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures,
45541
45378
  return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo), state);
45542
45379
  }
45543
45380
  function getEntrypointsFromPackageJsonInfo(packageJsonInfo, options, host, cache, resolveJs) {
45544
- var _a, _b;
45545
- const features = getNodeResolutionFeatures(options);
45546
- const cachedValue = !resolveJs ? (_a = packageJsonInfo.contents.resolvedEntrypoints) == null ? void 0 : _a.get(features) : void 0;
45547
- if (cachedValue !== void 0) {
45548
- return cachedValue || void 0;
45381
+ if (!resolveJs && packageJsonInfo.contents.resolvedEntrypoints !== void 0) {
45382
+ return packageJsonInfo.contents.resolvedEntrypoints;
45549
45383
  }
45550
45384
  let entrypoints;
45551
45385
  const extensions = 1 /* TypeScript */ | 4 /* Declaration */ | (resolveJs ? 2 /* JavaScript */ : 0);
45386
+ const features = getNodeResolutionFeatures(options);
45552
45387
  const loadPackageJsonMainState = getTemporaryModuleResolutionState(cache == null ? void 0 : cache.getPackageJsonInfoCache(), host, options);
45553
45388
  loadPackageJsonMainState.conditions = getConditions(options);
45554
45389
  loadPackageJsonMainState.requestContainingDirectory = packageJsonInfo.packageDirectory;
@@ -45581,8 +45416,7 @@ function getEntrypointsFromPackageJsonInfo(packageJsonInfo, options, host, cache
45581
45416
  }
45582
45417
  }
45583
45418
  }
45584
- ((_b = packageJsonInfo.contents).resolvedEntrypoints ?? (_b.resolvedEntrypoints = /* @__PURE__ */ new Map())).set(features, entrypoints || false);
45585
- return entrypoints;
45419
+ return packageJsonInfo.contents.resolvedEntrypoints = entrypoints || false;
45586
45420
  }
45587
45421
  function loadEntrypointsFromExportMap(scope, exports2, state, extensions) {
45588
45422
  let entrypoints;
@@ -126506,10 +126340,6 @@ function loadWithModeAwareCache(entries, containingFile, redirectedReference, op
126506
126340
  return resolutions;
126507
126341
  }
126508
126342
  var inferredTypesContainingFile = "__inferred type names__.ts";
126509
- function getAutomaticTypeDirectiveContainingFile(options, currentDirectory) {
126510
- const containingDirectory = options.configFilePath ? getDirectoryPath(options.configFilePath) : currentDirectory;
126511
- return combinePaths(containingDirectory, inferredTypesContainingFile);
126512
- }
126513
126343
  function getInferredLibraryNameResolveFrom(options, currentDirectory, libFileName) {
126514
126344
  const containingDirectory = options.configFilePath ? getDirectoryPath(options.configFilePath) : currentDirectory;
126515
126345
  return combinePaths(containingDirectory, `__lib_node_modules_lookup_${libFileName}__.ts`);
@@ -126742,7 +126572,7 @@ function createCreateProgramOptions(rootNames, options, host, oldProgram, config
126742
126572
  };
126743
126573
  }
126744
126574
  function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
126745
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
126575
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
126746
126576
  let _createProgramOptions = isArray(_rootNamesOrOptions) ? createCreateProgramOptions(_rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : _rootNamesOrOptions;
126747
126577
  const { rootNames, options, configFileParsingDiagnostics, projectReferences, typeScriptVersion: typeScriptVersion3, host: createProgramOptionsHost } = _createProgramOptions;
126748
126578
  let { oldProgram } = _createProgramOptions;
@@ -126883,6 +126713,7 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
126883
126713
  let projectReferenceRedirects;
126884
126714
  let mapFromFileToProjectReferenceRedirects;
126885
126715
  let mapFromToProjectReferenceRedirectSource;
126716
+ let hasResolvedReferencencesInNodeModules = false;
126886
126717
  const useSourceOfProjectReferenceRedirect = !!((_d = host.useSourceOfProjectReferenceRedirect) == null ? void 0 : _d.call(host)) && !options.disableSourceOfProjectReferenceRedirect;
126887
126718
  const { onProgramCreateComplete, fileExists, directoryExists } = updateHostForUseSourceOfProjectReferenceRedirect({
126888
126719
  compilerHost: host,
@@ -126947,10 +126778,9 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
126947
126778
  automaticTypeDirectiveResolutions = createModeAwareCache();
126948
126779
  if (automaticTypeDirectiveNames.length) {
126949
126780
  (_k = tracing) == null ? void 0 : _k.push(tracing.Phase.Program, "processTypeReferences", { count: automaticTypeDirectiveNames.length });
126950
- const resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(
126951
- automaticTypeDirectiveNames,
126952
- getAutomaticTypeDirectiveContainingFile(options, currentDirectory)
126953
- );
126781
+ const containingDirectory = options.configFilePath ? getDirectoryPath(options.configFilePath) : currentDirectory;
126782
+ const containingFilename = combinePaths(containingDirectory, inferredTypesContainingFile);
126783
+ const resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(automaticTypeDirectiveNames, containingFilename);
126954
126784
  for (let i = 0; i < automaticTypeDirectiveNames.length; i++) {
126955
126785
  automaticTypeDirectiveResolutions.set(
126956
126786
  automaticTypeDirectiveNames[i],
@@ -126971,17 +126801,6 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
126971
126801
  );
126972
126802
  }
126973
126803
  (_n = tracing) == null ? void 0 : _n.pop();
126974
- } else {
126975
- (_o = host.onReusedTypeReferenceDirectiveResolutions) == null ? void 0 : _o.call(
126976
- host,
126977
- /*reusedNames*/
126978
- void 0,
126979
- /*containingSourceFile*/
126980
- void 0,
126981
- /*redirectedReference*/
126982
- void 0,
126983
- options
126984
- );
126985
126804
  }
126986
126805
  if (rootNames.length && !skipDefaultLib) {
126987
126806
  const defaultLibraryFileName = getDefaultLibraryFileName();
@@ -127117,7 +126936,6 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
127117
126936
  getResolvedProjectReferenceByPath,
127118
126937
  forEachResolvedProjectReference: forEachResolvedProjectReference2,
127119
126938
  isSourceOfProjectReferenceRedirect,
127120
- getRedirectReferenceForResolution,
127121
126939
  getRedirectReferenceForResolutionFromSourceOfProject,
127122
126940
  getCompilerOptionsForFile,
127123
126941
  getDefaultResolutionModeForFile: getDefaultResolutionModeForFile2,
@@ -127129,7 +126947,7 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
127129
126947
  readFile,
127130
126948
  directoryExists,
127131
126949
  getSymlinkCache,
127132
- realpath: (_p = host.realpath) == null ? void 0 : _p.bind(host),
126950
+ realpath: (_o = host.realpath) == null ? void 0 : _o.bind(host),
127133
126951
  useCaseSensitiveFileNames: () => host.useCaseSensitiveFileNames(),
127134
126952
  getCanonicalFileName,
127135
126953
  getFileIncludeReasons: () => programDiagnostics.getFileReasons(),
@@ -127143,7 +126961,7 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
127143
126961
  }
127144
126962
  mark("afterProgram");
127145
126963
  measure("Program", "beforeProgram", "afterProgram");
127146
- (_q = tracing) == null ? void 0 : _q.pop();
126964
+ (_p = tracing) == null ? void 0 : _p.pop();
127147
126965
  return program;
127148
126966
  function getResolvedModule(file, moduleName, mode) {
127149
126967
  var _a2;
@@ -127321,7 +127139,6 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
127321
127139
  redirectedReference: getRedirectReferenceForResolution(containingFile),
127322
127140
  nameAndModeGetter: moduleResolutionNameAndModeGetter,
127323
127141
  resolutionWorker: resolveModuleNamesWorker,
127324
- onReusedResolutions: maybeBind(host, host.onReusedModuleResolutions),
127325
127142
  getResolutionFromOldProgram: (name, mode) => oldProgram == null ? void 0 : oldProgram.getResolvedModule(containingFile, name, mode),
127326
127143
  getResolved: getResolvedModuleFromResolution,
127327
127144
  canReuseResolutionsInFile: () => containingFile === (oldProgram == null ? void 0 : oldProgram.getSourceFile(containingFile.fileName)) && !hasInvalidatedResolutions(containingFile.path),
@@ -127337,7 +127154,6 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
127337
127154
  redirectedReference: containingSourceFile && getRedirectReferenceForResolution(containingSourceFile),
127338
127155
  nameAndModeGetter: typeReferenceResolutionNameAndModeGetter,
127339
127156
  resolutionWorker: resolveTypeReferenceDirectiveNamesWorker,
127340
- onReusedResolutions: maybeBind(host, host.onReusedTypeReferenceDirectiveResolutions),
127341
127157
  getResolutionFromOldProgram: (name, mode) => {
127342
127158
  var _a2;
127343
127159
  return containingSourceFile ? oldProgram == null ? void 0 : oldProgram.getResolvedTypeReferenceDirective(containingSourceFile, name, mode) : (_a2 = oldProgram == null ? void 0 : oldProgram.getAutomaticTypeDirectiveResolutions()) == null ? void 0 : _a2.get(name, mode);
@@ -127353,21 +127169,12 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
127353
127169
  redirectedReference,
127354
127170
  nameAndModeGetter,
127355
127171
  resolutionWorker,
127356
- onReusedResolutions,
127357
127172
  getResolutionFromOldProgram,
127358
127173
  getResolved,
127359
127174
  canReuseResolutionsInFile,
127360
127175
  resolveToOwnAmbientModule
127361
127176
  }) {
127362
- if (!entries.length) {
127363
- onReusedResolutions == null ? void 0 : onReusedResolutions(
127364
- entries,
127365
- containingSourceFile,
127366
- redirectedReference,
127367
- options
127368
- );
127369
- return emptyArray;
127370
- }
127177
+ if (!entries.length) return emptyArray;
127371
127178
  if (structureIsReused === 0 /* Not */ && (!resolveToOwnAmbientModule || !containingSourceFile.ambientModuleNames.length)) {
127372
127179
  return resolutionWorker(
127373
127180
  entries,
@@ -127422,20 +127229,8 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
127422
127229
  (unknownEntries ?? (unknownEntries = [])).push(entry);
127423
127230
  (unknownEntryIndices ?? (unknownEntryIndices = [])).push(i);
127424
127231
  }
127425
- if (!unknownEntries) {
127426
- onReusedResolutions == null ? void 0 : onReusedResolutions(
127427
- reusedNames,
127428
- containingSourceFile,
127429
- redirectedReference,
127430
- options
127431
- );
127432
- return result;
127433
- }
127434
- const resolutions = resolutionWorker(
127435
- unknownEntries,
127436
- containingFile,
127437
- reusedNames
127438
- );
127232
+ if (!unknownEntries) return result;
127233
+ const resolutions = resolutionWorker(unknownEntries, containingFile, reusedNames);
127439
127234
  if (!result) return resolutions;
127440
127235
  resolutions.forEach((resolution, index) => result[unknownEntryIndices[index]] = resolution);
127441
127236
  return result;
@@ -128462,7 +128257,7 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
128462
128257
  return typeof result === "object" ? { ...result, languageVersion, setExternalModuleIndicator: setExternalModuleIndicator2, jsDocParsingMode: host2.jsDocParsingMode } : { languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator2, jsDocParsingMode: host2.jsDocParsingMode };
128463
128258
  }
128464
128259
  function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
128465
- var _a2, _b2;
128260
+ var _a2;
128466
128261
  const path = toPath3(fileName);
128467
128262
  if (useSourceOfProjectReferenceRedirect) {
128468
128263
  let source = getSourceOfProjectReferenceRedirect(path);
@@ -128607,8 +128402,6 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
128607
128402
  processingOtherFiles.push(file);
128608
128403
  }
128609
128404
  (filesWithReferencesProcessed ?? (filesWithReferencesProcessed = /* @__PURE__ */ new Set())).add(file.path);
128610
- } else {
128611
- (_b2 = host.onSourceFileNotCreated) == null ? void 0 : _b2.call(host, sourceFileOptions);
128612
128405
  }
128613
128406
  return file;
128614
128407
  }
@@ -128663,6 +128456,7 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
128663
128456
  }
128664
128457
  function getSourceOfProjectReferenceRedirect(path) {
128665
128458
  if (!isDeclarationFileName(path)) return void 0;
128459
+ if (!hasResolvedReferencencesInNodeModules && pathContainsNodeModules(path)) return void 0;
128666
128460
  if (mapFromToProjectReferenceRedirectSource === void 0) {
128667
128461
  mapFromToProjectReferenceRedirectSource = /* @__PURE__ */ new Map();
128668
128462
  forEachResolvedProjectReference2((resolvedRef) => {
@@ -128706,19 +128500,8 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
128706
128500
  });
128707
128501
  }
128708
128502
  function processTypeReferenceDirectives(file) {
128709
- var _a2;
128710
128503
  const typeDirectives = file.typeReferenceDirectives;
128711
- if (!typeDirectives.length) {
128712
- (_a2 = host.onReusedTypeReferenceDirectiveResolutions) == null ? void 0 : _a2.call(
128713
- host,
128714
- /*reusedNames*/
128715
- void 0,
128716
- file,
128717
- getRedirectReferenceForResolution(file),
128718
- options
128719
- );
128720
- return;
128721
- }
128504
+ if (!typeDirectives.length) return;
128722
128505
  const resolutions = (resolvedTypeReferenceDirectiveNamesProcessing == null ? void 0 : resolvedTypeReferenceDirectiveNamesProcessing.get(file.path)) || resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectives, file);
128723
128506
  const resolutionsInFile = createModeAwareCache();
128724
128507
  (resolvedTypeReferenceDirectiveNames ?? (resolvedTypeReferenceDirectiveNames = /* @__PURE__ */ new Map())).set(file.path, resolutionsInFile);
@@ -128845,7 +128628,6 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
128845
128628
  return host.getCanonicalFileName(fileName);
128846
128629
  }
128847
128630
  function processImportedModules(file) {
128848
- var _a2;
128849
128631
  collectExternalModuleReferences(file);
128850
128632
  if (file.imports.length || file.moduleAugmentations.length) {
128851
128633
  const moduleNames = getModuleNames(file);
@@ -128889,15 +128671,6 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
128889
128671
  currentNodeModulesDepth--;
128890
128672
  }
128891
128673
  }
128892
- } else {
128893
- (_a2 = host.onReusedModuleResolutions) == null ? void 0 : _a2.call(
128894
- host,
128895
- /*reusedNames*/
128896
- void 0,
128897
- file,
128898
- getRedirectReferenceForResolution(file),
128899
- options
128900
- );
128901
128674
  }
128902
128675
  }
128903
128676
  function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) {
@@ -128981,6 +128754,9 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
128981
128754
  sourceFile.path = sourceFilePath;
128982
128755
  sourceFile.resolvedPath = sourceFilePath;
128983
128756
  sourceFile.originalFileName = refPath;
128757
+ if (!hasResolvedReferencencesInNodeModules && (pathContainsNodeModules(sourceFile.resolvedPath) || pathContainsNodeModules(sourceFile.path))) {
128758
+ hasResolvedReferencencesInNodeModules = true;
128759
+ }
128984
128760
  const resolvedRef = { commandLine, sourceFile };
128985
128761
  projectReferenceRedirects.set(sourceFilePath, resolvedRef);
128986
128762
  if (commandLine.projectReferences) {
@@ -132125,7 +131901,7 @@ function createAbstractBuilder(newProgramOrRootNames, hostOrOptions, oldProgramO
132125
131901
  );
132126
131902
  }
132127
131903
 
132128
- // src/compiler/sharedResolutionCache.ts
131904
+ // src/compiler/resolutionCache.ts
132129
131905
  function removeIgnoredPath(path) {
132130
131906
  if (endsWith(path, "/node_modules/.staging")) {
132131
131907
  return removeSuffix(path, "/.staging");
@@ -132256,930 +132032,24 @@ function getDirectoryOfFailedLookupWatch(dirComponents, dirPathComponents, lengt
132256
132032
  packageDirPath: packageDirLength !== void 0 ? getPathFromPathComponents(dirPathComponents, packageDirLength) : void 0
132257
132033
  };
132258
132034
  }
132259
- function getModuleOrTypeRefResolved(resolution) {
132260
- return resolution.resolvedModule ?? resolution.resolvedTypeReferenceDirective;
132261
- }
132262
- function createSharedResolutionCache(sharedCacheHost) {
132263
- const resolutionsWithFailedLookups = /* @__PURE__ */ new Set();
132264
- const resolutionsWithOnlyAffectingLocations = /* @__PURE__ */ new Set();
132265
- const resolvedFileToResolution = /* @__PURE__ */ new Map();
132266
- const impliedFormatPackageJsons = /* @__PURE__ */ new Map();
132267
- const watchedResolutionInfoMap = /* @__PURE__ */ new Map();
132268
- const typeRootsWatches = /* @__PURE__ */ new Map();
132269
- const inUseResolutionCaches = /* @__PURE__ */ new Map();
132270
- const cacheToOptions = /* @__PURE__ */ new Map();
132271
- let affectingPathChecks;
132272
- let failedLookupChecks;
132273
- let startsWithPathChecks;
132274
- let isInDirectoryChecks;
132275
- let cachesNeedingGc;
132276
- let potentiallyUnreferencedDirWatchers;
132277
- let considerNonWatchedResolutionAsInvalidated = false;
132278
- const getCurrentDirectory = memoize(() => sharedCacheHost.getCurrentDirectory());
132279
- const moduleResolutionCache = createModuleResolutionCache(
132280
- getCurrentDirectory(),
132281
- sharedCacheHost.getCanonicalFileName,
132282
- /*options*/
132283
- void 0,
132284
- /*packageJsonInfoCache*/
132285
- void 0,
132286
- /*optionsToRedirectsKey*/
132287
- void 0,
132288
- getValidModuleResolution
132289
- );
132290
- const typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(
132291
- getCurrentDirectory(),
132292
- sharedCacheHost.getCanonicalFileName,
132293
- /*options*/
132294
- void 0,
132295
- moduleResolutionCache.getPackageJsonInfoCache(),
132296
- moduleResolutionCache.optionsToRedirectsKey,
132297
- getValidResolution
132298
- );
132299
- const libraryResolutionCache = createModuleResolutionCache(
132300
- getCurrentDirectory(),
132301
- sharedCacheHost.getCanonicalFileName,
132302
- getOptionsForLibraryResolution(
132303
- /*options*/
132304
- void 0
132305
- ),
132306
- moduleResolutionCache.getPackageJsonInfoCache(),
132307
- /*optionsToRedirectsKey*/
132308
- void 0,
132309
- getValidResolution
132310
- );
132311
- const packageJsonRefCount = /* @__PURE__ */ new Map();
132312
- let potentiallyUnwatchedPackageJsons;
132313
- const directoryWatchesOfFailedLookups = /* @__PURE__ */ new Map();
132314
- const nonRecursiveDirectoryWatchesOfFailedLookups = /* @__PURE__ */ new Map();
132315
- const fileWatchesOfAffectingLocations = /* @__PURE__ */ new Map();
132316
- const isSymlinkCache = /* @__PURE__ */ new Map();
132317
- const packageDirWatchers = /* @__PURE__ */ new Map();
132318
- const dirPathToSymlinkPackageRefCount = /* @__PURE__ */ new Map();
132319
- let currentCache;
132320
- return {
132321
- sharedCacheHost,
132322
- moduleResolutionCache,
132323
- typeReferenceDirectiveResolutionCache,
132324
- libraryResolutionCache,
132325
- resolvedFileToResolution,
132326
- resolutionsWithFailedLookups,
132327
- resolutionsWithOnlyAffectingLocations,
132328
- packageJsonRefCount,
132329
- watchedResolutionInfoMap,
132330
- typeRootsWatches,
132331
- inUseResolutionCaches,
132332
- cacheToOptions,
132333
- directoryWatchesOfFailedLookups,
132334
- nonRecursiveDirectoryWatchesOfFailedLookups,
132335
- fileWatchesOfAffectingLocations,
132336
- packageDirWatchers,
132337
- dirPathToSymlinkPackageRefCount,
132338
- clear: clear2,
132339
- startCachingPerDirectoryResolution,
132340
- finishCachingPerDirectoryResolution,
132341
- compactCaches,
132342
- watchResolution,
132343
- releaseResolution,
132344
- createFileWatcherOfAffectingLocation,
132345
- releaseFileWatcherOfAffectingLocation,
132346
- closeFileWatcherOfAffectingLocation,
132347
- addToPotentiallyUnwatchedPackageJsons,
132348
- invalidateResolutionsOfFailedLookupLocations,
132349
- invalidateResolutionOfFile,
132350
- invalidateResolution,
132351
- createTypeRootsWatch,
132352
- currentCache: () => currentCache
132353
- };
132354
- function clearForCache(cache) {
132355
- let gcCaches = false;
132356
- currentCache = cache;
132357
- watchedResolutionInfoMap.forEach((watchedResolutionInfo, resolution) => {
132358
- if (watchedResolutionInfo.caches.has(cache)) {
132359
- gcCaches = releaseResolution(
132360
- resolution,
132361
- /*moduleOrTypeRefCache*/
132362
- void 0
132363
- ) || gcCaches;
132364
- }
132365
- });
132366
- fileWatchesOfAffectingLocations.forEach((watcher, location) => {
132367
- var _a;
132368
- if ((_a = watcher.files) == null ? void 0 : _a.delete(cache)) closeFileWatcherOfAffectingLocation(location, watcher);
132369
- });
132370
- inUseResolutionCaches.delete(cache);
132371
- if (gcCaches) {
132372
- gcModuleOrTypeRefCache(moduleResolutionCache);
132373
- gcModuleOrTypeRefCache(typeReferenceDirectiveResolutionCache);
132374
- gcModuleOrTypeRefCache(libraryResolutionCache);
132375
- }
132376
- currentCache = void 0;
132377
- if (cacheToOptions.delete(cache)) compactCachesWoker();
132378
- }
132379
- function clear2(cache) {
132380
- if (!inUseResolutionCaches.has(cache)) return;
132381
- if (inUseResolutionCaches.size !== 1) return clearForCache(cache);
132382
- currentCache = void 0;
132383
- inUseResolutionCaches.clear();
132384
- cacheToOptions.clear();
132385
- cachesNeedingGc = void 0;
132386
- potentiallyUnwatchedPackageJsons = void 0;
132387
- clearMap(directoryWatchesOfFailedLookups, closeFileWatcherOf);
132388
- clearMap(nonRecursiveDirectoryWatchesOfFailedLookups, closeFileWatcherOf);
132389
- clearMap(fileWatchesOfAffectingLocations, closeFileWatcherOf);
132390
- clearMap(typeRootsWatches, closeFileWatcherOf);
132391
- packageJsonRefCount.clear();
132392
- isSymlinkCache.clear();
132393
- packageDirWatchers.clear();
132394
- dirPathToSymlinkPackageRefCount.clear();
132395
- resolvedFileToResolution.clear();
132396
- resolutionsWithFailedLookups.clear();
132397
- resolutionsWithOnlyAffectingLocations.clear();
132398
- watchedResolutionInfoMap.clear();
132399
- failedLookupChecks = void 0;
132400
- startsWithPathChecks = void 0;
132401
- isInDirectoryChecks = void 0;
132402
- affectingPathChecks = void 0;
132403
- moduleResolutionCache.clear();
132404
- typeReferenceDirectiveResolutionCache.clear();
132405
- libraryResolutionCache.clear();
132406
- impliedFormatPackageJsons.clear();
132407
- }
132408
- function startCachingPerDirectoryResolution(cache) {
132409
- currentCache = cache;
132410
- moduleResolutionCache.isReadonly = void 0;
132411
- typeReferenceDirectiveResolutionCache.isReadonly = void 0;
132412
- libraryResolutionCache.isReadonly = void 0;
132413
- moduleResolutionCache.getPackageJsonInfoCache().isReadonly = void 0;
132414
- isSymlinkCache.clear();
132415
- }
132416
- function finishCachingPerDirectoryResolution() {
132417
- potentiallyUnreferencedDirWatchers == null ? void 0 : potentiallyUnreferencedDirWatchers.forEach(
132418
- (path) => closeDirectoryWatchesOfFailedLookup(
132419
- getDirectoryWatchesOfFailedLookup(
132420
- path,
132421
- /*nonRecursive*/
132422
- false
132423
- ),
132424
- path,
132425
- /*nonRecursive*/
132426
- false
132427
- )
132428
- );
132429
- potentiallyUnreferencedDirWatchers = void 0;
132430
- cachesNeedingGc == null ? void 0 : cachesNeedingGc.forEach(gcModuleOrTypeRefCache);
132431
- cachesNeedingGc = void 0;
132432
- potentiallyUnwatchedPackageJsons == null ? void 0 : potentiallyUnwatchedPackageJsons.forEach(releasePotentiallyUnwatchedPackageJson);
132433
- potentiallyUnwatchedPackageJsons = void 0;
132434
- moduleResolutionCache.isReadonly = true;
132435
- typeReferenceDirectiveResolutionCache.isReadonly = true;
132436
- libraryResolutionCache.isReadonly = true;
132437
- moduleResolutionCache.getPackageJsonInfoCache().isReadonly = true;
132438
- isSymlinkCache.clear();
132439
- currentCache = void 0;
132440
- }
132441
- function compactCaches(availableOptions, cache) {
132442
- if (availableOptions.size) cacheToOptions.set(cache, availableOptions);
132443
- else cacheToOptions.delete(cache);
132444
- compactCachesWoker();
132445
- }
132446
- function compactCachesWoker() {
132447
- let availableOptions;
132448
- if (cacheToOptions.size === 1) availableOptions = firstDefinedIterator(cacheToOptions.values(), identity);
132449
- else {
132450
- availableOptions = /* @__PURE__ */ new Set();
132451
- cacheToOptions.forEach((setOfOptions) => setOfOptions.forEach((options) => availableOptions.add(options)));
132452
- }
132453
- moduleResolutionCache.compact(
132454
- availableOptions,
132455
- /*skipOptionsToRedirectsKeyCleanup*/
132456
- true
132457
- );
132458
- typeReferenceDirectiveResolutionCache.compact(availableOptions);
132459
- libraryResolutionCache.compact();
132460
- }
132461
- function gcModuleOrTypeRefCache(cache) {
132462
- considerNonWatchedResolutionAsInvalidated = true;
132463
- cache.gc(watchedResolutionInfoMap);
132464
- considerNonWatchedResolutionAsInvalidated = false;
132465
- }
132466
- function getValidResolution(resolution) {
132467
- return isInvalidatedResolution(resolution) ? void 0 : resolution;
132468
- }
132469
- function getValidModuleResolution(resolution, forSet) {
132470
- var _a, _b, _c;
132471
- resolution = getValidResolution(resolution);
132472
- return resolution && (forSet ? resolution.globalCacheResolution && isInvalidatedResolution(resolution.globalCacheResolution.globalResult) ? void 0 : resolution : ((_b = currentCache == null ? void 0 : (_a = currentCache.resolutionHost).getGlobalTypingsCacheLocation) == null ? void 0 : _b.call(_a)) && ((_c = resolution == null ? void 0 : resolution.globalCacheResolution) == null ? void 0 : _c.globalResult) ? currentCache.getValidResolution(resolution.globalCacheResolution.globalResult) : resolution);
132473
- }
132474
- function isInvalidatedResolution(resolution) {
132475
- var _a;
132476
- return !resolution || considerNonWatchedResolutionAsInvalidated && !watchedResolutionInfoMap.has(resolution) || ((_a = watchedResolutionInfoMap.get(resolution)) == null ? void 0 : _a.isInvalidated);
132477
- }
132478
- function isNodeModulesAtTypesDirectory(dirPath) {
132479
- return endsWith(dirPath, "/node_modules/@types");
132480
- }
132481
- function watchResolution(resolution, getResolutionWithResolvedFileName, redirectedReference) {
132482
- var _a, _b, _c;
132483
- let watchedResolutionInfo = watchedResolutionInfoMap.get(resolution);
132484
- if (!(watchedResolutionInfo == null ? void 0 : watchedResolutionInfo.caches.has(currentCache))) addRefCountToCacheMap(inUseResolutionCaches, currentCache);
132485
- if (!(watchedResolutionInfo == null ? void 0 : watchedResolutionInfo.caches.size)) {
132486
- if (!watchedResolutionInfo) {
132487
- watchedResolutionInfoMap.set(resolution, watchedResolutionInfo = { caches: /* @__PURE__ */ new Set() });
132488
- if (isResolvedWithGlobalCachePass(resolution) && !watchedResolutionInfoMap.has(resolution.globalCacheResolution.primary)) {
132489
- watchedResolutionInfoMap.set(resolution.globalCacheResolution.primary, { caches: /* @__PURE__ */ new Set() });
132490
- }
132491
- }
132492
- if (isResolvedWithGlobalCachePassButStillUnresolved(resolution)) {
132493
- (_a = resolution.globalCacheResolution.globalResolution.failedLookupLocations) == null ? void 0 : _a.forEach(
132494
- addToPotentiallyUnwatchedPackageJsonsIfPackageJson
132495
- );
132496
- if (resolution.globalCacheResolution.globalResolution.alternateResult) addToPotentiallyUnwatchedPackageJsonsIfPackageJson(resolution.globalCacheResolution.globalResolution.alternateResult);
132497
- (_b = resolution.globalCacheResolution.globalResolution.affectingLocations) == null ? void 0 : _b.forEach(addToPotentiallyUnwatchedPackageJsons);
132498
- }
132499
- const resolved = getResolutionWithResolvedFileName(resolution);
132500
- if (resolved && resolved.resolvedFileName) {
132501
- const key = sharedCacheHost.toPath(resolved.resolvedFileName);
132502
- let resolutions = resolvedFileToResolution.get(key);
132503
- if (!resolutions) resolvedFileToResolution.set(key, resolutions = /* @__PURE__ */ new Set());
132504
- resolutions.add(resolution);
132505
- }
132506
- }
132507
- watchFailedLookupLocationOfResolution(resolution, redirectedReference, watchedResolutionInfo);
132508
- watchAffectingLocationsOfResolution(resolution, watchedResolutionInfo);
132509
- watchedResolutionInfo.caches.add(currentCache);
132510
- if (isResolvedWithGlobalCachePass(resolution)) {
132511
- watchPrimaryOrGlobalResultFailedAndAffectedLookups(resolution.globalCacheResolution.primary);
132512
- } else if ((_c = resolution.globalCacheResolution) == null ? void 0 : _c.globalResult) {
132513
- watchPrimaryOrGlobalResultFailedAndAffectedLookups(resolution.globalCacheResolution.globalResult);
132514
- }
132515
- }
132516
- function watchPrimaryOrGlobalResultFailedAndAffectedLookups(primaryOrGlobalResult) {
132517
- const watchInfo = watchedResolutionInfoMap.get(primaryOrGlobalResult);
132518
- if (!(watchInfo == null ? void 0 : watchInfo.caches.size)) return;
132519
- const first2 = firstDefinedIterator(watchInfo.caches, identity);
132520
- const savedCurrentCache = currentCache;
132521
- currentCache = first2;
132522
- watchFailedLookupLocationOfResolution(
132523
- primaryOrGlobalResult,
132524
- /*redirectedReference*/
132525
- void 0,
132526
- watchInfo
132527
- );
132528
- watchAffectingLocationsOfResolution(primaryOrGlobalResult, watchInfo);
132529
- currentCache = savedCurrentCache;
132530
- }
132531
- function watchFailedLookupLocation(failedLookupLocation, resolution, redirectedReference, watchedResolutionInfo) {
132532
- var _a, _b;
132533
- watchedResolutionInfo.rootDirInfo ?? (watchedResolutionInfo.rootDirInfo = currentCache.getRootDirInfoForResolution(redirectedReference, resolution));
132534
- const failedLookupLocationPath = sharedCacheHost.toPath(failedLookupLocation);
132535
- if (endsWith(failedLookupLocationPath, "/package.json")) addRefToPackageJson(failedLookupLocationPath);
132536
- const toWatch = getDirectoryToWatchFailedLookupLocation(
132537
- failedLookupLocation,
132538
- failedLookupLocationPath,
132539
- watchedResolutionInfo.rootDirInfo.rootDir,
132540
- watchedResolutionInfo.rootDirInfo.rootPath,
132541
- watchedResolutionInfo.rootDirInfo.rootPathComponents,
132542
- watchedResolutionInfo.rootDirInfo.canWatch,
132543
- getCurrentDirectory,
132544
- sharedCacheHost.preferNonRecursiveWatch
132545
- );
132546
- if (!toWatch) return;
132547
- const { dir, dirPath, nonRecursive, packageDir, packageDirPath } = toWatch;
132548
- if (!packageDirPath || !currentCache.resolutionHost.realpath) {
132549
- if (!((_a = !nonRecursive ? watchedResolutionInfo.dirWatches : watchedResolutionInfo.nonRecursiveDirWatches) == null ? void 0 : _a.has(dirPath))) {
132550
- const dirWatcher = createOrAddRefToDirectoryWatchOfFailedLookups(dir, dirPath, nonRecursive, currentCache);
132551
- (!nonRecursive ? watchedResolutionInfo.dirWatches ?? (watchedResolutionInfo.dirWatches = /* @__PURE__ */ new Set()) : watchedResolutionInfo.nonRecursiveDirWatches ?? (watchedResolutionInfo.nonRecursiveDirWatches = /* @__PURE__ */ new Set())).add(dirPath);
132552
- addRefCountToMapForCaches(dirWatcher.refCount, watchedResolutionInfo.caches, currentCache);
132553
- }
132554
- } else {
132555
- Debug.assert(!nonRecursive);
132556
- const forDirPath = (_b = watchedResolutionInfo.packageDirWatchers) == null ? void 0 : _b.get(packageDirPath);
132557
- if (!(forDirPath == null ? void 0 : forDirPath.has(dirPath))) {
132558
- const packageDirWatcher = createDirectoryWatcherForPackageDir(dir, dirPath, packageDir, packageDirPath);
132559
- if (forDirPath) forDirPath.add(dirPath);
132560
- else (watchedResolutionInfo.packageDirWatchers ?? (watchedResolutionInfo.packageDirWatchers = /* @__PURE__ */ new Map())).set(packageDirPath, /* @__PURE__ */ new Set([dirPath]));
132561
- forRefCountCaches(watchedResolutionInfo.caches, (cache) => addRefToDirPathWatcherOfPackageDir(packageDirWatcher, dirPath, cache), currentCache);
132562
- }
132563
- }
132564
- }
132565
- function addRefToPackageJson(path) {
132566
- addRefCountToCacheMap(packageJsonRefCount, path);
132567
- }
132568
- function releasePackageJsonCachePath(path) {
132569
- var _a;
132570
- (_a = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap()) == null ? void 0 : _a.delete(path);
132571
- packageJsonRefCount.delete(path);
132572
- }
132573
- function addToPotentiallyUnwatchedPackageJsons(location) {
132574
- (potentiallyUnwatchedPackageJsons ?? (potentiallyUnwatchedPackageJsons = /* @__PURE__ */ new Set())).add(sharedCacheHost.toPath(location));
132575
- }
132576
- function addToPotentiallyUnwatchedPackageJsonsIfPackageJson(location) {
132577
- if (endsWith(location, "/package.json")) addToPotentiallyUnwatchedPackageJsons(location);
132578
- }
132579
- function releasePotentiallyUnwatchedPackageJson(path) {
132580
- var _a;
132581
- if (!packageJsonRefCount.has(path)) (_a = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap()) == null ? void 0 : _a.delete(path);
132582
- }
132583
- function releasePackageJson(path) {
132584
- const existing = packageJsonRefCount.get(path);
132585
- if (existing !== 1) packageJsonRefCount.set(path, existing - 1);
132586
- else releasePackageJsonCachePath(path);
132587
- }
132588
- function releaseIfPackageJson(failedLookupLocation) {
132589
- if (endsWith(failedLookupLocation, "/package.json")) releasePackageJson(sharedCacheHost.toPath(failedLookupLocation));
132590
- }
132591
- function watchFailedLookupLocationOfResolution(resolution, redirectedReference, watchedResolutionInfo) {
132592
- var _a, _b, _c, _d, _e;
132593
- if (!watchedResolutionInfo.caches.has(currentCache)) {
132594
- (_a = watchedResolutionInfo.dirWatches) == null ? void 0 : _a.forEach((dirPath) => addRefCountToCacheMap(getDirectoryWatchesOfFailedLookup(
132595
- dirPath,
132596
- /*nonRecursive*/
132597
- false
132598
- ).refCount, currentCache));
132599
- (_b = watchedResolutionInfo.nonRecursiveDirWatches) == null ? void 0 : _b.forEach((dirPath) => addRefCountToCacheMap(getDirectoryWatchesOfFailedLookup(
132600
- dirPath,
132601
- /*nonRecursive*/
132602
- true
132603
- ).refCount, currentCache));
132604
- (_c = watchedResolutionInfo.packageDirWatchers) == null ? void 0 : _c.forEach((dirPaths, packageDirPath) => {
132605
- const packageDirWatcher = packageDirWatchers.get(packageDirPath);
132606
- dirPaths.forEach((dirPath) => addRefToDirPathWatcherOfPackageDir(packageDirWatcher, dirPath, currentCache));
132607
- });
132608
- }
132609
- if (watchedResolutionInfo.watchedFailed === ((_d = resolution.failedLookupLocations) == null ? void 0 : _d.length)) return;
132610
- if (!watchedResolutionInfo.watchedFailed) {
132611
- resolutionsWithFailedLookups.add(resolution);
132612
- if (watchedResolutionInfo.watchedAffected) resolutionsWithOnlyAffectingLocations.delete(resolution);
132613
- }
132614
- for (let i = watchedResolutionInfo.watchedFailed || 0; i < resolution.failedLookupLocations.length; i++) {
132615
- watchFailedLookupLocation(
132616
- resolution.failedLookupLocations[i],
132617
- resolution,
132618
- redirectedReference,
132619
- watchedResolutionInfo
132620
- );
132621
- }
132622
- if (!watchedResolutionInfo.watchedFailed && resolution.alternateResult) {
132623
- watchFailedLookupLocation(
132624
- resolution.alternateResult,
132625
- resolution,
132626
- redirectedReference,
132627
- watchedResolutionInfo
132628
- );
132629
- }
132630
- watchedResolutionInfo.watchedFailed = (_e = resolution.failedLookupLocations) == null ? void 0 : _e.length;
132631
- }
132632
- function createDirectoryWatcherForPackageDir(dir, dirPath, packageDir, packageDirPath) {
132633
- let isSymlink = isSymlinkCache.get(packageDirPath);
132634
- let packageDirWatcher = packageDirWatchers.get(packageDirPath);
132635
- if (isSymlink === void 0) {
132636
- const realPath2 = currentCache.resolutionHost.realpath(packageDir);
132637
- isSymlink = realPath2 !== packageDir && sharedCacheHost.toPath(realPath2) !== packageDirPath;
132638
- isSymlinkCache.set(packageDirPath, isSymlink);
132639
- if (!packageDirWatcher) {
132640
- packageDirWatchers.set(
132641
- packageDirPath,
132642
- packageDirWatcher = {
132643
- dirPathToWatcher: /* @__PURE__ */ new Map(),
132644
- isSymlink
132645
- }
132646
- );
132647
- } else if (packageDirWatcher.isSymlink !== isSymlink) {
132648
- packageDirWatcher.dirPathToWatcher.forEach((watcher, dirPath2, map2) => {
132649
- releaseRefCountFromMapForCaches(watcher.watcher.refCount, watcher.refCount);
132650
- (potentiallyUnreferencedDirWatchers ?? (potentiallyUnreferencedDirWatchers = /* @__PURE__ */ new Set())).add(packageDirWatcher.isSymlink ? packageDirPath : dirPath2);
132651
- const firstCache = firstDefinedIterator(watcher.refCount.keys(), identity);
132652
- if (firstCache) {
132653
- watcher.watcher = createDirPathToWatcher(firstCache);
132654
- addRefCountToMapForCaches(watcher.watcher.refCount, watcher.refCount, firstCache);
132655
- } else {
132656
- map2.delete(dirPath2);
132657
- }
132658
- });
132659
- packageDirWatcher.isSymlink = isSymlink;
132660
- }
132661
- } else {
132662
- Debug.assertIsDefined(packageDirWatcher);
132663
- Debug.assert(isSymlink === packageDirWatcher.isSymlink);
132664
- }
132665
- if (packageDirWatcher.dirPathToWatcher.has(dirPath)) {
132666
- addRefToDirPathWatcherOfPackageDir(packageDirWatcher, dirPath, currentCache);
132667
- } else {
132668
- packageDirWatcher.dirPathToWatcher.set(dirPath, {
132669
- watcher: createDirPathToWatcher(currentCache),
132670
- refCount: /* @__PURE__ */ new Map([[currentCache, 1]])
132671
- });
132672
- if (isSymlink) addRefCountToCacheMap(dirPathToSymlinkPackageRefCount, dirPath);
132673
- }
132674
- return packageDirWatcher;
132675
- function createDirPathToWatcher(cache) {
132676
- return isSymlink ? createOrAddRefToDirectoryWatchOfFailedLookups(
132677
- packageDir,
132678
- packageDirPath,
132679
- /*nonRecursive*/
132680
- false,
132681
- cache
132682
- ) : createOrAddRefToDirectoryWatchOfFailedLookups(
132683
- dir,
132684
- dirPath,
132685
- /*nonRecursive*/
132686
- false,
132687
- cache
132688
- );
132689
- }
132690
- }
132691
- function addRefToDirPathWatcherOfPackageDir(packageDirWatcher, dirPath, cache) {
132692
- const forDirPath = packageDirWatcher.dirPathToWatcher.get(dirPath);
132693
- if (!forDirPath.refCount.has(cache)) addRefCountToCacheMap(forDirPath.watcher.refCount, cache);
132694
- addRefCountToCacheMap(forDirPath.refCount, cache);
132695
- }
132696
- function removeRefToDirPathWatcherOfPackageDir(packageDirPath, dirPath) {
132697
- const packageDirWatcher = packageDirWatchers.get(packageDirPath);
132698
- if (!packageDirWatcher) return;
132699
- const forDirPath = packageDirWatcher.dirPathToWatcher.get(dirPath);
132700
- if (!forDirPath) return;
132701
- releaseRefCountFromMap(forDirPath.refCount, currentCache);
132702
- if (forDirPath.refCount.has(currentCache)) return;
132703
- releaseRefCountFromMap(forDirPath.watcher.refCount, currentCache);
132704
- if (forDirPath.refCount.size !== 0) return;
132705
- closeDirectoryWatchesOfFailedLookup(
132706
- forDirPath.watcher,
132707
- packageDirWatcher.isSymlink ? packageDirPath : dirPath,
132708
- /*nonRecursive*/
132709
- false
132710
- );
132711
- packageDirWatcher.dirPathToWatcher.delete(dirPath);
132712
- if (packageDirWatcher.isSymlink) releaseRefCountFromMap(dirPathToSymlinkPackageRefCount, dirPath);
132713
- if (packageDirWatcher.dirPathToWatcher.size === 0) {
132714
- packageDirWatchers.delete(packageDirPath);
132715
- }
132716
- }
132717
- function getDirectoryWatchesOfFailedLookup(dirPath, nonRecursive) {
132718
- const watchMap = !nonRecursive ? directoryWatchesOfFailedLookups : nonRecursiveDirectoryWatchesOfFailedLookups;
132719
- return watchMap.get(dirPath);
132720
- }
132721
- function createOrAddRefToDirectoryWatchOfFailedLookups(dir, dirPath, nonRecursive, cache) {
132722
- const watchMap = !nonRecursive ? directoryWatchesOfFailedLookups : nonRecursiveDirectoryWatchesOfFailedLookups;
132723
- let dirWatcher = watchMap.get(dirPath);
132724
- if (dirWatcher) {
132725
- addRefCountToCacheMap(dirWatcher.refCount, cache);
132726
- } else {
132727
- watchMap.set(
132728
- dirPath,
132729
- dirWatcher = {
132730
- watcher: cache.resolutionHost.watchDirectoryOfFailedLookupLocation(
132731
- dir,
132732
- (fileOrDirectory) => onDirectoryWatcher(dirPath, nonRecursive, fileOrDirectory),
132733
- nonRecursive ? 0 /* None */ : 1 /* Recursive */
132734
- ),
132735
- refCount: /* @__PURE__ */ new Map([[cache, 1]])
132736
- }
132737
- );
132738
- }
132739
- return dirWatcher;
132740
- }
132741
- function removeDirectoryWatcher(dirPath, nonRecursive, forCaches) {
132742
- const dirWatcher = getDirectoryWatchesOfFailedLookup(dirPath, nonRecursive);
132743
- if (dirWatcher) releaseRefCountFromMapForCaches(dirWatcher.refCount, forCaches);
132744
- closeDirectoryWatchesOfFailedLookup(dirWatcher, dirPath, nonRecursive);
132745
- }
132746
- function closeDirectoryWatchesOfFailedLookup(watcher, path, nonRecursive) {
132747
- if (watcher && watcher.refCount.size === 0) {
132748
- if (!nonRecursive) directoryWatchesOfFailedLookups.delete(path);
132749
- else nonRecursiveDirectoryWatchesOfFailedLookups.delete(path);
132750
- watcher.watcher.close();
132751
- }
132752
- }
132753
- function onDirectoryWatcher(dirPath, nonRecursive, fileOrDirectory, fileOrDirectoryPath) {
132754
- var _a;
132755
- const refCountCache = (_a = getDirectoryWatchesOfFailedLookup(dirPath, nonRecursive)) == null ? void 0 : _a.refCount;
132756
- if (!refCountCache) return;
132757
- fileOrDirectoryPath ?? (fileOrDirectoryPath = sharedCacheHost.toPath(fileOrDirectory));
132758
- refCountCache.forEach((_refCount, cache) => {
132759
- var _a2;
132760
- (_a2 = cache.resolutionHost.getCachedDirectoryStructureHost()) == null ? void 0 : _a2.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
132761
- });
132762
- scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath, refCountCache);
132763
- }
132764
- function watchAffectingLocationsOfResolution(resolution, watchedResolutionInfo) {
132765
- var _a, _b, _c;
132766
- if (((_a = resolution.affectingLocations) == null ? void 0 : _a.length) === watchedResolutionInfo.watchedAffected) {
132767
- if (!watchedResolutionInfo.caches.has(currentCache)) {
132768
- (_b = resolution.affectingLocations) == null ? void 0 : _b.forEach(
132769
- (affectingLocation) => addRefCountToCacheMap(
132770
- fileWatchesOfAffectingLocations.get(affectingLocation).resolutions,
132771
- currentCache
132772
- )
132773
- );
132774
- }
132775
- return;
132776
- }
132777
- if (!watchedResolutionInfo.watchedAffected && !watchedResolutionInfo.watchedFailed) resolutionsWithOnlyAffectingLocations.add(resolution);
132778
- for (let i = watchedResolutionInfo.watchedAffected || 0; i < resolution.affectingLocations.length; i++) {
132779
- createFileWatcherOfAffectingLocation(
132780
- resolution.affectingLocations[i],
132781
- /*forResolution*/
132782
- true
132783
- );
132784
- addRefCountToMapForCaches(
132785
- fileWatchesOfAffectingLocations.get(resolution.affectingLocations[i]).resolutions,
132786
- watchedResolutionInfo.caches,
132787
- currentCache
132788
- );
132789
- }
132790
- watchedResolutionInfo.watchedAffected = (_c = resolution.affectingLocations) == null ? void 0 : _c.length;
132791
- }
132792
- function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) {
132793
- if (!forResolution) addRefCountToCacheMap(inUseResolutionCaches, currentCache);
132794
- const fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation);
132795
- if (fileWatcher) {
132796
- addRefCountToCacheMap(forResolution ? fileWatcher.resolutions ?? (fileWatcher.resolutions = /* @__PURE__ */ new Map()) : fileWatcher.files ?? (fileWatcher.files = /* @__PURE__ */ new Map()), currentCache);
132797
- return;
132798
- }
132799
- let locationToWatch = affectingLocation;
132800
- let isSymlink = false;
132801
- let symlinkWatcher;
132802
- if (currentCache.resolutionHost.realpath) {
132803
- locationToWatch = currentCache.resolutionHost.realpath(affectingLocation);
132804
- if (affectingLocation !== locationToWatch) {
132805
- isSymlink = true;
132806
- symlinkWatcher = fileWatchesOfAffectingLocations.get(locationToWatch);
132807
- }
132808
- }
132809
- const resolutions = forResolution ? /* @__PURE__ */ new Map([[currentCache, 1]]) : void 0;
132810
- const files = forResolution ? void 0 : /* @__PURE__ */ new Map([[currentCache, 1]]);
132811
- if (!isSymlink || !symlinkWatcher) {
132812
- const watcher = {
132813
- watcher: canWatchAffectingLocation(sharedCacheHost.toPath(locationToWatch)) ? currentCache.resolutionHost.watchAffectingFileLocation(locationToWatch, (fileName, eventKind) => {
132814
- const refCountCaches = /* @__PURE__ */ new Set();
132815
- onFileWatcherOfAffectingLocation(locationToWatch, refCountCaches);
132816
- const seenCaches = /* @__PURE__ */ new Set();
132817
- refCountCaches.forEach(
132818
- (caches) => forRefCountCaches(
132819
- caches,
132820
- (cache) => {
132821
- var _a;
132822
- if (!tryAddToSet(seenCaches, cache)) return;
132823
- (_a = cache.resolutionHost.getCachedDirectoryStructureHost()) == null ? void 0 : _a.addOrDeleteFile(fileName, sharedCacheHost.toPath(locationToWatch), eventKind);
132824
- cache.resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
132825
- },
132826
- /*skipCache*/
132827
- void 0
132828
- )
132829
- );
132830
- }) : noopFileWatcher,
132831
- resolutions: isSymlink ? void 0 : resolutions,
132832
- files: isSymlink ? void 0 : files,
132833
- symlinks: void 0
132834
- };
132835
- fileWatchesOfAffectingLocations.set(locationToWatch, watcher);
132836
- addRefToPackageJson(sharedCacheHost.toPath(locationToWatch));
132837
- if (isSymlink) symlinkWatcher = watcher;
132838
- }
132839
- if (isSymlink) {
132840
- Debug.assert(!!symlinkWatcher);
132841
- const watcher = {
132842
- watcher: {
132843
- close: () => {
132844
- var _a, _b, _c;
132845
- const symlinkWatcher2 = fileWatchesOfAffectingLocations.get(locationToWatch);
132846
- if (((_a = symlinkWatcher2 == null ? void 0 : symlinkWatcher2.symlinks) == null ? void 0 : _a.delete(affectingLocation)) && !symlinkWatcher2.symlinks.size && !((_b = symlinkWatcher2.resolutions) == null ? void 0 : _b.size) && !((_c = symlinkWatcher2.files) == null ? void 0 : _c.size)) {
132847
- fileWatchesOfAffectingLocations.delete(locationToWatch);
132848
- releasePackageJson(sharedCacheHost.toPath(locationToWatch));
132849
- symlinkWatcher2.watcher.close();
132850
- }
132851
- }
132852
- },
132853
- resolutions,
132854
- files,
132855
- symlinks: void 0
132856
- };
132857
- fileWatchesOfAffectingLocations.set(affectingLocation, watcher);
132858
- addRefToPackageJson(sharedCacheHost.toPath(affectingLocation));
132859
- (symlinkWatcher.symlinks ?? (symlinkWatcher.symlinks = /* @__PURE__ */ new Set())).add(affectingLocation);
132860
- }
132861
- }
132862
- function releaseFileWatcherOfAffectingLocation(location) {
132863
- releaseRefCountFromMap(inUseResolutionCaches, currentCache);
132864
- const watcher = fileWatchesOfAffectingLocations.get(location);
132865
- releaseRefCountFromMap(watcher.files, currentCache);
132866
- }
132867
- function closeFileWatcherOfAffectingLocation(path, watcher) {
132868
- var _a, _b, _c;
132869
- watcher ?? (watcher = fileWatchesOfAffectingLocations.get(path));
132870
- if (watcher && !((_a = watcher.files) == null ? void 0 : _a.size) && !((_b = watcher.resolutions) == null ? void 0 : _b.size) && !((_c = watcher.symlinks) == null ? void 0 : _c.size)) {
132871
- fileWatchesOfAffectingLocations.delete(path);
132872
- releasePackageJson(sharedCacheHost.toPath(path));
132873
- watcher.watcher.close();
132874
- }
132875
- }
132876
- function onFileWatcherOfAffectingLocation(path, seenCaches) {
132877
- var _a, _b, _c, _d;
132878
- const watcher = fileWatchesOfAffectingLocations.get(path);
132879
- if ((_a = watcher == null ? void 0 : watcher.resolutions) == null ? void 0 : _a.size) {
132880
- (affectingPathChecks ?? (affectingPathChecks = /* @__PURE__ */ new Set())).add(path);
132881
- seenCaches.add(watcher.resolutions);
132882
- }
132883
- if ((_b = watcher == null ? void 0 : watcher.files) == null ? void 0 : _b.size) {
132884
- watcher.files.forEach((_refCount, cache) => cache.invalidateAffectingFileWatcher(path));
132885
- seenCaches.add(watcher.files);
132886
- }
132887
- (_c = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap()) == null ? void 0 : _c.delete(sharedCacheHost.toPath(path));
132888
- (_d = watcher == null ? void 0 : watcher.symlinks) == null ? void 0 : _d.forEach((path2) => onFileWatcherOfAffectingLocation(path2, seenCaches));
132889
- }
132890
- function releaseResolution(resolution, moduleOrTypeRefCache) {
132891
- var _a, _b, _c, _d, _e, _f;
132892
- releaseRefCountFromMap(inUseResolutionCaches, currentCache);
132893
- const watchedResolutionInfo = watchedResolutionInfoMap.get(resolution);
132894
- watchedResolutionInfo.caches.delete(currentCache);
132895
- const forCaches = /* @__PURE__ */ new Set([currentCache]);
132896
- (_a = watchedResolutionInfo.dirWatches) == null ? void 0 : _a.forEach((dirPath) => removeDirectoryWatcher(
132897
- dirPath,
132898
- /*nonRecursive*/
132899
- false,
132900
- forCaches
132901
- ));
132902
- (_b = watchedResolutionInfo.nonRecursiveDirWatches) == null ? void 0 : _b.forEach((dirPath) => removeDirectoryWatcher(
132903
- dirPath,
132904
- /*nonRecursive*/
132905
- true,
132906
- forCaches
132907
- ));
132908
- (_c = watchedResolutionInfo.packageDirWatchers) == null ? void 0 : _c.forEach(
132909
- (dirPaths, packageDirPath) => dirPaths.forEach(
132910
- (dirPath) => removeRefToDirPathWatcherOfPackageDir(packageDirPath, dirPath)
132911
- )
132912
- );
132913
- (_d = resolution.affectingLocations) == null ? void 0 : _d.forEach((affectingLocation) => {
132914
- const watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
132915
- if (watcher == null ? void 0 : watcher.resolutions) releaseRefCountFromMap(watcher.resolutions, currentCache);
132916
- closeFileWatcherOfAffectingLocation(affectingLocation, watcher);
132917
- });
132918
- if (watchedResolutionInfo.caches.size) return false;
132919
- watchedResolutionInfoMap.delete(resolution);
132920
- if (resolutionsWithFailedLookups.delete(resolution)) {
132921
- (_e = resolution.failedLookupLocations) == null ? void 0 : _e.forEach(releaseIfPackageJson);
132922
- if (resolution.alternateResult) releaseIfPackageJson(resolution.alternateResult);
132923
- }
132924
- resolutionsWithOnlyAffectingLocations.delete(resolution);
132925
- const resolved = getModuleOrTypeRefResolved(resolution);
132926
- if (resolved && resolved.resolvedFileName) {
132927
- const key = sharedCacheHost.toPath(resolved.resolvedFileName);
132928
- const resolutions = resolvedFileToResolution.get(key);
132929
- if ((resolutions == null ? void 0 : resolutions.delete(resolution)) && !resolutions.size) resolvedFileToResolution.delete(key);
132930
- }
132931
- if (isResolvedWithGlobalCachePass(resolution)) {
132932
- const primary = resolution.globalCacheResolution.primary;
132933
- const primaryWatchedInfo = watchedResolutionInfoMap.get(primary);
132934
- if (primaryWatchedInfo.caches.size) {
132935
- primary.globalCacheResolution = { primary };
132936
- } else {
132937
- watchedResolutionInfoMap.delete(primary);
132938
- }
132939
- } else if ((_f = resolution.globalCacheResolution) == null ? void 0 : _f.globalResult) {
132940
- watchedResolutionInfoMap.set(resolution, watchedResolutionInfo);
132941
- watchedResolutionInfo.dirWatches = void 0;
132942
- watchedResolutionInfo.nonRecursiveDirWatches = void 0;
132943
- watchedResolutionInfo.packageDirWatchers = void 0;
132944
- watchedResolutionInfo.watchedFailed = void 0;
132945
- watchedResolutionInfo.watchedAffected = void 0;
132946
- watchedResolutionInfo.isInvalidated = void 0;
132947
- watchedResolutionInfo.rootDirInfo = void 0;
132948
- }
132949
- if (moduleOrTypeRefCache) (cachesNeedingGc ?? (cachesNeedingGc = /* @__PURE__ */ new Set())).add(moduleOrTypeRefCache.sharedCache);
132950
- return true;
132951
- }
132952
- function invalidateResolutions(resolutions, canInvalidate) {
132953
- if (!resolutions) return false;
132954
- let invalidated = false;
132955
- resolutions.forEach((resolution) => invalidated = invalidateResolution(resolution, canInvalidate) || invalidated);
132956
- return invalidated;
132957
- }
132958
- function invalidateResolution(resolution, canInvalidate) {
132959
- const watchedResolutionInfo = watchedResolutionInfoMap.get(resolution);
132960
- if (watchedResolutionInfo.isInvalidated || !canInvalidate(resolution)) return false;
132961
- watchedResolutionInfo.isInvalidated = true;
132962
- watchedResolutionInfo.caches.forEach(
132963
- (cache) => cache !== currentCache ? cache.invalidateResolution(resolution) : void 0
132964
- );
132965
- return true;
132966
- }
132967
- function invalidateResolutionOfFile(filePath) {
132968
- return invalidateResolutions(resolvedFileToResolution.get(filePath), returnTrue);
132969
- }
132970
- function scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, isCreatingWatchedDirectory, refCountCache) {
132971
- if (isCreatingWatchedDirectory) {
132972
- (isInDirectoryChecks || (isInDirectoryChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
132973
- } else {
132974
- const updatedPath = removeIgnoredPath(fileOrDirectoryPath);
132975
- if (!updatedPath) return false;
132976
- fileOrDirectoryPath = updatedPath;
132977
- if (sharedCacheHost.fileIsOpen(fileOrDirectoryPath)) {
132978
- return false;
132979
- }
132980
- const dirOfFileOrDirectory = getDirectoryPath(fileOrDirectoryPath);
132981
- if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || isNodeModulesDirectory(fileOrDirectoryPath) || isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || isNodeModulesDirectory(dirOfFileOrDirectory)) {
132982
- (failedLookupChecks || (failedLookupChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
132983
- (startsWithPathChecks || (startsWithPathChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
132984
- } else {
132985
- if (fileExtensionIs(fileOrDirectoryPath, ".map")) {
132986
- return false;
132987
- }
132988
- if (!forEachKey(
132989
- refCountCache,
132990
- (cache) => !isEmittedFileOfProgram(
132991
- cache.resolutionHost.getCurrentProgram(),
132992
- fileOrDirectoryPath
132993
- )
132994
- )) return false;
132995
- (failedLookupChecks || (failedLookupChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
132996
- (startsWithPathChecks || (startsWithPathChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
132997
- const packagePath = parseNodeModuleFromPath(
132998
- fileOrDirectoryPath,
132999
- /*isFolder*/
133000
- true
133001
- );
133002
- if (packagePath) (startsWithPathChecks || (startsWithPathChecks = /* @__PURE__ */ new Set())).add(packagePath);
133003
- }
133004
- }
133005
- refCountCache.forEach((_refCount, cache) => cache.resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations());
133006
- }
133007
- function invalidatePackageJsonMap() {
133008
- const packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
133009
- if (packageJsonMap && (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks)) {
133010
- packageJsonMap.forEach((_value, path) => isInvalidatedFailedLookup(path) ? packageJsonMap.delete(path) : void 0);
133011
- }
133012
- }
133013
- function invalidateResolutionsOfFailedLookupLocations() {
133014
- if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
133015
- return false;
133016
- }
133017
- let invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution);
133018
- invalidatePackageJsonMap();
133019
- failedLookupChecks = void 0;
133020
- startsWithPathChecks = void 0;
133021
- isInDirectoryChecks = void 0;
133022
- invalidated = invalidateResolutions(resolutionsWithOnlyAffectingLocations, canInvalidatedFailedLookupResolutionWithAffectingLocation) || invalidated;
133023
- affectingPathChecks = void 0;
133024
- return invalidated;
133025
- }
133026
- function canInvalidateFailedLookupResolution(resolution) {
133027
- var _a;
133028
- if (canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution)) return true;
133029
- if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) return false;
133030
- return ((_a = resolution.failedLookupLocations) == null ? void 0 : _a.some((location) => isInvalidatedFailedLookup(sharedCacheHost.toPath(location)))) || !!resolution.alternateResult && isInvalidatedFailedLookup(sharedCacheHost.toPath(resolution.alternateResult));
133031
- }
133032
- function isInvalidatedFailedLookup(locationPath) {
133033
- return (failedLookupChecks == null ? void 0 : failedLookupChecks.has(locationPath)) || firstDefinedIterator((startsWithPathChecks == null ? void 0 : startsWithPathChecks.keys()) || [], (fileOrDirectoryPath) => startsWith(locationPath, fileOrDirectoryPath) ? true : void 0) || firstDefinedIterator((isInDirectoryChecks == null ? void 0 : isInDirectoryChecks.keys()) || [], (dirPath) => locationPath.length > dirPath.length && startsWith(locationPath, dirPath) && (isDiskPathRoot(dirPath) || locationPath[dirPath.length] === directorySeparator) ? true : void 0);
133034
- }
133035
- function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
133036
- var _a;
133037
- return !!affectingPathChecks && ((_a = resolution.affectingLocations) == null ? void 0 : _a.some((location) => affectingPathChecks.has(location)));
133038
- }
133039
- function createTypeRootsWatch(typeRoot, cache) {
133040
- let watcher = typeRootsWatches.get(typeRoot);
133041
- if (watcher) {
133042
- watcher.refCount.add(cache);
133043
- } else {
133044
- typeRootsWatches.set(
133045
- typeRoot,
133046
- watcher = {
133047
- watcher: canWatchAtTypes(sharedCacheHost.toPath(typeRoot)) ? cache.resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
133048
- var _a;
133049
- const fileOrDirectoryPath = sharedCacheHost.toPath(fileOrDirectory);
133050
- (_a = typeRootsWatches.get(typeRoot)) == null ? void 0 : _a.refCount.forEach((cache2) => {
133051
- var _a2;
133052
- (_a2 = cache2.resolutionHost.getCachedDirectoryStructureHost()) == null ? void 0 : _a2.addOrDeleteFileOrDirectory(
133053
- fileOrDirectory,
133054
- fileOrDirectoryPath
133055
- );
133056
- cache2.invalidateTypeRoot();
133057
- });
133058
- const fileOrDirectoryPathComponents = getPathComponents(fileOrDirectoryPath);
133059
- directoryWatchesOfFailedLookups.forEach((_watcher, dirPath) => {
133060
- if (isInDirectoryPath(getPathComponents(dirPath), fileOrDirectoryPathComponents)) {
133061
- onDirectoryWatcher(
133062
- dirPath,
133063
- /*nonRecursive*/
133064
- false,
133065
- fileOrDirectory,
133066
- fileOrDirectoryPath
133067
- );
133068
- }
133069
- });
133070
- nonRecursiveDirectoryWatchesOfFailedLookups.forEach((_watcher, dirPath) => {
133071
- const dirPathComponents = getPathComponents(dirPath);
133072
- if (isInDirectoryPath(dirPathComponents, fileOrDirectoryPathComponents) && (dirPathComponents.length === fileOrDirectoryPathComponents.length || dirPathComponents.length + 1 === fileOrDirectoryPathComponents.length)) {
133073
- onDirectoryWatcher(
133074
- dirPath,
133075
- /*nonRecursive*/
133076
- true,
133077
- fileOrDirectory,
133078
- fileOrDirectoryPath
133079
- );
133080
- }
133081
- });
133082
- }, 1 /* Recursive */) : noopFileWatcher,
133083
- refCount: /* @__PURE__ */ new Set([cache])
133084
- }
133085
- );
133086
- }
133087
- const result = {
133088
- close: () => {
133089
- const existing = typeRootsWatches.get(typeRoot);
133090
- if (existing == null ? void 0 : existing.refCount.delete(cache)) {
133091
- releaseRefCountFromMap(inUseResolutionCaches, cache);
133092
- closeTypeRootsWatch(typeRoot, existing);
133093
- }
133094
- }
133095
- };
133096
- addRefCountToCacheMap(inUseResolutionCaches, cache);
133097
- return result;
133098
- }
133099
- function closeTypeRootsWatch(typeRoot, watcher) {
133100
- if (!watcher.refCount.size) {
133101
- typeRootsWatches.delete(typeRoot);
133102
- watcher.watcher.close();
133103
- }
133104
- }
133105
- }
133106
- function enableSharingModuleOrTypeReferenceResolutionCache(moduleOrTypeRefCache, sharedCache) {
133107
- const getFromDirectoryCache = moduleOrTypeRefCache.getFromDirectoryCache;
133108
- moduleOrTypeRefCache.getFromDirectoryCache = (name, mode, directoryName, redirectedReference) => {
133109
- let result = getFromDirectoryCache.call(moduleOrTypeRefCache, name, mode, directoryName, redirectedReference);
133110
- if (result) return result;
133111
- result = withSharingModuleOrTypeReferenceResolutionCache(
133112
- moduleOrTypeRefCache,
133113
- (sharedCache2) => sharedCache2.getFromDirectoryCache(name, mode, directoryName, redirectedReference)
133114
- );
133115
- if (result) {
133116
- moduleOrTypeRefCache.setPerDirectoryAndNonRelativeNameCacheResult(
133117
- name,
133118
- mode,
133119
- directoryName,
133120
- redirectedReference,
133121
- result
133122
- );
133123
- }
133124
- return result;
133125
- };
133126
- const getFromNonRelativeNameCache = moduleOrTypeRefCache.getFromNonRelativeNameCache;
133127
- moduleOrTypeRefCache.getFromNonRelativeNameCache = (nonRelativeModuleName, mode, directoryName, redirectedReference) => getFromNonRelativeNameCache.call(moduleOrTypeRefCache, nonRelativeModuleName, mode, directoryName, redirectedReference) || withSharingModuleOrTypeReferenceResolutionCache(
133128
- moduleOrTypeRefCache,
133129
- (sharedCache2) => sharedCache2 == null ? void 0 : sharedCache2.getFromNonRelativeNameCache(nonRelativeModuleName, mode, directoryName, redirectedReference)
133130
- );
133131
- const setPerDirectoryAndNonRelativeNameCacheResult = moduleOrTypeRefCache.setPerDirectoryAndNonRelativeNameCacheResult;
133132
- moduleOrTypeRefCache.setPerDirectoryAndNonRelativeNameCacheResult = (name, mode, directoryName, redirectedReference, result, primary) => {
133133
- var _a;
133134
- setPerDirectoryAndNonRelativeNameCacheResult.call(moduleOrTypeRefCache, name, mode, directoryName, redirectedReference, result, primary);
133135
- if (primary) return;
133136
- result = ((_a = result.globalCacheResolution) == null ? void 0 : _a.primary) || result;
133137
- withSharingModuleOrTypeReferenceResolutionCache(
133138
- moduleOrTypeRefCache,
133139
- (sharedCache2) => sharedCache2.setPerDirectoryAndNonRelativeNameCacheResult(name, mode, directoryName, redirectedReference, result)
133140
- );
133141
- };
133142
- const update = moduleOrTypeRefCache.update;
133143
- moduleOrTypeRefCache.update = (options) => {
133144
- var _a;
133145
- update.call(moduleOrTypeRefCache, options);
133146
- (_a = moduleOrTypeRefCache.sharedCache) == null ? void 0 : _a.update(options);
133147
- };
133148
- moduleOrTypeRefCache.sharedCache = sharedCache;
133149
- return moduleOrTypeRefCache;
133150
- }
133151
- function withSharingModuleOrTypeReferenceResolutionCache(moduleOrTypeRefCache, cb) {
133152
- if (!moduleOrTypeRefCache.sharedCache) return;
133153
- moduleOrTypeRefCache.sharedCache.update(moduleOrTypeRefCache.options());
133154
- return cb(moduleOrTypeRefCache.sharedCache);
133155
- }
133156
- function addRefCountToCacheMap(refCountCache, key) {
133157
- refCountCache.set(key, (refCountCache.get(key) ?? 0) + 1);
133158
- }
133159
- function releaseRefCountFromMap(refCountCache, key) {
133160
- const existing = refCountCache.get(key);
133161
- if (existing !== 1) refCountCache.set(key, existing - 1);
133162
- else refCountCache.delete(key);
133163
- }
133164
- function addRefCountToMapForCaches(refCountCache, forCaches, alreadyAddedCache) {
133165
- forRefCountCaches(forCaches, (cache) => addRefCountToCacheMap(refCountCache, cache), alreadyAddedCache);
133166
- }
133167
- function releaseRefCountFromMapForCaches(refCountCache, forCaches) {
133168
- forRefCountCaches(
133169
- forCaches,
133170
- (cache) => releaseRefCountFromMap(refCountCache, cache),
133171
- /*skipCache*/
133172
- void 0
132035
+ function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath, rootPath, rootPathComponents, isRootWatchable, getCurrentDirectory, preferNonRecursiveWatch, filterCustomPath) {
132036
+ const typeRootPathComponents = getPathComponents(typeRootPath);
132037
+ if (isRootWatchable && isInDirectoryPath(rootPathComponents, typeRootPathComponents)) {
132038
+ return rootPath;
132039
+ }
132040
+ typeRoot = isRootedDiskPath(typeRoot) ? normalizePath(typeRoot) : getNormalizedAbsolutePath(typeRoot, getCurrentDirectory());
132041
+ const toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(
132042
+ getPathComponents(typeRoot),
132043
+ typeRootPathComponents,
132044
+ typeRootPathComponents.length,
132045
+ perceivedOsRootLengthForWatching(typeRootPathComponents, typeRootPathComponents.length),
132046
+ typeRootPathComponents.indexOf("node_modules"),
132047
+ rootPathComponents,
132048
+ typeRootPathComponents.lastIndexOf("node_modules"),
132049
+ preferNonRecursiveWatch
133173
132050
  );
132051
+ return toWatch && filterCustomPath(toWatch.dirPath) ? toWatch.dirPath : void 0;
133174
132052
  }
133175
- function forRefCountCaches(forCaches, cb, skipCache) {
133176
- forCaches.forEach((_refCount, cache) => {
133177
- if (cache === skipCache) return;
133178
- cb(cache);
133179
- });
133180
- }
133181
-
133182
- // src/compiler/resolutionCache.ts
133183
132053
  function getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory) {
133184
132054
  const normalized = getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory());
133185
132055
  return !isDiskPathRoot(normalized) ? removeTrailingDirectorySeparator(normalized) : normalized;
@@ -133202,157 +132072,103 @@ function createModuleResolutionLoaderUsingGlobalCache(containingFile, redirected
133202
132072
  )
133203
132073
  };
133204
132074
  }
133205
- function needsResolutionFromGlobalCache(moduleName, resolution) {
133206
- return !isExternalModuleNameRelative(moduleName) && isUnresolvedOrResolvedToJs(resolution);
133207
- }
133208
- function isUnresolvedOrResolvedToJs(resolution) {
133209
- return !resolution.resolvedModule || !resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension);
133210
- }
133211
- function isResolvedWithGlobalCachePass(resolution) {
133212
- var _a;
133213
- return ((_a = resolution.globalCacheResolution) == null ? void 0 : _a.globalResult) === resolution;
133214
- }
133215
- function isResolvedWithoutGlobalCachePass(resolution) {
133216
- var _a;
133217
- return ((_a = resolution.globalCacheResolution) == null ? void 0 : _a.primary) === resolution;
133218
- }
133219
- function isResolvedWithGlobalCachePassButStillUnresolved(resolution) {
133220
- return isResolvedWithGlobalCachePass(resolution) && !resolution.globalCacheResolution.globalResolution.resolvedModule;
133221
- }
133222
- function createGlobalResolutionResultField(primary, global2) {
133223
- if (!primary) return global2 == null ? void 0 : global2.slice();
133224
- if (!global2) return primary.slice();
133225
- return primary.concat(global2);
133226
- }
133227
132075
  function resolveModuleNameUsingGlobalCache(resolutionHost, moduleResolutionCache, moduleName, containingFile, compilerOptions, redirectedReference, mode) {
133228
- var _a;
133229
132076
  const host = getModuleResolutionHost(resolutionHost);
133230
- const primary = resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
133231
- if (!resolutionHost.getGlobalTypingsCacheLocation) return primary;
133232
- const globalCache = (_a = resolutionHost.getGlobalTypingsCacheLocation) == null ? void 0 : _a.call(resolutionHost);
133233
- if ((globalCache === void 0 ? isResolvedWithoutGlobalCachePass(primary) : isResolvedWithGlobalCachePass(primary)) || !needsResolutionFromGlobalCache(moduleName, primary)) return primary;
133234
- if (globalCache === void 0) {
133235
- primary.globalCacheResolution = { primary };
133236
- return primary;
133237
- }
133238
- const globalResolution = loadModuleFromGlobalCache(
133239
- Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName),
133240
- resolutionHost.projectName,
133241
- compilerOptions,
133242
- host,
133243
- globalCache,
133244
- moduleResolutionCache
133245
- );
133246
- if (globalResolution.resolvedModule) {
133247
- primary.globalCacheResolution = { primary, globalResolution, globalResult: globalResolution };
133248
- globalResolution.failedLookupLocations = createGlobalResolutionResultField(primary.failedLookupLocations, globalResolution.failedLookupLocations);
133249
- globalResolution.affectingLocations = createGlobalResolutionResultField(primary.affectingLocations, globalResolution.affectingLocations);
133250
- globalResolution.resolutionDiagnostics = createGlobalResolutionResultField(globalResolution.resolutionDiagnostics, primary.resolutionDiagnostics);
133251
- globalResolution.alternateResult = primary.alternateResult;
133252
- } else {
133253
- primary.globalCacheResolution = {
133254
- primary,
133255
- globalResolution,
133256
- globalResult: { ...primary }
133257
- };
132077
+ const primaryResult = resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
132078
+ if (!resolutionHost.getGlobalTypingsCacheLocation) {
132079
+ return primaryResult;
132080
+ }
132081
+ const globalCache = resolutionHost.getGlobalTypingsCacheLocation();
132082
+ if (globalCache !== void 0 && !isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && extensionIsTS(primaryResult.resolvedModule.extension))) {
132083
+ const { resolvedModule, failedLookupLocations, affectingLocations, resolutionDiagnostics } = loadModuleFromGlobalCache(
132084
+ Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName),
132085
+ resolutionHost.projectName,
132086
+ compilerOptions,
132087
+ host,
132088
+ globalCache,
132089
+ moduleResolutionCache
132090
+ );
132091
+ if (resolvedModule) {
132092
+ primaryResult.resolvedModule = resolvedModule;
132093
+ primaryResult.failedLookupLocations = updateResolutionField(primaryResult.failedLookupLocations, failedLookupLocations);
132094
+ primaryResult.affectingLocations = updateResolutionField(primaryResult.affectingLocations, affectingLocations);
132095
+ primaryResult.resolutionDiagnostics = updateResolutionField(primaryResult.resolutionDiagnostics, resolutionDiagnostics);
132096
+ return primaryResult;
132097
+ }
133258
132098
  }
133259
- Debug.assertIsDefined(primary.globalCacheResolution.globalResult);
133260
- primary.globalCacheResolution.globalResult.globalCacheResolution = primary.globalCacheResolution;
133261
- moduleResolutionCache.setPerDirectoryAndNonRelativeNameCacheResult(
133262
- moduleName,
133263
- mode,
133264
- getDirectoryPath(containingFile),
133265
- redirectedReference,
133266
- primary.globalCacheResolution.globalResult,
133267
- primary
133268
- );
133269
- return primary.globalCacheResolution.globalResult;
132099
+ return primaryResult;
133270
132100
  }
133271
- function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache = createSharedResolutionCache(resolutionHost)) {
132101
+ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
132102
+ let filesWithChangedSetOfUnresolvedImports;
133272
132103
  let filesWithInvalidatedResolutions;
132104
+ let filesWithInvalidatedNonRelativeUnresolvedImports;
132105
+ const nonRelativeExternalModuleResolutions = /* @__PURE__ */ new Set();
132106
+ const resolutionsWithFailedLookups = /* @__PURE__ */ new Set();
132107
+ const resolutionsWithOnlyAffectingLocations = /* @__PURE__ */ new Set();
132108
+ const resolvedFileToResolution = /* @__PURE__ */ new Map();
133273
132109
  const impliedFormatPackageJsons = /* @__PURE__ */ new Map();
133274
- const filesReferencingResolution = /* @__PURE__ */ new Map();
133275
132110
  let hasChangedAutomaticTypeDirectiveNames = false;
133276
132111
  let affectingPathChecksForFile;
132112
+ let affectingPathChecks;
132113
+ let failedLookupChecks;
132114
+ let startsWithPathChecks;
132115
+ let isInDirectoryChecks;
133277
132116
  let allModuleAndTypeResolutionsAreInvalidated = false;
133278
- let resolutionsWithGlobalCachePassAreInvalidated = false;
133279
- let resolutionsWithoutGlobalCachePassAreInvalidated = false;
133280
- let unresolvedResolutionsWithGlobalCachePassAreInvalidated = false;
133281
- let pendingRemoveResolutionsOfFile;
133282
- let potentiallyUnreferencedResolutions;
133283
- let newUnresolvedResolutionCachePassResolutions;
133284
- let considerNonWatchedResolutionAsInvalidated = false;
133285
132117
  const getCurrentDirectory = memoize(() => resolutionHost.getCurrentDirectory());
132118
+ const cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
133286
132119
  const resolvedModuleNames = /* @__PURE__ */ new Map();
133287
- const moduleResolutionCache = enableSharingModuleOrTypeReferenceResolutionCache(
133288
- createModuleResolutionCache(
133289
- getCurrentDirectory(),
133290
- resolutionHost.getCanonicalFileName,
133291
- /*options*/
133292
- void 0,
133293
- sharedCache.moduleResolutionCache.getPackageJsonInfoCache(),
133294
- /*optionsToRedirectsKey*/
133295
- void 0,
133296
- getValidResolution
133297
- ),
133298
- sharedCache.moduleResolutionCache
132120
+ const moduleResolutionCache = createModuleResolutionCache(
132121
+ getCurrentDirectory(),
132122
+ resolutionHost.getCanonicalFileName,
132123
+ resolutionHost.getCompilationSettings()
133299
132124
  );
133300
132125
  const resolvedTypeReferenceDirectives = /* @__PURE__ */ new Map();
133301
- const typeReferenceDirectiveResolutionCache = enableSharingModuleOrTypeReferenceResolutionCache(
133302
- createTypeReferenceDirectiveResolutionCache(
133303
- getCurrentDirectory(),
133304
- resolutionHost.getCanonicalFileName,
133305
- /*options*/
133306
- void 0,
133307
- moduleResolutionCache.getPackageJsonInfoCache(),
133308
- moduleResolutionCache.optionsToRedirectsKey,
133309
- getValidResolution
133310
- ),
133311
- sharedCache.typeReferenceDirectiveResolutionCache
132126
+ const typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(
132127
+ getCurrentDirectory(),
132128
+ resolutionHost.getCanonicalFileName,
132129
+ resolutionHost.getCompilationSettings(),
132130
+ moduleResolutionCache.getPackageJsonInfoCache(),
132131
+ moduleResolutionCache.optionsToRedirectsKey
133312
132132
  );
133313
132133
  const resolvedLibraries = /* @__PURE__ */ new Map();
133314
- const libraryResolutionCache = enableSharingModuleOrTypeReferenceResolutionCache(
133315
- createModuleResolutionCache(
133316
- getCurrentDirectory(),
133317
- resolutionHost.getCanonicalFileName,
133318
- sharedCache.libraryResolutionCache.options(),
133319
- moduleResolutionCache.getPackageJsonInfoCache(),
133320
- /*optionsToRedirectsKey*/
133321
- void 0,
133322
- getValidResolution
133323
- ),
133324
- sharedCache.libraryResolutionCache
132134
+ const libraryResolutionCache = createModuleResolutionCache(
132135
+ getCurrentDirectory(),
132136
+ resolutionHost.getCanonicalFileName,
132137
+ getOptionsForLibraryResolution(resolutionHost.getCompilationSettings()),
132138
+ moduleResolutionCache.getPackageJsonInfoCache()
133325
132139
  );
133326
- let resolutionsResolvedWithGlobalCache = 0;
133327
- let resolutionsResolvedWithoutGlobalCache = 0;
133328
- const rootDirInfo = getRootDirInfo(rootDirForResolution);
133329
- const redirectsToRootDirInfo = /* @__PURE__ */ new Map();
132140
+ const directoryWatchesOfFailedLookups = /* @__PURE__ */ new Map();
132141
+ const fileWatchesOfAffectingLocations = /* @__PURE__ */ new Map();
132142
+ const rootDir = getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory);
132143
+ const rootPath = resolutionHost.toPath(rootDir);
132144
+ const rootPathComponents = getPathComponents(rootPath);
132145
+ const isRootWatchable = canWatchDirectoryOrFile(rootPathComponents);
132146
+ const isSymlinkCache = /* @__PURE__ */ new Map();
132147
+ const packageDirWatchers = /* @__PURE__ */ new Map();
132148
+ const dirPathToSymlinkPackageRefCount = /* @__PURE__ */ new Map();
133330
132149
  const typeRootsWatches = /* @__PURE__ */ new Map();
133331
- const cache = {
133332
- resolutionHost,
133333
- sharedCache,
132150
+ return {
133334
132151
  rootDirForResolution,
133335
132152
  resolvedModuleNames,
133336
132153
  resolvedTypeReferenceDirectives,
133337
132154
  resolvedLibraries,
133338
- moduleResolutionCache,
133339
- typeReferenceDirectiveResolutionCache,
133340
- libraryResolutionCache,
133341
- filesReferencingResolution,
133342
- typeRootsWatches,
133343
- countResolutionsResolvedWithGlobalCache: () => resolutionsResolvedWithGlobalCache,
133344
- countResolutionsResolvedWithoutGlobalCache: () => resolutionsResolvedWithoutGlobalCache,
133345
- watchResolution,
132155
+ resolvedFileToResolution,
132156
+ resolutionsWithFailedLookups,
132157
+ resolutionsWithOnlyAffectingLocations,
132158
+ directoryWatchesOfFailedLookups,
132159
+ fileWatchesOfAffectingLocations,
132160
+ packageDirWatchers,
132161
+ dirPathToSymlinkPackageRefCount,
132162
+ watchFailedLookupLocationsOfExternalModuleResolutions,
132163
+ getModuleResolutionCache: () => moduleResolutionCache,
132164
+ startRecordingFilesWithChangedResolutions,
132165
+ finishRecordingFilesWithChangedResolutions,
133346
132166
  // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
133347
132167
  // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
133348
132168
  startCachingPerDirectoryResolution,
133349
132169
  finishCachingPerDirectoryResolution,
133350
- compactCaches,
133351
132170
  resolveModuleNameLiterals,
133352
132171
  resolveTypeReferenceDirectiveReferences,
133353
- onReusedModuleResolutions,
133354
- onReusedTypeReferenceDirectiveResolutions,
133355
- onSourceFileNotCreated,
133356
132172
  resolveLibrary: resolveLibrary2,
133357
132173
  resolveSingleModuleNameWithoutWatching,
133358
132174
  removeResolutionsFromProjectReferenceRedirects,
@@ -133360,72 +132176,37 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133360
132176
  hasChangedAutomaticTypeDirectiveNames: () => hasChangedAutomaticTypeDirectiveNames,
133361
132177
  invalidateResolutionOfFile,
133362
132178
  invalidateResolutionsOfFailedLookupLocations,
133363
- invalidateResolutionsWithGlobalCachePass,
133364
- invalidateResolutionsWithoutGlobalCachePass,
133365
- invalidateUnresolvedResolutionsWithGlobalCachePass,
132179
+ setFilesWithInvalidatedNonRelativeUnresolvedImports,
133366
132180
  createHasInvalidatedResolutions,
132181
+ isFileWithInvalidatedNonRelativeUnresolvedImports,
133367
132182
  updateTypeRootsWatch,
133368
132183
  closeTypeRootsWatch,
133369
132184
  clear: clear2,
133370
- onChangesAffectModuleResolution,
133371
- // Used by shared cache
133372
- getRootDirInfoForResolution: maybeBind(resolutionHost, resolutionHost.getRootDirInfoForResolution) ?? getRootDirInfoOfRedirectedReference,
133373
- invalidateAffectingFileWatcher,
133374
- invalidateResolution,
133375
- invalidateTypeRoot,
133376
- getValidResolution
132185
+ onChangesAffectModuleResolution
133377
132186
  };
133378
- return cache;
133379
- function getRootDirInfo(rootDirForResolution2) {
133380
- const rootDir = getRootDirectoryOfResolutionCache(rootDirForResolution2, getCurrentDirectory);
133381
- const rootPath = resolutionHost.toPath(rootDir);
133382
- const rootPathComponents = getPathComponents(rootPath);
133383
- return {
133384
- rootDir,
133385
- rootPath,
133386
- rootPathComponents,
133387
- canWatch: canWatchDirectoryOrFile(rootPathComponents)
133388
- };
133389
- }
133390
- function getRootDirInfoOfRedirectedReference(redirectedReference) {
133391
- if (!redirectedReference) return rootDirInfo;
133392
- let result = redirectsToRootDirInfo.get(redirectedReference);
133393
- if (!result) {
133394
- redirectsToRootDirInfo.set(
133395
- redirectedReference,
133396
- result = getRootDirInfo(
133397
- getDirectoryPath(redirectedReference.sourceFile.fileName)
133398
- )
133399
- );
133400
- }
133401
- return result;
133402
- }
133403
- function cleanupRedirectRootDirInfo(newProgram) {
133404
- const toDeleteRedirectToRootDirInfo = new Set(redirectsToRootDirInfo.keys());
133405
- newProgram == null ? void 0 : newProgram.forEachResolvedProjectReference((redirect) => {
133406
- toDeleteRedirectToRootDirInfo.delete(redirect);
133407
- });
133408
- toDeleteRedirectToRootDirInfo.forEach((redirect) => redirectsToRootDirInfo.delete(redirect));
133409
- }
133410
132187
  function clear2() {
133411
- pendingRemoveResolutionsOfFile = void 0;
133412
- potentiallyUnreferencedResolutions = void 0;
133413
- newUnresolvedResolutionCachePassResolutions = void 0;
133414
- redirectsToRootDirInfo.clear();
132188
+ clearMap(directoryWatchesOfFailedLookups, closeFileWatcherOf);
132189
+ clearMap(fileWatchesOfAffectingLocations, closeFileWatcherOf);
132190
+ isSymlinkCache.clear();
132191
+ packageDirWatchers.clear();
132192
+ dirPathToSymlinkPackageRefCount.clear();
132193
+ nonRelativeExternalModuleResolutions.clear();
133415
132194
  closeTypeRootsWatch();
133416
- sharedCache.clear(cache);
133417
132195
  resolvedModuleNames.clear();
133418
132196
  resolvedTypeReferenceDirectives.clear();
133419
- filesReferencingResolution.clear();
133420
- resolutionsResolvedWithGlobalCache = 0;
133421
- resolutionsResolvedWithoutGlobalCache = 0;
132197
+ resolvedFileToResolution.clear();
132198
+ resolutionsWithFailedLookups.clear();
132199
+ resolutionsWithOnlyAffectingLocations.clear();
132200
+ failedLookupChecks = void 0;
132201
+ startsWithPathChecks = void 0;
132202
+ isInDirectoryChecks = void 0;
132203
+ affectingPathChecks = void 0;
133422
132204
  affectingPathChecksForFile = void 0;
133423
132205
  allModuleAndTypeResolutionsAreInvalidated = false;
133424
- resolutionsWithGlobalCachePassAreInvalidated = false;
133425
- resolutionsWithoutGlobalCachePassAreInvalidated = false;
133426
- unresolvedResolutionsWithGlobalCachePassAreInvalidated = false;
133427
132206
  moduleResolutionCache.clear();
133428
132207
  typeReferenceDirectiveResolutionCache.clear();
132208
+ moduleResolutionCache.update(resolutionHost.getCompilationSettings());
132209
+ typeReferenceDirectiveResolutionCache.update(resolutionHost.getCompilationSettings());
133429
132210
  libraryResolutionCache.clear();
133430
132211
  impliedFormatPackageJsons.clear();
133431
132212
  resolvedLibraries.clear();
@@ -133433,28 +132214,48 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133433
132214
  }
133434
132215
  function onChangesAffectModuleResolution() {
133435
132216
  allModuleAndTypeResolutionsAreInvalidated = true;
132217
+ moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
132218
+ typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
132219
+ moduleResolutionCache.update(resolutionHost.getCompilationSettings());
132220
+ typeReferenceDirectiveResolutionCache.update(resolutionHost.getCompilationSettings());
132221
+ }
132222
+ function startRecordingFilesWithChangedResolutions() {
132223
+ filesWithChangedSetOfUnresolvedImports = [];
132224
+ }
132225
+ function finishRecordingFilesWithChangedResolutions() {
132226
+ const collected = filesWithChangedSetOfUnresolvedImports;
132227
+ filesWithChangedSetOfUnresolvedImports = void 0;
132228
+ return collected;
132229
+ }
132230
+ function isFileWithInvalidatedNonRelativeUnresolvedImports(path) {
132231
+ if (!filesWithInvalidatedNonRelativeUnresolvedImports) {
132232
+ return false;
132233
+ }
132234
+ const value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
132235
+ return !!value && !!value.length;
133436
132236
  }
133437
132237
  function createHasInvalidatedResolutions(customHasInvalidatedResolutions, customHasInvalidatedLibResolutions) {
133438
132238
  invalidateResolutionsOfFailedLookupLocations();
133439
132239
  const collected = filesWithInvalidatedResolutions;
133440
132240
  filesWithInvalidatedResolutions = void 0;
133441
132241
  return {
133442
- hasInvalidatedResolutions: (path) => customHasInvalidatedResolutions(path) || allModuleAndTypeResolutionsAreInvalidated || resolutionsWithGlobalCachePassAreInvalidated || resolutionsWithoutGlobalCachePassAreInvalidated || unresolvedResolutionsWithGlobalCachePassAreInvalidated || !!(collected == null ? void 0 : collected.has(path)),
132242
+ hasInvalidatedResolutions: (path) => customHasInvalidatedResolutions(path) || allModuleAndTypeResolutionsAreInvalidated || !!(collected == null ? void 0 : collected.has(path)) || isFileWithInvalidatedNonRelativeUnresolvedImports(path),
133443
132243
  hasInvalidatedLibResolutions: (libFileName) => {
133444
132244
  var _a;
133445
- return customHasInvalidatedLibResolutions(libFileName) || !!((_a = sharedCache.watchedResolutionInfoMap.get(resolvedLibraries == null ? void 0 : resolvedLibraries.get(libFileName))) == null ? void 0 : _a.isInvalidated);
132245
+ return customHasInvalidatedLibResolutions(libFileName) || !!((_a = resolvedLibraries == null ? void 0 : resolvedLibraries.get(libFileName)) == null ? void 0 : _a.isInvalidated);
133446
132246
  }
133447
132247
  };
133448
132248
  }
133449
- function startCachingPerDirectoryResolution(options) {
132249
+ function startCachingPerDirectoryResolution() {
133450
132250
  moduleResolutionCache.isReadonly = void 0;
133451
132251
  typeReferenceDirectiveResolutionCache.isReadonly = void 0;
133452
132252
  libraryResolutionCache.isReadonly = void 0;
133453
- moduleResolutionCache.update(options ?? resolutionHost.getCompilationSettings());
133454
- typeReferenceDirectiveResolutionCache.update(options ?? resolutionHost.getCompilationSettings());
133455
- sharedCache.startCachingPerDirectoryResolution(cache);
133456
- pendingRemoveResolutionsOfFile == null ? void 0 : pendingRemoveResolutionsOfFile.forEach((path) => removeResolutionsOfFile(path));
133457
- pendingRemoveResolutionsOfFile = void 0;
132253
+ moduleResolutionCache.getPackageJsonInfoCache().isReadonly = void 0;
132254
+ moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
132255
+ typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
132256
+ libraryResolutionCache.clearAllExceptPackageJsonInfoCache();
132257
+ watchFailedLookupLocationOfNonRelativeModuleResolutions();
132258
+ isSymlinkCache.clear();
133458
132259
  }
133459
132260
  function cleanupLibResolutionWatching(newProgram) {
133460
132261
  resolvedLibraries.forEach((resolution, libFileName) => {
@@ -133463,35 +132264,32 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133463
132264
  stopWatchFailedLookupLocationOfResolution(
133464
132265
  resolution,
133465
132266
  resolutionHost.toPath(getInferredLibraryNameResolveFrom(resolutionHost.getCompilationSettings(), getCurrentDirectory(), libFileName)),
133466
- libraryResolutionCache
132267
+ getResolvedModuleFromResolution
133467
132268
  );
133468
132269
  resolvedLibraries.delete(libFileName);
133469
132270
  }
133470
132271
  });
133471
132272
  }
133472
- function finishCachingPerDirectoryResolution(newProgram, oldProgram, skipCacheCompact) {
132273
+ function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
132274
+ filesWithInvalidatedNonRelativeUnresolvedImports = void 0;
133473
132275
  allModuleAndTypeResolutionsAreInvalidated = false;
133474
- resolutionsWithGlobalCachePassAreInvalidated = false;
133475
- resolutionsWithoutGlobalCachePassAreInvalidated = false;
133476
- unresolvedResolutionsWithGlobalCachePassAreInvalidated = false;
133477
- newUnresolvedResolutionCachePassResolutions = void 0;
133478
- let potentiallyUnReferencedFileWatcherOfAffectingLocation;
132276
+ watchFailedLookupLocationOfNonRelativeModuleResolutions();
133479
132277
  if (newProgram !== oldProgram) {
133480
- const releaseFileWatcherOfAffectingLocation = (location) => {
133481
- sharedCache.releaseFileWatcherOfAffectingLocation(location);
133482
- (potentiallyUnReferencedFileWatcherOfAffectingLocation ?? (potentiallyUnReferencedFileWatcherOfAffectingLocation = /* @__PURE__ */ new Set())).add(location);
133483
- };
133484
132278
  cleanupLibResolutionWatching(newProgram);
133485
132279
  newProgram == null ? void 0 : newProgram.getSourceFiles().forEach((newFile) => {
133486
132280
  var _a;
133487
132281
  const expected = ((_a = newFile.packageJsonLocations) == null ? void 0 : _a.length) ?? 0;
133488
132282
  const existing = impliedFormatPackageJsons.get(newFile.resolvedPath) ?? emptyArray;
133489
132283
  for (let i = existing.length; i < expected; i++) {
133490
- sharedCache.createFileWatcherOfAffectingLocation(newFile.packageJsonLocations[i]);
132284
+ createFileWatcherOfAffectingLocation(
132285
+ newFile.packageJsonLocations[i],
132286
+ /*forResolution*/
132287
+ false
132288
+ );
133491
132289
  }
133492
132290
  if (existing.length > expected) {
133493
132291
  for (let i = expected; i < existing.length; i++) {
133494
- releaseFileWatcherOfAffectingLocation(existing[i]);
132292
+ fileWatchesOfAffectingLocations.get(existing[i]).files--;
133495
132293
  }
133496
132294
  }
133497
132295
  if (expected) impliedFormatPackageJsons.set(newFile.resolvedPath, newFile.packageJsonLocations);
@@ -133500,68 +132298,38 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133500
132298
  impliedFormatPackageJsons.forEach((existing, path) => {
133501
132299
  const newFile = newProgram == null ? void 0 : newProgram.getSourceFileByPath(path);
133502
132300
  if (!newFile || newFile.resolvedPath !== path) {
133503
- existing.forEach(releaseFileWatcherOfAffectingLocation);
132301
+ existing.forEach((location) => fileWatchesOfAffectingLocations.get(location).files--);
133504
132302
  impliedFormatPackageJsons.delete(path);
133505
132303
  }
133506
132304
  });
133507
- cleanupRedirectRootDirInfo(newProgram);
133508
- }
133509
- potentiallyUnReferencedFileWatcherOfAffectingLocation == null ? void 0 : potentiallyUnReferencedFileWatcherOfAffectingLocation.forEach((location) => sharedCache.closeFileWatcherOfAffectingLocation(location));
133510
- potentiallyUnReferencedFileWatcherOfAffectingLocation = void 0;
133511
- if (potentiallyUnreferencedResolutions) {
133512
- potentiallyUnreferencedResolutions.forEach(gcModuleOrTypeRefCache);
133513
- potentiallyUnreferencedResolutions = void 0;
133514
132305
  }
133515
- sharedCache.finishCachingPerDirectoryResolution();
132306
+ directoryWatchesOfFailedLookups.forEach(closeDirectoryWatchesOfFailedLookup);
132307
+ fileWatchesOfAffectingLocations.forEach(closeFileWatcherOfAffectingLocation);
132308
+ packageDirWatchers.forEach(closePackageDirWatcher);
133516
132309
  hasChangedAutomaticTypeDirectiveNames = false;
133517
- if (!skipCacheCompact) compactCaches(newProgram);
133518
132310
  moduleResolutionCache.isReadonly = true;
133519
132311
  typeReferenceDirectiveResolutionCache.isReadonly = true;
133520
132312
  libraryResolutionCache.isReadonly = true;
133521
132313
  moduleResolutionCache.getPackageJsonInfoCache().isReadonly = true;
132314
+ isSymlinkCache.clear();
133522
132315
  }
133523
- function compactCaches(newProgram) {
133524
- const availableOptions = /* @__PURE__ */ new Set();
133525
- if (newProgram) {
133526
- availableOptions.add(newProgram.getCompilerOptions());
133527
- newProgram.forEachResolvedProjectReference((ref) => {
133528
- availableOptions.add(ref.commandLine.options);
133529
- });
132316
+ function closePackageDirWatcher(watcher, packageDirPath) {
132317
+ if (watcher.dirPathToWatcher.size === 0) {
132318
+ packageDirWatchers.delete(packageDirPath);
133530
132319
  }
133531
- moduleResolutionCache.compact(
133532
- availableOptions,
133533
- /*skipOptionsToRedirectsKeyCleanup*/
133534
- true
133535
- );
133536
- typeReferenceDirectiveResolutionCache.compact(availableOptions);
133537
- libraryResolutionCache.compact();
133538
- sharedCache.compactCaches(availableOptions, cache);
133539
132320
  }
133540
- function gcModuleOrTypeRefCache(setOfResolutions, cache2) {
133541
- let needsGc = false;
133542
- setOfResolutions.forEach((resolution) => needsGc = releaseResolution(resolution, cache2) || needsGc);
133543
- if (needsGc) {
133544
- considerNonWatchedResolutionAsInvalidated = true;
133545
- cache2.gc(filesReferencingResolution);
133546
- considerNonWatchedResolutionAsInvalidated = false;
132321
+ function closeDirectoryWatchesOfFailedLookup(watcher, path) {
132322
+ if (watcher.refCount === 0) {
132323
+ directoryWatchesOfFailedLookups.delete(path);
132324
+ watcher.watcher.close();
133547
132325
  }
133548
132326
  }
133549
- function onSourceFileNotCreated(sourceFileOptions) {
133550
- var _a;
133551
- (_a = sourceFileOptions.packageJsonLocations) == null ? void 0 : _a.forEach((location) => sharedCache.addToPotentiallyUnwatchedPackageJsons(location));
133552
- }
133553
- function getValidResolution(resolution) {
133554
- return isInvalidatedResolution(resolution) ? void 0 : resolution;
133555
- }
133556
- function isInvalidatedResolution(resolution) {
132327
+ function closeFileWatcherOfAffectingLocation(watcher, path) {
133557
132328
  var _a;
133558
- if (!resolution || considerNonWatchedResolutionAsInvalidated && !filesReferencingResolution.has(resolution) || ((_a = sharedCache.watchedResolutionInfoMap.get(resolution)) == null ? void 0 : _a.isInvalidated) || resolutionsWithGlobalCachePassAreInvalidated && isResolvedWithGlobalCachePass(resolution) || resolutionsWithoutGlobalCachePassAreInvalidated && isResolvedWithoutGlobalCachePass(resolution)) return true;
133559
- if ((newUnresolvedResolutionCachePassResolutions == null ? void 0 : newUnresolvedResolutionCachePassResolutions.has(resolution)) || !isInvalidatedUnResolvedGlobalCachePassResolution(resolution)) return false;
133560
- sharedCache.invalidateResolution(resolution, returnTrue);
133561
- return true;
133562
- }
133563
- function isInvalidatedUnResolvedGlobalCachePassResolution(resolution) {
133564
- return unresolvedResolutionsWithGlobalCachePassAreInvalidated && isResolvedWithGlobalCachePassButStillUnresolved(resolution);
132329
+ if (watcher.files === 0 && watcher.resolutions === 0 && !((_a = watcher.symlinks) == null ? void 0 : _a.size)) {
132330
+ fileWatchesOfAffectingLocations.delete(path);
132331
+ watcher.watcher.close();
132332
+ }
133565
132333
  }
133566
132334
  function resolveNamesWithLocalCache({
133567
132335
  entries,
@@ -133570,15 +132338,17 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133570
132338
  redirectedReference,
133571
132339
  options,
133572
132340
  perFileCache,
133573
- moduleOrTypeRefCache,
133574
132341
  reusedNames,
133575
132342
  loader,
133576
132343
  getResolutionWithResolvedFileName,
133577
- onNewResolution
132344
+ deferWatchingNonRelativeResolution,
132345
+ shouldRetryResolution,
132346
+ logChanges
133578
132347
  }) {
133579
132348
  const path = resolutionHost.toPath(containingFile);
133580
132349
  const resolutionsInFile = perFileCache.get(path) || perFileCache.set(path, createModeAwareCache()).get(path);
133581
132350
  const resolvedModules = [];
132351
+ const hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
133582
132352
  const program = resolutionHost.getCurrentProgram();
133583
132353
  const oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
133584
132354
  const unmatchedRedirects = oldRedirect ? !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path : !!redirectedReference;
@@ -133587,7 +132357,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133587
132357
  const name = loader.nameAndMode.getName(entry);
133588
132358
  const mode = loader.nameAndMode.getMode(entry, containingSourceFile, (redirectedReference == null ? void 0 : redirectedReference.commandLine.options) || options);
133589
132359
  let resolution = resolutionsInFile.get(name, mode);
133590
- if (!seenNamesInFile.has(name, mode) && (allModuleAndTypeResolutionsAreInvalidated || unmatchedRedirects || isInvalidatedResolution(resolution))) {
132360
+ if (!seenNamesInFile.has(name, mode) && (allModuleAndTypeResolutionsAreInvalidated || unmatchedRedirects || !resolution || resolution.isInvalidated || // If the name is unresolved import that was invalidated, recalculate
132361
+ hasInvalidatedNonRelativeUnresolvedImport && !isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
133591
132362
  const existingResolution = resolution;
133592
132363
  resolution = loader.resolve(name, mode);
133593
132364
  if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
@@ -133595,15 +132366,15 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133595
132366
  }
133596
132367
  resolutionsInFile.set(name, mode, resolution);
133597
132368
  if (resolution !== existingResolution) {
133598
- watchResolution(resolution, path, getResolutionWithResolvedFileName, redirectedReference);
132369
+ watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName, deferWatchingNonRelativeResolution);
133599
132370
  if (existingResolution) {
133600
- stopWatchFailedLookupLocationOfResolution(existingResolution, path, moduleOrTypeRefCache);
132371
+ stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
133601
132372
  }
133602
132373
  }
133603
- if (isInvalidatedUnResolvedGlobalCachePassResolution(resolution)) {
133604
- (newUnresolvedResolutionCachePassResolutions ?? (newUnresolvedResolutionCachePassResolutions = /* @__PURE__ */ new Set())).add(resolution);
132374
+ if (logChanges && filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) {
132375
+ filesWithChangedSetOfUnresolvedImports.push(path);
132376
+ logChanges = false;
133605
132377
  }
133606
- onNewResolution == null ? void 0 : onNewResolution(existingResolution, resolution, path, name, mode);
133607
132378
  } else {
133608
132379
  const host = getModuleResolutionHost(resolutionHost);
133609
132380
  if (isTraceEnabled(options, host) && !seenNamesInFile.has(name, mode)) {
@@ -133618,76 +132389,43 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133618
132389
  );
133619
132390
  }
133620
132391
  }
133621
- Debug.assert(resolution !== void 0 && !sharedCache.watchedResolutionInfoMap.get(resolution).isInvalidated);
132392
+ Debug.assert(resolution !== void 0 && !resolution.isInvalidated);
133622
132393
  seenNamesInFile.set(name, mode, true);
133623
132394
  resolvedModules.push(resolution);
133624
132395
  }
133625
- onReusedResolutions({
133626
- reusedNames,
133627
- containingSourceFile,
133628
- redirectedReference,
133629
- options,
133630
- path,
133631
- resolutionsInFile,
133632
- seenNamesInFile,
133633
- nameAndModeGetter: loader.nameAndMode,
133634
- moduleOrTypeRefCache
133635
- });
133636
- return resolvedModules;
133637
- }
133638
- function onReusedResolutions({
133639
- reusedNames,
133640
- containingSourceFile,
133641
- redirectedReference,
133642
- options,
133643
- path,
133644
- resolutionsInFile,
133645
- seenNamesInFile,
133646
- nameAndModeGetter,
133647
- moduleOrTypeRefCache
133648
- }) {
133649
- if (!resolutionsInFile) return;
133650
- if (!seenNamesInFile) seenNamesInFile = createModeAwareCache();
133651
132396
  reusedNames == null ? void 0 : reusedNames.forEach(
133652
132397
  (entry) => seenNamesInFile.set(
133653
- nameAndModeGetter.getName(entry),
133654
- nameAndModeGetter.getMode(entry, containingSourceFile, (redirectedReference == null ? void 0 : redirectedReference.commandLine.options) || options),
132398
+ loader.nameAndMode.getName(entry),
132399
+ loader.nameAndMode.getMode(entry, containingSourceFile, (redirectedReference == null ? void 0 : redirectedReference.commandLine.options) || options),
133655
132400
  true
133656
132401
  )
133657
132402
  );
133658
132403
  if (resolutionsInFile.size() !== seenNamesInFile.size()) {
133659
132404
  resolutionsInFile.forEach((resolution, name, mode) => {
133660
132405
  if (!seenNamesInFile.has(name, mode)) {
133661
- stopWatchFailedLookupLocationOfResolution(resolution, path, moduleOrTypeRefCache);
132406
+ stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
133662
132407
  resolutionsInFile.delete(name, mode);
133663
132408
  }
133664
132409
  });
133665
132410
  }
133666
- }
133667
- function onReusedModuleResolutions(reusedNames, containingSourceFile, redirectedReference, options) {
133668
- onReusedResolutions({
133669
- reusedNames,
133670
- containingSourceFile,
133671
- redirectedReference,
133672
- options,
133673
- path: containingSourceFile.path,
133674
- resolutionsInFile: resolvedModuleNames.get(containingSourceFile.path),
133675
- nameAndModeGetter: moduleResolutionNameAndModeGetter,
133676
- moduleOrTypeRefCache: moduleResolutionCache
133677
- });
133678
- }
133679
- function onReusedTypeReferenceDirectiveResolutions(reusedNames, containingSourceFile, redirectedReference, options) {
133680
- const path = containingSourceFile ? containingSourceFile.path : resolutionHost.toPath(getAutomaticTypeDirectiveContainingFile(resolutionHost.getCompilationSettings(), getCurrentDirectory()));
133681
- onReusedResolutions({
133682
- reusedNames,
133683
- containingSourceFile,
133684
- redirectedReference,
133685
- options,
133686
- path,
133687
- resolutionsInFile: resolvedTypeReferenceDirectives.get(path),
133688
- nameAndModeGetter: typeReferenceResolutionNameAndModeGetter,
133689
- moduleOrTypeRefCache: typeReferenceDirectiveResolutionCache
133690
- });
132411
+ return resolvedModules;
132412
+ function resolutionIsEqualTo(oldResolution, newResolution) {
132413
+ if (oldResolution === newResolution) {
132414
+ return true;
132415
+ }
132416
+ if (!oldResolution || !newResolution) {
132417
+ return false;
132418
+ }
132419
+ const oldResult = getResolutionWithResolvedFileName(oldResolution);
132420
+ const newResult = getResolutionWithResolvedFileName(newResolution);
132421
+ if (oldResult === newResult) {
132422
+ return true;
132423
+ }
132424
+ if (!oldResult || !newResult) {
132425
+ return false;
132426
+ }
132427
+ return oldResult.resolvedFileName === newResult.resolvedFileName;
132428
+ }
133691
132429
  }
133692
132430
  function resolveTypeReferenceDirectiveReferences(typeDirectiveReferences, containingFile, redirectedReference, options, containingSourceFile, reusedNames) {
133693
132431
  return resolveNamesWithLocalCache({
@@ -133698,7 +132436,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133698
132436
  options,
133699
132437
  reusedNames,
133700
132438
  perFileCache: resolvedTypeReferenceDirectives,
133701
- moduleOrTypeRefCache: typeReferenceDirectiveResolutionCache,
133702
132439
  loader: createTypeReferenceResolutionLoader(
133703
132440
  containingFile,
133704
132441
  redirectedReference,
@@ -133706,10 +132443,12 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133706
132443
  getModuleResolutionHost(resolutionHost),
133707
132444
  typeReferenceDirectiveResolutionCache
133708
132445
  ),
133709
- getResolutionWithResolvedFileName: getResolvedTypeReferenceDirectiveFromResolution
132446
+ getResolutionWithResolvedFileName: getResolvedTypeReferenceDirectiveFromResolution,
132447
+ shouldRetryResolution: (resolution) => resolution.resolvedTypeReferenceDirective === void 0,
132448
+ deferWatchingNonRelativeResolution: false
133710
132449
  });
133711
132450
  }
133712
- function resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options, containingSourceFile, reusedNames, onNewResolution) {
132451
+ function resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options, containingSourceFile, reusedNames) {
133713
132452
  return resolveNamesWithLocalCache({
133714
132453
  entries: moduleLiterals,
133715
132454
  containingFile,
@@ -133718,7 +132457,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133718
132457
  options,
133719
132458
  reusedNames,
133720
132459
  perFileCache: resolvedModuleNames,
133721
- moduleOrTypeRefCache: moduleResolutionCache,
133722
132460
  loader: createModuleResolutionLoaderUsingGlobalCache(
133723
132461
  containingFile,
133724
132462
  redirectedReference,
@@ -133727,26 +132465,30 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133727
132465
  moduleResolutionCache
133728
132466
  ),
133729
132467
  getResolutionWithResolvedFileName: getResolvedModuleFromResolution,
133730
- onNewResolution
132468
+ shouldRetryResolution: (resolution) => !resolution.resolvedModule || !resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension),
132469
+ logChanges: logChangesWhenResolvingModule,
132470
+ deferWatchingNonRelativeResolution: true
132471
+ // Defer non relative resolution watch because we could be using ambient modules
133731
132472
  });
133732
132473
  }
133733
132474
  function resolveLibrary2(libraryName, resolveFrom, options, libFileName) {
133734
132475
  const host = getModuleResolutionHost(resolutionHost);
133735
132476
  let resolution = resolvedLibraries == null ? void 0 : resolvedLibraries.get(libFileName);
133736
- if (isInvalidatedResolution(resolution)) {
132477
+ if (!resolution || resolution.isInvalidated) {
133737
132478
  const existingResolution = resolution;
133738
132479
  resolution = resolveLibrary(libraryName, resolveFrom, options, host, libraryResolutionCache);
133739
132480
  const path = resolutionHost.toPath(resolveFrom);
133740
- watchResolution(
132481
+ watchFailedLookupLocationsOfExternalModuleResolutions(
132482
+ libraryName,
133741
132483
  resolution,
133742
132484
  path,
133743
132485
  getResolvedModuleFromResolution,
133744
- /*redirectedReference*/
133745
- void 0
132486
+ /*deferWatchingNonRelativeResolution*/
132487
+ false
133746
132488
  );
133747
132489
  resolvedLibraries.set(libFileName, resolution);
133748
132490
  if (existingResolution) {
133749
- stopWatchFailedLookupLocationOfResolution(existingResolution, path, libraryResolutionCache);
132491
+ stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolvedModuleFromResolution);
133750
132492
  }
133751
132493
  } else {
133752
132494
  if (isTraceEnabled(options, host)) {
@@ -133772,7 +132514,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133772
132514
  /*mode*/
133773
132515
  void 0
133774
132516
  );
133775
- if (resolution && !sharedCache.watchedResolutionInfoMap.get(resolution).isInvalidated) return resolution;
132517
+ if (resolution && !resolution.isInvalidated) return resolution;
133776
132518
  const data = (_a = resolutionHost.beforeResolveSingleModuleNameWithoutWatching) == null ? void 0 : _a.call(resolutionHost, moduleResolutionCache);
133777
132519
  const host = getModuleResolutionHost(resolutionHost);
133778
132520
  const result = resolveModuleName(
@@ -133785,48 +132527,306 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133785
132527
  (_b = resolutionHost.afterResolveSingleModuleNameWithoutWatching) == null ? void 0 : _b.call(resolutionHost, moduleResolutionCache, moduleName, containingFile, result, data);
133786
132528
  return result;
133787
132529
  }
133788
- function watchResolution(resolution, filePath, getResolutionWithResolvedFileName, redirectedReference) {
133789
- let files = filesReferencingResolution.get(resolution);
133790
- if (!files) {
133791
- filesReferencingResolution.set(resolution, files = /* @__PURE__ */ new Set([filePath]));
133792
- if (isResolvedWithGlobalCachePass(resolution)) resolutionsResolvedWithGlobalCache++;
133793
- else if (isResolvedWithoutGlobalCachePass(resolution)) resolutionsResolvedWithoutGlobalCache++;
133794
- } else {
133795
- files.add(filePath);
133796
- }
133797
- sharedCache.watchResolution(resolution, getResolutionWithResolvedFileName, redirectedReference);
133798
- }
133799
- function invalidateAffectingFileWatcher(path) {
133800
- (affectingPathChecksForFile ?? (affectingPathChecksForFile = /* @__PURE__ */ new Set())).add(path);
133801
- }
133802
- function stopWatchFailedLookupLocationOfResolution(resolution, filePath, cache2) {
133803
- const files = filesReferencingResolution.get(resolution);
133804
- files.delete(filePath);
133805
- if (files.size) return;
133806
- let setOfResolutions = potentiallyUnreferencedResolutions == null ? void 0 : potentiallyUnreferencedResolutions.get(cache2);
133807
- if (!setOfResolutions) (potentiallyUnreferencedResolutions ?? (potentiallyUnreferencedResolutions = /* @__PURE__ */ new Map())).set(cache2, setOfResolutions = /* @__PURE__ */ new Set());
133808
- setOfResolutions.add(resolution);
133809
- }
133810
- function releaseResolution(resolution, moduleOrTypeRefCache) {
133811
- const files = filesReferencingResolution.get(resolution);
133812
- if (files.size) return false;
133813
- filesReferencingResolution.delete(resolution);
133814
- if (isResolvedWithGlobalCachePass(resolution)) resolutionsResolvedWithGlobalCache--;
133815
- else if (isResolvedWithoutGlobalCachePass(resolution)) resolutionsResolvedWithoutGlobalCache--;
133816
- sharedCache.releaseResolution(resolution, moduleOrTypeRefCache);
133817
- return true;
132530
+ function isNodeModulesAtTypesDirectory(dirPath) {
132531
+ return endsWith(dirPath, "/node_modules/@types");
132532
+ }
132533
+ function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName, deferWatchingNonRelativeResolution) {
132534
+ (resolution.files ?? (resolution.files = /* @__PURE__ */ new Set())).add(filePath);
132535
+ if (resolution.files.size !== 1) return;
132536
+ if (!deferWatchingNonRelativeResolution || isExternalModuleNameRelative(name)) {
132537
+ watchFailedLookupLocationOfResolution(resolution);
132538
+ } else {
132539
+ nonRelativeExternalModuleResolutions.add(resolution);
132540
+ }
132541
+ const resolved = getResolutionWithResolvedFileName(resolution);
132542
+ if (resolved && resolved.resolvedFileName) {
132543
+ const key = resolutionHost.toPath(resolved.resolvedFileName);
132544
+ let resolutions = resolvedFileToResolution.get(key);
132545
+ if (!resolutions) resolvedFileToResolution.set(key, resolutions = /* @__PURE__ */ new Set());
132546
+ resolutions.add(resolution);
132547
+ }
132548
+ }
132549
+ function watchFailedLookupLocation(failedLookupLocation, setAtRoot) {
132550
+ const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
132551
+ const toWatch = getDirectoryToWatchFailedLookupLocation(
132552
+ failedLookupLocation,
132553
+ failedLookupLocationPath,
132554
+ rootDir,
132555
+ rootPath,
132556
+ rootPathComponents,
132557
+ isRootWatchable,
132558
+ getCurrentDirectory,
132559
+ resolutionHost.preferNonRecursiveWatch
132560
+ );
132561
+ if (toWatch) {
132562
+ const { dir, dirPath, nonRecursive, packageDir, packageDirPath } = toWatch;
132563
+ if (dirPath === rootPath) {
132564
+ Debug.assert(nonRecursive);
132565
+ Debug.assert(!packageDir);
132566
+ setAtRoot = true;
132567
+ } else {
132568
+ setDirectoryWatcher(dir, dirPath, packageDir, packageDirPath, nonRecursive);
132569
+ }
132570
+ }
132571
+ return setAtRoot;
132572
+ }
132573
+ function watchFailedLookupLocationOfResolution(resolution) {
132574
+ var _a;
132575
+ Debug.assert(!!((_a = resolution.files) == null ? void 0 : _a.size));
132576
+ const { failedLookupLocations, affectingLocations, alternateResult } = resolution;
132577
+ if (!(failedLookupLocations == null ? void 0 : failedLookupLocations.length) && !(affectingLocations == null ? void 0 : affectingLocations.length) && !alternateResult) return;
132578
+ if ((failedLookupLocations == null ? void 0 : failedLookupLocations.length) || alternateResult) resolutionsWithFailedLookups.add(resolution);
132579
+ let setAtRoot = false;
132580
+ if (failedLookupLocations) {
132581
+ for (const failedLookupLocation of failedLookupLocations) {
132582
+ setAtRoot = watchFailedLookupLocation(failedLookupLocation, setAtRoot);
132583
+ }
132584
+ }
132585
+ if (alternateResult) setAtRoot = watchFailedLookupLocation(alternateResult, setAtRoot);
132586
+ if (setAtRoot) {
132587
+ setDirectoryWatcher(
132588
+ rootDir,
132589
+ rootPath,
132590
+ /*packageDir*/
132591
+ void 0,
132592
+ /*packageDirPath*/
132593
+ void 0,
132594
+ /*nonRecursive*/
132595
+ true
132596
+ );
132597
+ }
132598
+ watchAffectingLocationsOfResolution(resolution, !(failedLookupLocations == null ? void 0 : failedLookupLocations.length) && !alternateResult);
132599
+ }
132600
+ function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
132601
+ var _a;
132602
+ Debug.assert(!!((_a = resolution.files) == null ? void 0 : _a.size));
132603
+ const { affectingLocations } = resolution;
132604
+ if (!(affectingLocations == null ? void 0 : affectingLocations.length)) return;
132605
+ if (addToResolutionsWithOnlyAffectingLocations) resolutionsWithOnlyAffectingLocations.add(resolution);
132606
+ for (const affectingLocation of affectingLocations) {
132607
+ createFileWatcherOfAffectingLocation(
132608
+ affectingLocation,
132609
+ /*forResolution*/
132610
+ true
132611
+ );
132612
+ }
132613
+ }
132614
+ function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) {
132615
+ const fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation);
132616
+ if (fileWatcher) {
132617
+ if (forResolution) fileWatcher.resolutions++;
132618
+ else fileWatcher.files++;
132619
+ return;
132620
+ }
132621
+ let locationToWatch = affectingLocation;
132622
+ let isSymlink = false;
132623
+ let symlinkWatcher;
132624
+ if (resolutionHost.realpath) {
132625
+ locationToWatch = resolutionHost.realpath(affectingLocation);
132626
+ if (affectingLocation !== locationToWatch) {
132627
+ isSymlink = true;
132628
+ symlinkWatcher = fileWatchesOfAffectingLocations.get(locationToWatch);
132629
+ }
132630
+ }
132631
+ const resolutions = forResolution ? 1 : 0;
132632
+ const files = forResolution ? 0 : 1;
132633
+ if (!isSymlink || !symlinkWatcher) {
132634
+ const watcher = {
132635
+ watcher: canWatchAffectingLocation(resolutionHost.toPath(locationToWatch)) ? resolutionHost.watchAffectingFileLocation(locationToWatch, (fileName, eventKind) => {
132636
+ cachedDirectoryStructureHost == null ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
132637
+ invalidateAffectingFileWatcher(locationToWatch, moduleResolutionCache.getPackageJsonInfoCache().getInternalMap());
132638
+ resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
132639
+ }) : noopFileWatcher,
132640
+ resolutions: isSymlink ? 0 : resolutions,
132641
+ files: isSymlink ? 0 : files,
132642
+ symlinks: void 0
132643
+ };
132644
+ fileWatchesOfAffectingLocations.set(locationToWatch, watcher);
132645
+ if (isSymlink) symlinkWatcher = watcher;
132646
+ }
132647
+ if (isSymlink) {
132648
+ Debug.assert(!!symlinkWatcher);
132649
+ const watcher = {
132650
+ watcher: {
132651
+ close: () => {
132652
+ var _a;
132653
+ const symlinkWatcher2 = fileWatchesOfAffectingLocations.get(locationToWatch);
132654
+ if (((_a = symlinkWatcher2 == null ? void 0 : symlinkWatcher2.symlinks) == null ? void 0 : _a.delete(affectingLocation)) && !symlinkWatcher2.symlinks.size && !symlinkWatcher2.resolutions && !symlinkWatcher2.files) {
132655
+ fileWatchesOfAffectingLocations.delete(locationToWatch);
132656
+ symlinkWatcher2.watcher.close();
132657
+ }
132658
+ }
132659
+ },
132660
+ resolutions,
132661
+ files,
132662
+ symlinks: void 0
132663
+ };
132664
+ fileWatchesOfAffectingLocations.set(affectingLocation, watcher);
132665
+ (symlinkWatcher.symlinks ?? (symlinkWatcher.symlinks = /* @__PURE__ */ new Set())).add(affectingLocation);
132666
+ }
132667
+ }
132668
+ function invalidateAffectingFileWatcher(path, packageJsonMap) {
132669
+ var _a;
132670
+ const watcher = fileWatchesOfAffectingLocations.get(path);
132671
+ if (watcher == null ? void 0 : watcher.resolutions) (affectingPathChecks ?? (affectingPathChecks = /* @__PURE__ */ new Set())).add(path);
132672
+ if (watcher == null ? void 0 : watcher.files) (affectingPathChecksForFile ?? (affectingPathChecksForFile = /* @__PURE__ */ new Set())).add(path);
132673
+ (_a = watcher == null ? void 0 : watcher.symlinks) == null ? void 0 : _a.forEach((path2) => invalidateAffectingFileWatcher(path2, packageJsonMap));
132674
+ packageJsonMap == null ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path));
132675
+ }
132676
+ function watchFailedLookupLocationOfNonRelativeModuleResolutions() {
132677
+ nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfResolution);
132678
+ nonRelativeExternalModuleResolutions.clear();
132679
+ }
132680
+ function createDirectoryWatcherForPackageDir(dir, dirPath, packageDir, packageDirPath, nonRecursive) {
132681
+ Debug.assert(!nonRecursive);
132682
+ let isSymlink = isSymlinkCache.get(packageDirPath);
132683
+ let packageDirWatcher = packageDirWatchers.get(packageDirPath);
132684
+ if (isSymlink === void 0) {
132685
+ const realPath2 = resolutionHost.realpath(packageDir);
132686
+ isSymlink = realPath2 !== packageDir && resolutionHost.toPath(realPath2) !== packageDirPath;
132687
+ isSymlinkCache.set(packageDirPath, isSymlink);
132688
+ if (!packageDirWatcher) {
132689
+ packageDirWatchers.set(
132690
+ packageDirPath,
132691
+ packageDirWatcher = {
132692
+ dirPathToWatcher: /* @__PURE__ */ new Map(),
132693
+ isSymlink
132694
+ }
132695
+ );
132696
+ } else if (packageDirWatcher.isSymlink !== isSymlink) {
132697
+ packageDirWatcher.dirPathToWatcher.forEach((watcher) => {
132698
+ removeDirectoryWatcher(packageDirWatcher.isSymlink ? packageDirPath : dirPath);
132699
+ watcher.watcher = createDirPathToWatcher();
132700
+ });
132701
+ packageDirWatcher.isSymlink = isSymlink;
132702
+ }
132703
+ } else {
132704
+ Debug.assertIsDefined(packageDirWatcher);
132705
+ Debug.assert(isSymlink === packageDirWatcher.isSymlink);
132706
+ }
132707
+ const forDirPath = packageDirWatcher.dirPathToWatcher.get(dirPath);
132708
+ if (forDirPath) {
132709
+ forDirPath.refCount++;
132710
+ } else {
132711
+ packageDirWatcher.dirPathToWatcher.set(dirPath, {
132712
+ watcher: createDirPathToWatcher(),
132713
+ refCount: 1
132714
+ });
132715
+ if (isSymlink) dirPathToSymlinkPackageRefCount.set(dirPath, (dirPathToSymlinkPackageRefCount.get(dirPath) ?? 0) + 1);
132716
+ }
132717
+ function createDirPathToWatcher() {
132718
+ return isSymlink ? createOrAddRefToDirectoryWatchOfFailedLookups(packageDir, packageDirPath, nonRecursive) : createOrAddRefToDirectoryWatchOfFailedLookups(dir, dirPath, nonRecursive);
132719
+ }
132720
+ }
132721
+ function setDirectoryWatcher(dir, dirPath, packageDir, packageDirPath, nonRecursive) {
132722
+ if (!packageDirPath || !resolutionHost.realpath) {
132723
+ createOrAddRefToDirectoryWatchOfFailedLookups(dir, dirPath, nonRecursive);
132724
+ } else {
132725
+ createDirectoryWatcherForPackageDir(dir, dirPath, packageDir, packageDirPath, nonRecursive);
132726
+ }
132727
+ }
132728
+ function createOrAddRefToDirectoryWatchOfFailedLookups(dir, dirPath, nonRecursive) {
132729
+ let dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
132730
+ if (dirWatcher) {
132731
+ Debug.assert(!!nonRecursive === !!dirWatcher.nonRecursive);
132732
+ dirWatcher.refCount++;
132733
+ } else {
132734
+ directoryWatchesOfFailedLookups.set(dirPath, dirWatcher = { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive });
132735
+ }
132736
+ return dirWatcher;
132737
+ }
132738
+ function stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot) {
132739
+ const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
132740
+ const toWatch = getDirectoryToWatchFailedLookupLocation(
132741
+ failedLookupLocation,
132742
+ failedLookupLocationPath,
132743
+ rootDir,
132744
+ rootPath,
132745
+ rootPathComponents,
132746
+ isRootWatchable,
132747
+ getCurrentDirectory,
132748
+ resolutionHost.preferNonRecursiveWatch
132749
+ );
132750
+ if (toWatch) {
132751
+ const { dirPath, packageDirPath } = toWatch;
132752
+ if (dirPath === rootPath) {
132753
+ removeAtRoot = true;
132754
+ } else if (packageDirPath && resolutionHost.realpath) {
132755
+ const packageDirWatcher = packageDirWatchers.get(packageDirPath);
132756
+ const forDirPath = packageDirWatcher.dirPathToWatcher.get(dirPath);
132757
+ forDirPath.refCount--;
132758
+ if (forDirPath.refCount === 0) {
132759
+ removeDirectoryWatcher(packageDirWatcher.isSymlink ? packageDirPath : dirPath);
132760
+ packageDirWatcher.dirPathToWatcher.delete(dirPath);
132761
+ if (packageDirWatcher.isSymlink) {
132762
+ const refCount = dirPathToSymlinkPackageRefCount.get(dirPath) - 1;
132763
+ if (refCount === 0) {
132764
+ dirPathToSymlinkPackageRefCount.delete(dirPath);
132765
+ } else {
132766
+ dirPathToSymlinkPackageRefCount.set(dirPath, refCount);
132767
+ }
132768
+ }
132769
+ }
132770
+ } else {
132771
+ removeDirectoryWatcher(dirPath);
132772
+ }
132773
+ }
132774
+ return removeAtRoot;
132775
+ }
132776
+ function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
132777
+ Debug.checkDefined(resolution.files).delete(filePath);
132778
+ if (resolution.files.size) return;
132779
+ resolution.files = void 0;
132780
+ const resolved = getResolutionWithResolvedFileName(resolution);
132781
+ if (resolved && resolved.resolvedFileName) {
132782
+ const key = resolutionHost.toPath(resolved.resolvedFileName);
132783
+ const resolutions = resolvedFileToResolution.get(key);
132784
+ if ((resolutions == null ? void 0 : resolutions.delete(resolution)) && !resolutions.size) resolvedFileToResolution.delete(key);
132785
+ }
132786
+ const { failedLookupLocations, affectingLocations, alternateResult } = resolution;
132787
+ if (resolutionsWithFailedLookups.delete(resolution)) {
132788
+ let removeAtRoot = false;
132789
+ if (failedLookupLocations) {
132790
+ for (const failedLookupLocation of failedLookupLocations) {
132791
+ removeAtRoot = stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot);
132792
+ }
132793
+ }
132794
+ if (alternateResult) removeAtRoot = stopWatchFailedLookupLocation(alternateResult, removeAtRoot);
132795
+ if (removeAtRoot) removeDirectoryWatcher(rootPath);
132796
+ } else if (affectingLocations == null ? void 0 : affectingLocations.length) {
132797
+ resolutionsWithOnlyAffectingLocations.delete(resolution);
132798
+ }
132799
+ if (affectingLocations) {
132800
+ for (const affectingLocation of affectingLocations) {
132801
+ const watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
132802
+ watcher.resolutions--;
132803
+ }
132804
+ }
133818
132805
  }
133819
- function removeResolutionsOfFileFromCache(cache2, filePath, moduleOrTypeRefCache) {
133820
- const resolutions = cache2.get(filePath);
132806
+ function removeDirectoryWatcher(dirPath) {
132807
+ const dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
132808
+ dirWatcher.refCount--;
132809
+ }
132810
+ function createDirectoryWatcher(directory, dirPath, nonRecursive) {
132811
+ return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, (fileOrDirectory) => {
132812
+ const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
132813
+ if (cachedDirectoryStructureHost) {
132814
+ cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
132815
+ }
132816
+ scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
132817
+ }, nonRecursive ? 0 /* None */ : 1 /* Recursive */);
132818
+ }
132819
+ function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) {
132820
+ const resolutions = cache.get(filePath);
133821
132821
  if (resolutions) {
133822
132822
  resolutions.forEach(
133823
132823
  (resolution) => stopWatchFailedLookupLocationOfResolution(
133824
132824
  resolution,
133825
132825
  filePath,
133826
- moduleOrTypeRefCache
132826
+ getResolutionWithResolvedFileName
133827
132827
  )
133828
132828
  );
133829
- cache2.delete(filePath);
132829
+ cache.delete(filePath);
133830
132830
  }
133831
132831
  }
133832
132832
  function removeResolutionsFromProjectReferenceRedirects(filePath) {
@@ -133838,62 +132838,149 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133838
132838
  resolvedProjectReference.commandLine.fileNames.forEach((f) => removeResolutionsOfFile(resolutionHost.toPath(f)));
133839
132839
  }
133840
132840
  function removeResolutionsOfFile(filePath) {
133841
- if (sharedCache.currentCache() === cache) {
133842
- removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, moduleResolutionCache);
133843
- removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, typeReferenceDirectiveResolutionCache);
133844
- } else {
133845
- (pendingRemoveResolutionsOfFile ?? (pendingRemoveResolutionsOfFile = /* @__PURE__ */ new Set())).add(filePath);
133846
- }
132841
+ removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModuleFromResolution);
132842
+ removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirectiveFromResolution);
133847
132843
  }
133848
- function invalidateResolution(resolution) {
133849
- const files = filesReferencingResolution.get(resolution);
133850
- for (const containingFilePath of files) {
133851
- (filesWithInvalidatedResolutions ?? (filesWithInvalidatedResolutions = /* @__PURE__ */ new Set())).add(containingFilePath);
133852
- hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || endsWith(containingFilePath, inferredTypesContainingFile);
133853
- }
132844
+ function invalidateResolutions(resolutions, canInvalidate) {
132845
+ if (!resolutions) return false;
132846
+ let invalidated = false;
132847
+ resolutions.forEach((resolution) => {
132848
+ if (resolution.isInvalidated || !canInvalidate(resolution)) return;
132849
+ resolution.isInvalidated = invalidated = true;
132850
+ for (const containingFilePath of Debug.checkDefined(resolution.files)) {
132851
+ (filesWithInvalidatedResolutions ?? (filesWithInvalidatedResolutions = /* @__PURE__ */ new Set())).add(containingFilePath);
132852
+ hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || endsWith(containingFilePath, inferredTypesContainingFile);
132853
+ }
132854
+ });
132855
+ return invalidated;
133854
132856
  }
133855
132857
  function invalidateResolutionOfFile(filePath) {
133856
132858
  removeResolutionsOfFile(filePath);
133857
132859
  const prevHasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
133858
- if (sharedCache.invalidateResolutionOfFile(filePath) && hasChangedAutomaticTypeDirectiveNames && !prevHasChangedAutomaticTypeDirectiveNames) {
132860
+ if (invalidateResolutions(resolvedFileToResolution.get(filePath), returnTrue) && hasChangedAutomaticTypeDirectiveNames && !prevHasChangedAutomaticTypeDirectiveNames) {
133859
132861
  resolutionHost.onChangedAutomaticTypeDirectiveNames();
133860
132862
  }
133861
132863
  }
133862
- function invalidateResolutionsWithGlobalCachePass() {
133863
- if (resolutionsResolvedWithGlobalCache) resolutionsWithGlobalCachePassAreInvalidated = true;
132864
+ function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) {
132865
+ Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === void 0);
132866
+ filesWithInvalidatedNonRelativeUnresolvedImports = filesMap;
133864
132867
  }
133865
- function invalidateResolutionsWithoutGlobalCachePass() {
133866
- if (resolutionsResolvedWithoutGlobalCache) resolutionsWithoutGlobalCachePassAreInvalidated = true;
132868
+ function scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, isCreatingWatchedDirectory) {
132869
+ if (isCreatingWatchedDirectory) {
132870
+ (isInDirectoryChecks || (isInDirectoryChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
132871
+ } else {
132872
+ const updatedPath = removeIgnoredPath(fileOrDirectoryPath);
132873
+ if (!updatedPath) return false;
132874
+ fileOrDirectoryPath = updatedPath;
132875
+ if (resolutionHost.fileIsOpen(fileOrDirectoryPath)) {
132876
+ return false;
132877
+ }
132878
+ const dirOfFileOrDirectory = getDirectoryPath(fileOrDirectoryPath);
132879
+ if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || isNodeModulesDirectory(fileOrDirectoryPath) || isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || isNodeModulesDirectory(dirOfFileOrDirectory)) {
132880
+ (failedLookupChecks || (failedLookupChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
132881
+ (startsWithPathChecks || (startsWithPathChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
132882
+ } else {
132883
+ if (isEmittedFileOfProgram(resolutionHost.getCurrentProgram(), fileOrDirectoryPath)) {
132884
+ return false;
132885
+ }
132886
+ if (fileExtensionIs(fileOrDirectoryPath, ".map")) {
132887
+ return false;
132888
+ }
132889
+ (failedLookupChecks || (failedLookupChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
132890
+ (startsWithPathChecks || (startsWithPathChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
132891
+ const packagePath = parseNodeModuleFromPath(
132892
+ fileOrDirectoryPath,
132893
+ /*isFolder*/
132894
+ true
132895
+ );
132896
+ if (packagePath) (startsWithPathChecks || (startsWithPathChecks = /* @__PURE__ */ new Set())).add(packagePath);
132897
+ }
132898
+ }
132899
+ resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
133867
132900
  }
133868
- function invalidateUnresolvedResolutionsWithGlobalCachePass() {
133869
- if (resolutionsResolvedWithGlobalCache) unresolvedResolutionsWithGlobalCachePassAreInvalidated = true;
132901
+ function invalidatePackageJsonMap() {
132902
+ const packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
132903
+ if (packageJsonMap && (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks)) {
132904
+ packageJsonMap.forEach((_value, path) => isInvalidatedFailedLookup(path) ? packageJsonMap.delete(path) : void 0);
132905
+ }
133870
132906
  }
133871
132907
  function invalidateResolutionsOfFailedLookupLocations() {
133872
132908
  var _a;
133873
- let invalidated = allModuleAndTypeResolutionsAreInvalidated;
133874
- if (!allModuleAndTypeResolutionsAreInvalidated && affectingPathChecksForFile) {
132909
+ if (allModuleAndTypeResolutionsAreInvalidated) {
132910
+ affectingPathChecksForFile = void 0;
132911
+ invalidatePackageJsonMap();
132912
+ if (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks || affectingPathChecks) {
132913
+ invalidateResolutions(resolvedLibraries, canInvalidateFailedLookupResolution);
132914
+ }
132915
+ failedLookupChecks = void 0;
132916
+ startsWithPathChecks = void 0;
132917
+ isInDirectoryChecks = void 0;
132918
+ affectingPathChecks = void 0;
132919
+ return true;
132920
+ }
132921
+ let invalidated = false;
132922
+ if (affectingPathChecksForFile) {
133875
132923
  (_a = resolutionHost.getCurrentProgram()) == null ? void 0 : _a.getSourceFiles().forEach((f) => {
133876
132924
  if (some(f.packageJsonLocations, (location) => affectingPathChecksForFile.has(location))) {
133877
132925
  (filesWithInvalidatedResolutions ?? (filesWithInvalidatedResolutions = /* @__PURE__ */ new Set())).add(f.path);
133878
132926
  invalidated = true;
133879
132927
  }
133880
132928
  });
132929
+ affectingPathChecksForFile = void 0;
133881
132930
  }
133882
- affectingPathChecksForFile = void 0;
133883
- return sharedCache.invalidateResolutionsOfFailedLookupLocations() || invalidated;
132931
+ if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
132932
+ return invalidated;
132933
+ }
132934
+ invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution) || invalidated;
132935
+ invalidatePackageJsonMap();
132936
+ failedLookupChecks = void 0;
132937
+ startsWithPathChecks = void 0;
132938
+ isInDirectoryChecks = void 0;
132939
+ invalidated = invalidateResolutions(resolutionsWithOnlyAffectingLocations, canInvalidatedFailedLookupResolutionWithAffectingLocation) || invalidated;
132940
+ affectingPathChecks = void 0;
132941
+ return invalidated;
132942
+ }
132943
+ function canInvalidateFailedLookupResolution(resolution) {
132944
+ var _a;
132945
+ if (canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution)) return true;
132946
+ if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) return false;
132947
+ return ((_a = resolution.failedLookupLocations) == null ? void 0 : _a.some((location) => isInvalidatedFailedLookup(resolutionHost.toPath(location)))) || !!resolution.alternateResult && isInvalidatedFailedLookup(resolutionHost.toPath(resolution.alternateResult));
132948
+ }
132949
+ function isInvalidatedFailedLookup(locationPath) {
132950
+ return (failedLookupChecks == null ? void 0 : failedLookupChecks.has(locationPath)) || firstDefinedIterator((startsWithPathChecks == null ? void 0 : startsWithPathChecks.keys()) || [], (fileOrDirectoryPath) => startsWith(locationPath, fileOrDirectoryPath) ? true : void 0) || firstDefinedIterator((isInDirectoryChecks == null ? void 0 : isInDirectoryChecks.keys()) || [], (dirPath) => locationPath.length > dirPath.length && startsWith(locationPath, dirPath) && (isDiskPathRoot(dirPath) || locationPath[dirPath.length] === directorySeparator) ? true : void 0);
132951
+ }
132952
+ function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
132953
+ var _a;
132954
+ return !!affectingPathChecks && ((_a = resolution.affectingLocations) == null ? void 0 : _a.some((location) => affectingPathChecks.has(location)));
133884
132955
  }
133885
132956
  function closeTypeRootsWatch() {
133886
132957
  clearMap(typeRootsWatches, closeFileWatcher);
133887
132958
  }
133888
132959
  function createTypeRootsWatch(typeRoot) {
133889
- return sharedCache.createTypeRootsWatch(typeRoot, cache);
133890
- }
133891
- function invalidateTypeRoot() {
133892
- hasChangedAutomaticTypeDirectiveNames = true;
133893
- resolutionHost.onChangedAutomaticTypeDirectiveNames();
132960
+ return canWatchTypeRootPath(typeRoot) ? resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
132961
+ const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
132962
+ if (cachedDirectoryStructureHost) {
132963
+ cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
132964
+ }
132965
+ hasChangedAutomaticTypeDirectiveNames = true;
132966
+ resolutionHost.onChangedAutomaticTypeDirectiveNames();
132967
+ const dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(
132968
+ typeRoot,
132969
+ resolutionHost.toPath(typeRoot),
132970
+ rootPath,
132971
+ rootPathComponents,
132972
+ isRootWatchable,
132973
+ getCurrentDirectory,
132974
+ resolutionHost.preferNonRecursiveWatch,
132975
+ (dirPath2) => directoryWatchesOfFailedLookups.has(dirPath2) || dirPathToSymlinkPackageRefCount.has(dirPath2)
132976
+ );
132977
+ if (dirPath) {
132978
+ scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
132979
+ }
132980
+ }, 1 /* Recursive */) : noopFileWatcher;
133894
132981
  }
133895
- function updateTypeRootsWatch(options) {
133896
- options ?? (options = resolutionHost.getCompilationSettings());
132982
+ function updateTypeRootsWatch() {
132983
+ const options = resolutionHost.getCompilationSettings();
133897
132984
  if (options.types) {
133898
132985
  closeTypeRootsWatch();
133899
132986
  return;
@@ -133912,6 +132999,10 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133912
132999
  closeTypeRootsWatch();
133913
133000
  }
133914
133001
  }
133002
+ function canWatchTypeRootPath(typeRoot) {
133003
+ if (resolutionHost.getCompilationSettings().typeRoots) return true;
133004
+ return canWatchAtTypes(resolutionHost.toPath(typeRoot));
133005
+ }
133915
133006
  }
133916
133007
  function resolutionIsSymlink(resolution) {
133917
133008
  var _a, _b;
@@ -134704,23 +133795,22 @@ function createWatchProgram(host) {
134704
133795
  compilerHost.getParsedCommandLine = getParsedCommandLine;
134705
133796
  const resolutionCache = createResolutionCache(
134706
133797
  compilerHost,
134707
- configFileName ? getDirectoryPath(getNormalizedAbsolutePath(configFileName, currentDirectory)) : currentDirectory
133798
+ configFileName ? getDirectoryPath(getNormalizedAbsolutePath(configFileName, currentDirectory)) : currentDirectory,
133799
+ /*logChangesWhenResolvingModule*/
133800
+ false
134708
133801
  );
134709
- compilerHost.onSourceFileNotCreated = resolutionCache.onSourceFileNotCreated.bind(resolutionCache);
134710
133802
  compilerHost.resolveModuleNameLiterals = maybeBind(host, host.resolveModuleNameLiterals);
134711
133803
  compilerHost.resolveModuleNames = maybeBind(host, host.resolveModuleNames);
134712
133804
  if (!compilerHost.resolveModuleNameLiterals && !compilerHost.resolveModuleNames) {
134713
133805
  compilerHost.resolveModuleNameLiterals = resolutionCache.resolveModuleNameLiterals.bind(resolutionCache);
134714
- compilerHost.onReusedModuleResolutions = resolutionCache.onReusedModuleResolutions.bind(resolutionCache);
134715
133806
  }
134716
133807
  compilerHost.resolveTypeReferenceDirectiveReferences = maybeBind(host, host.resolveTypeReferenceDirectiveReferences);
134717
133808
  compilerHost.resolveTypeReferenceDirectives = maybeBind(host, host.resolveTypeReferenceDirectives);
134718
133809
  if (!compilerHost.resolveTypeReferenceDirectiveReferences && !compilerHost.resolveTypeReferenceDirectives) {
134719
133810
  compilerHost.resolveTypeReferenceDirectiveReferences = resolutionCache.resolveTypeReferenceDirectiveReferences.bind(resolutionCache);
134720
- compilerHost.onReusedTypeReferenceDirectiveResolutions = resolutionCache.onReusedTypeReferenceDirectiveResolutions.bind(resolutionCache);
134721
133811
  }
134722
133812
  compilerHost.resolveLibrary = !host.resolveLibrary ? resolutionCache.resolveLibrary.bind(resolutionCache) : host.resolveLibrary.bind(host);
134723
- compilerHost.getModuleResolutionCache = host.resolveModuleNameLiterals || host.resolveModuleNames ? maybeBind(host, host.getModuleResolutionCache) : () => resolutionCache.moduleResolutionCache;
133813
+ compilerHost.getModuleResolutionCache = host.resolveModuleNameLiterals || host.resolveModuleNames ? maybeBind(host, host.getModuleResolutionCache) : () => resolutionCache.getModuleResolutionCache();
134724
133814
  const userProvidedResolution = !!host.resolveModuleNameLiterals || !!host.resolveTypeReferenceDirectiveReferences || !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
134725
133815
  const customHasInvalidatedResolutions = userProvidedResolution ? maybeBind(host, host.hasInvalidatedResolutions) || returnTrue : returnFalse;
134726
133816
  const customHasInvalidLibResolutions = host.resolveLibrary ? maybeBind(host, host.hasInvalidatedLibResolutions) || returnTrue : returnFalse;
@@ -153406,10 +152496,7 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
153406
152496
  resolveTypeReferenceDirectives: maybeBind(host, host.resolveTypeReferenceDirectives),
153407
152497
  resolveModuleNameLiterals: maybeBind(host, host.resolveModuleNameLiterals),
153408
152498
  resolveTypeReferenceDirectiveReferences: maybeBind(host, host.resolveTypeReferenceDirectiveReferences),
153409
- onReusedModuleResolutions: maybeBind(host, host.onReusedModuleResolutions),
153410
- onReusedTypeReferenceDirectiveResolutions: maybeBind(host, host.onReusedTypeReferenceDirectiveResolutions),
153411
152499
  resolveLibrary: maybeBind(host, host.resolveLibrary),
153412
- onSourceFileNotCreated: maybeBind(host, host.onSourceFileNotCreated),
153413
152500
  useSourceOfProjectReferenceRedirect: maybeBind(host, host.useSourceOfProjectReferenceRedirect),
153414
152501
  getParsedCommandLine,
153415
152502
  jsDocParsingMode: host.jsDocParsingMode,
@@ -184115,7 +183202,6 @@ __export(ts_exports2, {
184115
183202
  computeLineOfPosition: () => computeLineOfPosition,
184116
183203
  computeLineStarts: () => computeLineStarts,
184117
183204
  computePositionOfLineAndCharacter: () => computePositionOfLineAndCharacter,
184118
- computeRedirectsCacheKey: () => computeRedirectsCacheKey,
184119
183205
  computeSignatureWithDiagnostics: () => computeSignatureWithDiagnostics,
184120
183206
  computeSuggestionDiagnostics: () => computeSuggestionDiagnostics,
184121
183207
  computedOptions: () => computedOptions,
@@ -184240,7 +183326,6 @@ __export(ts_exports2, {
184240
183326
  createScanner: () => createScanner,
184241
183327
  createSemanticDiagnosticsBuilderProgram: () => createSemanticDiagnosticsBuilderProgram,
184242
183328
  createSet: () => createSet,
184243
- createSharedResolutionCache: () => createSharedResolutionCache,
184244
183329
  createSolutionBuilder: () => createSolutionBuilder,
184245
183330
  createSolutionBuilderHost: () => createSolutionBuilderHost,
184246
183331
  createSolutionBuilderWithWatch: () => createSolutionBuilderWithWatch,
@@ -184308,8 +183393,6 @@ __export(ts_exports2, {
184308
183393
  emptyFileSystemEntries: () => emptyFileSystemEntries,
184309
183394
  emptyMap: () => emptyMap,
184310
183395
  emptyOptions: () => emptyOptions,
184311
- emptyResolution: () => emptyResolution,
184312
- enableSharingModuleOrTypeReferenceResolutionCache: () => enableSharingModuleOrTypeReferenceResolutionCache,
184313
183396
  endsWith: () => endsWith,
184314
183397
  ensurePathIsNonModuleName: () => ensurePathIsNonModuleName,
184315
183398
  ensureScriptKind: () => ensureScriptKind,
@@ -184447,7 +183530,6 @@ __export(ts_exports2, {
184447
183530
  getAssignmentDeclarationKind: () => getAssignmentDeclarationKind,
184448
183531
  getAssignmentDeclarationPropertyAccessKind: () => getAssignmentDeclarationPropertyAccessKind,
184449
183532
  getAssignmentTargetKind: () => getAssignmentTargetKind,
184450
- getAutomaticTypeDirectiveContainingFile: () => getAutomaticTypeDirectiveContainingFile,
184451
183533
  getAutomaticTypeDirectiveNames: () => getAutomaticTypeDirectiveNames,
184452
183534
  getBaseFileName: () => getBaseFileName,
184453
183535
  getBinaryOperatorPrecedence: () => getBinaryOperatorPrecedence,
@@ -184507,6 +183589,7 @@ __export(ts_exports2, {
184507
183589
  getDiagnosticsWithinSpan: () => getDiagnosticsWithinSpan,
184508
183590
  getDirectoryPath: () => getDirectoryPath,
184509
183591
  getDirectoryToWatchFailedLookupLocation: () => getDirectoryToWatchFailedLookupLocation,
183592
+ getDirectoryToWatchFailedLookupLocationFromTypeRoot: () => getDirectoryToWatchFailedLookupLocationFromTypeRoot,
184510
183593
  getDocumentPositionMapper: () => getDocumentPositionMapper,
184511
183594
  getDocumentSpansEqualityComparer: () => getDocumentSpansEqualityComparer,
184512
183595
  getESModuleInterop: () => getESModuleInterop,
@@ -185474,9 +184557,6 @@ __export(ts_exports2, {
185474
184557
  isRegularExpressionLiteral: () => isRegularExpressionLiteral,
185475
184558
  isRequireCall: () => isRequireCall,
185476
184559
  isRequireVariableStatement: () => isRequireVariableStatement,
185477
- isResolvedWithGlobalCachePass: () => isResolvedWithGlobalCachePass,
185478
- isResolvedWithGlobalCachePassButStillUnresolved: () => isResolvedWithGlobalCachePassButStillUnresolved,
185479
- isResolvedWithoutGlobalCachePass: () => isResolvedWithoutGlobalCachePass,
185480
184560
  isRestParameter: () => isRestParameter,
185481
184561
  isRestTypeNode: () => isRestTypeNode,
185482
184562
  isReturnStatement: () => isReturnStatement,
@@ -185596,7 +184676,6 @@ __export(ts_exports2, {
185596
184676
  isUnaryExpressionWithWrite: () => isUnaryExpressionWithWrite,
185597
184677
  isUnicodeIdentifierStart: () => isUnicodeIdentifierStart,
185598
184678
  isUnionTypeNode: () => isUnionTypeNode,
185599
- isUnresolvedOrResolvedToJs: () => isUnresolvedOrResolvedToJs,
185600
184679
  isUrl: () => isUrl,
185601
184680
  isValidBigIntString: () => isValidBigIntString,
185602
184681
  isValidESSymbolDeclaration: () => isValidESSymbolDeclaration,
@@ -185681,7 +184760,6 @@ __export(ts_exports2, {
185681
184760
  mutateMap: () => mutateMap,
185682
184761
  mutateMapSkippingNewValues: () => mutateMapSkippingNewValues,
185683
184762
  needsParentheses: () => needsParentheses,
185684
- needsResolutionFromGlobalCache: () => needsResolutionFromGlobalCache,
185685
184763
  needsScopeMarker: () => needsScopeMarker,
185686
184764
  newCaseClauseTracker: () => newCaseClauseTracker,
185687
184765
  newPrivateEnvironment: () => newPrivateEnvironment,
@@ -186039,7 +185117,6 @@ __export(ts_exports2, {
186039
185117
  typeDirectiveIsEqualTo: () => typeDirectiveIsEqualTo,
186040
185118
  typeKeywords: () => typeKeywords,
186041
185119
  typeParameterNamePart: () => typeParameterNamePart,
186042
- typeReferenceResolutionNameAndModeGetter: () => typeReferenceResolutionNameAndModeGetter,
186043
185120
  typeToDisplayParts: () => typeToDisplayParts,
186044
185121
  unchangedPollThresholds: () => unchangedPollThresholds,
186045
185122
  unchangedTextChangeRange: () => unchangedTextChangeRange,
@@ -186055,6 +185132,7 @@ __export(ts_exports2, {
186055
185132
  updateErrorForNoInputFiles: () => updateErrorForNoInputFiles,
186056
185133
  updateLanguageServiceSourceFile: () => updateLanguageServiceSourceFile,
186057
185134
  updateMissingFilePathsWatch: () => updateMissingFilePathsWatch,
185135
+ updateResolutionField: () => updateResolutionField,
186058
185136
  updateSharedExtendedConfigFileWatcher: () => updateSharedExtendedConfigFileWatcher,
186059
185137
  updateSourceFile: () => updateSourceFile,
186060
185138
  updateWatchingWildcardDirectories: () => updateWatchingWildcardDirectories,
@@ -186261,7 +185339,6 @@ __export(ts_server_exports3, {
186261
185339
  getBaseConfigFileName: () => getBaseConfigFileName,
186262
185340
  getDetailWatchInfo: () => getDetailWatchInfo,
186263
185341
  getLocationInNewDocument: () => getLocationInNewDocument,
186264
- getUnresolvedImports: () => getUnresolvedImports,
186265
185342
  hasArgument: () => hasArgument,
186266
185343
  hasNoTypeScriptSource: () => hasNoTypeScriptSource,
186267
185344
  indent: () => indent2,
@@ -186668,7 +185745,7 @@ var TypingsInstaller = class {
186668
185745
  }
186669
185746
  const existing = this.projectWatchers.get(projectName);
186670
185747
  const newSet = new Set(files);
186671
- if (!existing || newSet.size !== existing.size || forEachKey(newSet, (s) => !existing.has(s)) || forEachKey(existing, (s) => !newSet.has(s))) {
185748
+ if (!existing || forEachKey(newSet, (s) => !existing.has(s)) || forEachKey(existing, (s) => !newSet.has(s))) {
186672
185749
  this.projectWatchers.set(projectName, newSet);
186673
185750
  this.sendResponse({ kind: ActionWatchTypingLocations, projectName, files });
186674
185751
  } else {
@@ -187683,16 +186760,11 @@ function compilerOptionsChanged(opt1, opt2) {
187683
186760
  return getAllowJSCompilerOption(opt1) !== getAllowJSCompilerOption(opt2);
187684
186761
  }
187685
186762
  function unresolvedImportsChanged(imports1, imports2) {
187686
- if (imports1 === imports2) return false;
187687
- if (!(imports1 == null ? void 0 : imports1.length) === !(imports2 == null ? void 0 : imports2.length)) return false;
186763
+ if (imports1 === imports2) {
186764
+ return false;
186765
+ }
187688
186766
  return !arrayIsEqualTo(imports1, imports2);
187689
186767
  }
187690
- var disabledTypeAcquisition = {};
187691
- var enabledTypeAcquisition = {
187692
- enable: true,
187693
- include: emptyArray,
187694
- exclude: emptyArray
187695
- };
187696
186768
  var Project2 = class _Project {
187697
186769
  /** @internal */
187698
186770
  constructor(projectName, projectKind, projectService, hasExplicitListOfFiles, lastFileExceededProgramSize, compilerOptions, compileOnSaveEnabled, watchOptions, directoryStructureHost, currentDirectory) {
@@ -187712,7 +186784,6 @@ var Project2 = class _Project {
187712
186784
  * @internal
187713
186785
  */
187714
186786
  this.cachedUnresolvedImportsPerFile = /* @__PURE__ */ new Map();
187715
- this.recordChangesToUnresolvedImports = false;
187716
186787
  this.hasAddedorRemovedFiles = false;
187717
186788
  this.hasAddedOrRemovedSymlinks = false;
187718
186789
  /**
@@ -187789,7 +186860,8 @@ var Project2 = class _Project {
187789
186860
  this.resolutionCache = createResolutionCache(
187790
186861
  this,
187791
186862
  this.currentDirectory,
187792
- this.projectService.sharedResolutionCache
186863
+ /*logChangesWhenResolvingModule*/
186864
+ true
187793
186865
  );
187794
186866
  this.languageService = createLanguageService(
187795
186867
  this,
@@ -187979,35 +187051,11 @@ var Project2 = class _Project {
187979
187051
  }
187980
187052
  /** @internal */
187981
187053
  resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options, containingSourceFile, reusedNames) {
187982
- let invalidated = false;
187983
- return this.resolutionCache.resolveModuleNameLiterals(
187984
- moduleLiterals,
187985
- containingFile,
187986
- redirectedReference,
187987
- options,
187988
- containingSourceFile,
187989
- reusedNames,
187990
- this.recordChangesToUnresolvedImports ? (existing, current, path, name) => {
187991
- if (invalidated || isExternalModuleNameRelative(name)) return;
187992
- if ((existing && isUnresolvedOrResolvedToJs(existing)) === isUnresolvedOrResolvedToJs(current)) return;
187993
- invalidated = true;
187994
- this.cachedUnresolvedImportsPerFile.delete(path);
187995
- this.lastCachedUnresolvedImportsList = void 0;
187996
- } : void 0
187997
- );
187998
- }
187999
- /** @internal */
188000
- onReusedModuleResolutions(reusedNames, containingSourceFile, redirectedReference, options) {
188001
- return this.resolutionCache.onReusedModuleResolutions(
188002
- reusedNames,
188003
- containingSourceFile,
188004
- redirectedReference,
188005
- options
188006
- );
187054
+ return this.resolutionCache.resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options, containingSourceFile, reusedNames);
188007
187055
  }
188008
187056
  /** @internal */
188009
187057
  getModuleResolutionCache() {
188010
- return this.resolutionCache.moduleResolutionCache;
187058
+ return this.resolutionCache.getModuleResolutionCache();
188011
187059
  }
188012
187060
  /** @internal */
188013
187061
  resolveTypeReferenceDirectiveReferences(typeDirectiveReferences, containingFile, redirectedReference, options, containingSourceFile, reusedNames) {
@@ -188021,22 +187069,9 @@ var Project2 = class _Project {
188021
187069
  );
188022
187070
  }
188023
187071
  /** @internal */
188024
- onReusedTypeReferenceDirectiveResolutions(reusedNames, containingSourceFile, redirectedReference, options) {
188025
- return this.resolutionCache.onReusedTypeReferenceDirectiveResolutions(
188026
- reusedNames,
188027
- containingSourceFile,
188028
- redirectedReference,
188029
- options
188030
- );
188031
- }
188032
- /** @internal */
188033
187072
  resolveLibrary(libraryName, resolveFrom, options, libFileName) {
188034
187073
  return this.resolutionCache.resolveLibrary(libraryName, resolveFrom, options, libFileName);
188035
187074
  }
188036
- /** @internal */
188037
- onSourceFileNotCreated(sourceFileOptions) {
188038
- this.resolutionCache.onSourceFileNotCreated(sourceFileOptions);
188039
- }
188040
187075
  directoryExists(path) {
188041
187076
  return this.directoryStructureHost.directoryExists(path);
188042
187077
  }
@@ -188122,7 +187157,7 @@ var Project2 = class _Project {
188122
187157
  }
188123
187158
  /** @internal */
188124
187159
  fileIsOpen(filePath) {
188125
- return this.projectService.fileIsOpen(filePath);
187160
+ return this.projectService.openFiles.has(filePath);
188126
187161
  }
188127
187162
  /** @internal */
188128
187163
  writeLog(s) {
@@ -188232,9 +187267,6 @@ var Project2 = class _Project {
188232
187267
  }
188233
187268
  this.languageServiceEnabled = true;
188234
187269
  this.lastFileExceededProgramSize = void 0;
188235
- if (this.projectService.serverMode === 0 /* Semantic */) {
188236
- this.resolutionCache.updateTypeRootsWatch();
188237
- }
188238
187270
  this.projectService.onUpdateLanguageServiceStateForProject(
188239
187271
  this,
188240
187272
  /*languageServiceEnabled*/
@@ -188554,10 +187586,6 @@ var Project2 = class _Project {
188554
187586
  updateFromProject() {
188555
187587
  updateProjectIfDirty(this);
188556
187588
  }
188557
- /** @internal */
188558
- useTypingsFromGlobalCache() {
188559
- return !this.isOrphan() && !!this.languageServiceEnabled && this.projectService.serverMode === 0 /* Semantic */ && this.projectService.typingsInstaller !== nullTypingsInstaller && !!this.getTypeAcquisition().enable;
188560
- }
188561
187589
  /**
188562
187590
  * Updates set of files that contribute to this project
188563
187591
  * @returns: true if set of files in the project stays the same and false - otherwise.
@@ -188565,27 +187593,23 @@ var Project2 = class _Project {
188565
187593
  updateGraph() {
188566
187594
  var _a, _b;
188567
187595
  (_a = tracing) == null ? void 0 : _a.push(tracing.Phase.Session, "updateGraph", { name: this.projectName, kind: ProjectKind[this.projectKind] });
188568
- const useTypingsFromGlobalCache = this.useTypingsFromGlobalCache();
188569
- if (!useTypingsFromGlobalCache) this.resolutionCache.invalidateResolutionsWithGlobalCachePass();
188570
- else this.resolutionCache.invalidateResolutionsWithoutGlobalCachePass();
188571
- if (useTypingsFromGlobalCache && this.cachedUnresolvedImportsPerFile.size) this.recordChangesToUnresolvedImports = true;
187596
+ this.resolutionCache.startRecordingFilesWithChangedResolutions();
188572
187597
  const hasNewProgram = this.updateGraphWorker();
188573
187598
  const hasAddedorRemovedFiles = this.hasAddedorRemovedFiles;
188574
187599
  this.hasAddedorRemovedFiles = false;
188575
187600
  this.hasAddedOrRemovedSymlinks = false;
188576
- this.recordChangesToUnresolvedImports = false;
188577
- if (useTypingsFromGlobalCache) {
188578
- this.lastCachedUnresolvedImportsList ?? (this.lastCachedUnresolvedImportsList = getUnresolvedImports(
188579
- this.program,
188580
- this.cachedUnresolvedImportsPerFile
188581
- ));
187601
+ const changedFiles = this.resolutionCache.finishRecordingFilesWithChangedResolutions() || emptyArray2;
187602
+ for (const file of changedFiles) {
187603
+ this.cachedUnresolvedImportsPerFile.delete(file);
187604
+ }
187605
+ if (this.languageServiceEnabled && this.projectService.serverMode === 0 /* Semantic */ && !this.isOrphan()) {
187606
+ if (hasNewProgram || changedFiles.length) {
187607
+ this.lastCachedUnresolvedImportsList = getUnresolvedImports(this.program, this.cachedUnresolvedImportsPerFile);
187608
+ }
188582
187609
  this.enqueueInstallTypingsForProject(hasAddedorRemovedFiles);
188583
187610
  } else {
188584
187611
  this.lastCachedUnresolvedImportsList = void 0;
188585
- this.cachedUnresolvedImportsPerFile.clear();
188586
- this.typingsCache = void 0;
188587
187612
  }
188588
- this.projectService.verifyUnresovedImports(this);
188589
187613
  const isFirstProgramLoad = this.projectProgramVersion === 0 && hasNewProgram;
188590
187614
  if (hasNewProgram) {
188591
187615
  this.projectProgramVersion++;
@@ -188601,7 +187625,6 @@ var Project2 = class _Project {
188601
187625
  }
188602
187626
  /** @internal */
188603
187627
  enqueueInstallTypingsForProject(forceRefresh) {
188604
- var _a;
188605
187628
  const typeAcquisition = this.getTypeAcquisition();
188606
187629
  if (!typeAcquisition || !typeAcquisition.enable || this.projectService.typingsInstaller === nullTypingsInstaller) {
188607
187630
  return;
@@ -188611,31 +187634,29 @@ var Project2 = class _Project {
188611
187634
  this.typingsCache = {
188612
187635
  compilerOptions: this.getCompilationSettings(),
188613
187636
  typeAcquisition,
188614
- unresolvedImports: ((_a = this.lastCachedUnresolvedImportsList) == null ? void 0 : _a.length) ? this.lastCachedUnresolvedImportsList : void 0
187637
+ unresolvedImports: this.lastCachedUnresolvedImportsList
188615
187638
  };
188616
- this.projectService.typingsInstaller.enqueueInstallTypingsRequest(
188617
- this,
188618
- typeAcquisition,
188619
- this.typingsCache.unresolvedImports
188620
- );
187639
+ this.projectService.typingsInstaller.enqueueInstallTypingsRequest(this, typeAcquisition, this.lastCachedUnresolvedImportsList);
188621
187640
  }
188622
187641
  }
188623
187642
  /** @internal */
188624
- updateTypingFiles({ compilerOptions, typeAcquisition, unresolvedImports, typings }) {
188625
- if (!this.getTypeAcquisition().enable) return;
187643
+ updateTypingFiles(compilerOptions, typeAcquisition, unresolvedImports, newTypings) {
188626
187644
  this.typingsCache = {
188627
187645
  compilerOptions,
188628
187646
  typeAcquisition,
188629
187647
  unresolvedImports
188630
187648
  };
188631
- const typingFiles = typings.length ? toSorted(typings) : emptyArray2;
188632
- if (!arrayIsEqualTo(
187649
+ const typingFiles = !typeAcquisition || !typeAcquisition.enable ? emptyArray2 : toSorted(newTypings);
187650
+ if (enumerateInsertsAndDeletes(
188633
187651
  typingFiles,
188634
187652
  this.typingFiles,
188635
- this.useCaseSensitiveFileNames() ? equateStringsCaseSensitive : equateStringsCaseInsensitive
187653
+ getStringComparer(!this.useCaseSensitiveFileNames()),
187654
+ /*inserted*/
187655
+ noop,
187656
+ (removed) => this.detachScriptInfoFromProject(removed)
188636
187657
  )) {
188637
187658
  this.typingFiles = typingFiles;
188638
- if (this.typingFiles.length) this.resolutionCache.invalidateUnresolvedResolutionsWithGlobalCachePass();
187659
+ this.resolutionCache.setFilesWithInvalidatedNonRelativeUnresolvedImports(this.cachedUnresolvedImportsPerFile);
188639
187660
  this.projectService.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(this);
188640
187661
  }
188641
187662
  }
@@ -189052,19 +188073,10 @@ var Project2 = class _Project {
189052
188073
  setTypeAcquisition(newTypeAcquisition) {
189053
188074
  if (newTypeAcquisition) {
189054
188075
  this.typeAcquisition = this.removeLocalTypingsFromTypeAcquisition(newTypeAcquisition);
189055
- } else {
189056
- this.typeAcquisition = void 0;
189057
- }
189058
- if (!this.getTypeAcquisition().enable) {
189059
- this.typingFiles = emptyArray2;
189060
- if (this.typingsCache) {
189061
- this.typingsCache = void 0;
189062
- this.projectService.typingsInstaller.onProjectClosed(this);
189063
- }
189064
188076
  }
189065
188077
  }
189066
188078
  getTypeAcquisition() {
189067
- return this.typeAcquisition ?? (this.typeAcquisition = disabledTypeAcquisition);
188079
+ return this.typeAcquisition || {};
189068
188080
  }
189069
188081
  /** @internal */
189070
188082
  getChangesSinceVersion(lastKnownVersion, includeProjectReferenceRedirectInfo) {
@@ -189396,8 +188408,8 @@ function getUnresolvedImports(program, cachedUnresolvedImportsPerFile) {
189396
188408
  function extractUnresolvedImportsFromSourceFile(program, file, ambientModules, cachedUnresolvedImportsPerFile) {
189397
188409
  return getOrUpdate(cachedUnresolvedImportsPerFile, file.path, () => {
189398
188410
  let unresolvedImports;
189399
- program.forEachResolvedModule((resolution, name) => {
189400
- if (needsResolutionFromGlobalCache(name, resolution) && !ambientModules.some((m) => m === name)) {
188411
+ program.forEachResolvedModule(({ resolvedModule }, name) => {
188412
+ if ((!resolvedModule || !resolutionExtensionIsTSOrJson(resolvedModule.extension)) && !isExternalModuleNameRelative(name) && !ambientModules.some((m) => m === name)) {
189401
188413
  unresolvedImports = append(unresolvedImports, parsePackageName(name).packageName);
189402
188414
  }
189403
188415
  }, file);
@@ -189463,12 +188475,10 @@ var InferredProject2 = class extends Project2 {
189463
188475
  false
189464
188476
  );
189465
188477
  }
189466
- this.inferredTypeAcquisition = void 0;
189467
188478
  super.addRoot(info);
189468
188479
  }
189469
188480
  removeRoot(info) {
189470
188481
  this.projectService.stopWatchingConfigFilesForScriptInfo(info);
189471
- this.inferredTypeAcquisition = void 0;
189472
188482
  super.removeRoot(info);
189473
188483
  if (!this.isOrphan() && this._isJsInferredProject && info.isJavaScript()) {
189474
188484
  if (every(this.getRootScriptInfos(), (rootInfo) => !rootInfo.isJavaScript())) {
@@ -189490,12 +188500,12 @@ var InferredProject2 = class extends Project2 {
189490
188500
  forEach(this.getRootScriptInfos(), (info) => this.projectService.stopWatchingConfigFilesForScriptInfo(info));
189491
188501
  super.close();
189492
188502
  }
189493
- setTypeAcquisition(newTypeAcquisition) {
189494
- this.inferredTypeAcquisition = void 0;
189495
- super.setTypeAcquisition(newTypeAcquisition);
189496
- }
189497
188503
  getTypeAcquisition() {
189498
- return this.typeAcquisition || (this.inferredTypeAcquisition ?? (this.inferredTypeAcquisition = allRootFilesAreJsOrDts(this) ? enabledTypeAcquisition : disabledTypeAcquisition));
188504
+ return this.typeAcquisition || {
188505
+ enable: allRootFilesAreJsOrDts(this),
188506
+ include: emptyArray,
188507
+ exclude: emptyArray
188508
+ };
189499
188509
  }
189500
188510
  };
189501
188511
  var AuxiliaryProject = class extends Project2 {
@@ -189773,6 +188783,11 @@ var _AutoImportProviderProject = class _AutoImportProviderProject extends Projec
189773
188783
  getSymlinkCache() {
189774
188784
  return this.hostProject.getSymlinkCache();
189775
188785
  }
188786
+ /** @internal */
188787
+ getModuleResolutionCache() {
188788
+ var _a;
188789
+ return (_a = this.hostProject.getCurrentProgram()) == null ? void 0 : _a.getModuleResolutionCache();
188790
+ }
189776
188791
  };
189777
188792
  _AutoImportProviderProject.maxDependencies = 10;
189778
188793
  /** @internal */
@@ -190645,8 +189660,6 @@ var _ProjectService = class _ProjectService {
190645
189660
  /** @internal */
190646
189661
  this.verifyProgram = noop;
190647
189662
  /** @internal */
190648
- this.verifyUnresovedImports = noop;
190649
- /** @internal */
190650
189663
  this.onProjectCreation = noop;
190651
189664
  var _a;
190652
189665
  this.host = opts.host;
@@ -190710,19 +189723,8 @@ var _ProjectService = class _ProjectService {
190710
189723
  getDetailWatchInfo
190711
189724
  );
190712
189725
  this.canUseWatchEvents = getCanUseWatchEvents(this, opts.canUseWatchEvents);
190713
- this.sharedResolutionCache = createSharedResolutionCache({
190714
- getCurrentDirectory: this.host.getCurrentDirectory.bind(this.host),
190715
- toPath: this.toPath.bind(this),
190716
- getCanonicalFileName: this.toCanonicalFileName,
190717
- preferNonRecursiveWatch: this.canUseWatchEvents || this.host.preferNonRecursiveWatch,
190718
- fileIsOpen: this.fileIsOpen.bind(this)
190719
- });
190720
189726
  (_a = opts.incrementalVerifier) == null ? void 0 : _a.call(opts, this);
190721
189727
  }
190722
- /** @internal */
190723
- fileIsOpen(filePath) {
190724
- return this.openFiles.has(filePath);
190725
- }
190726
189728
  toPath(fileName) {
190727
189729
  return toPath(fileName, this.currentDirectory, this.toCanonicalFileName);
190728
189730
  }
@@ -190794,7 +189796,12 @@ var _ProjectService = class _ProjectService {
190794
189796
  }
190795
189797
  switch (response.kind) {
190796
189798
  case ActionSet:
190797
- project.updateTypingFiles(response);
189799
+ project.updateTypingFiles(
189800
+ response.compilerOptions,
189801
+ response.typeAcquisition,
189802
+ response.unresolvedImports,
189803
+ response.typings
189804
+ );
190798
189805
  return;
190799
189806
  case ActionInvalidate:
190800
189807
  project.enqueueInstallTypingsForProject(
@@ -195993,7 +195000,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
195993
195000
  );
195994
195001
  const packageName = getPackageNameFromTypesPackageName(unmangleScopedPackageName(packageNamePathPart));
195995
195002
  const path = project.toPath(fileName);
195996
- if (some(entrypoints, (e) => project.toPath(e) === path)) {
195003
+ if (entrypoints && some(entrypoints, (e) => project.toPath(e) === path)) {
195997
195004
  return (_b = auxiliaryProject.resolutionCache.resolveSingleModuleNameWithoutWatching(packageName, resolveFromFile).resolvedModule) == null ? void 0 : _b.resolvedFileName;
195998
195005
  } else {
195999
195006
  const pathToFileInPackage = fileName.substring(nodeModulesPathParts.packageRootIndex + 1);
@@ -198619,7 +197626,6 @@ __export(ts_server_exports4, {
198619
197626
  getBaseConfigFileName: () => getBaseConfigFileName,
198620
197627
  getDetailWatchInfo: () => getDetailWatchInfo,
198621
197628
  getLocationInNewDocument: () => getLocationInNewDocument,
198622
- getUnresolvedImports: () => getUnresolvedImports,
198623
197629
  hasArgument: () => hasArgument,
198624
197630
  hasNoTypeScriptSource: () => hasNoTypeScriptSource,
198625
197631
  indent: () => indent2,
@@ -198957,7 +197963,6 @@ if (typeof console !== "undefined") {
198957
197963
  computeLineOfPosition,
198958
197964
  computeLineStarts,
198959
197965
  computePositionOfLineAndCharacter,
198960
- computeRedirectsCacheKey,
198961
197966
  computeSignatureWithDiagnostics,
198962
197967
  computeSuggestionDiagnostics,
198963
197968
  computedOptions,
@@ -199082,7 +198087,6 @@ if (typeof console !== "undefined") {
199082
198087
  createScanner,
199083
198088
  createSemanticDiagnosticsBuilderProgram,
199084
198089
  createSet,
199085
- createSharedResolutionCache,
199086
198090
  createSolutionBuilder,
199087
198091
  createSolutionBuilderHost,
199088
198092
  createSolutionBuilderWithWatch,
@@ -199150,8 +198154,6 @@ if (typeof console !== "undefined") {
199150
198154
  emptyFileSystemEntries,
199151
198155
  emptyMap,
199152
198156
  emptyOptions,
199153
- emptyResolution,
199154
- enableSharingModuleOrTypeReferenceResolutionCache,
199155
198157
  endsWith,
199156
198158
  ensurePathIsNonModuleName,
199157
198159
  ensureScriptKind,
@@ -199289,7 +198291,6 @@ if (typeof console !== "undefined") {
199289
198291
  getAssignmentDeclarationKind,
199290
198292
  getAssignmentDeclarationPropertyAccessKind,
199291
198293
  getAssignmentTargetKind,
199292
- getAutomaticTypeDirectiveContainingFile,
199293
198294
  getAutomaticTypeDirectiveNames,
199294
198295
  getBaseFileName,
199295
198296
  getBinaryOperatorPrecedence,
@@ -199349,6 +198350,7 @@ if (typeof console !== "undefined") {
199349
198350
  getDiagnosticsWithinSpan,
199350
198351
  getDirectoryPath,
199351
198352
  getDirectoryToWatchFailedLookupLocation,
198353
+ getDirectoryToWatchFailedLookupLocationFromTypeRoot,
199352
198354
  getDocumentPositionMapper,
199353
198355
  getDocumentSpansEqualityComparer,
199354
198356
  getESModuleInterop,
@@ -200316,9 +199318,6 @@ if (typeof console !== "undefined") {
200316
199318
  isRegularExpressionLiteral,
200317
199319
  isRequireCall,
200318
199320
  isRequireVariableStatement,
200319
- isResolvedWithGlobalCachePass,
200320
- isResolvedWithGlobalCachePassButStillUnresolved,
200321
- isResolvedWithoutGlobalCachePass,
200322
199321
  isRestParameter,
200323
199322
  isRestTypeNode,
200324
199323
  isReturnStatement,
@@ -200438,7 +199437,6 @@ if (typeof console !== "undefined") {
200438
199437
  isUnaryExpressionWithWrite,
200439
199438
  isUnicodeIdentifierStart,
200440
199439
  isUnionTypeNode,
200441
- isUnresolvedOrResolvedToJs,
200442
199440
  isUrl,
200443
199441
  isValidBigIntString,
200444
199442
  isValidESSymbolDeclaration,
@@ -200523,7 +199521,6 @@ if (typeof console !== "undefined") {
200523
199521
  mutateMap,
200524
199522
  mutateMapSkippingNewValues,
200525
199523
  needsParentheses,
200526
- needsResolutionFromGlobalCache,
200527
199524
  needsScopeMarker,
200528
199525
  newCaseClauseTracker,
200529
199526
  newPrivateEnvironment,
@@ -200881,7 +199878,6 @@ if (typeof console !== "undefined") {
200881
199878
  typeDirectiveIsEqualTo,
200882
199879
  typeKeywords,
200883
199880
  typeParameterNamePart,
200884
- typeReferenceResolutionNameAndModeGetter,
200885
199881
  typeToDisplayParts,
200886
199882
  unchangedPollThresholds,
200887
199883
  unchangedTextChangeRange,
@@ -200897,6 +199893,7 @@ if (typeof console !== "undefined") {
200897
199893
  updateErrorForNoInputFiles,
200898
199894
  updateLanguageServiceSourceFile,
200899
199895
  updateMissingFilePathsWatch,
199896
+ updateResolutionField,
200900
199897
  updateSharedExtendedConfigFileWatcher,
200901
199898
  updateSourceFile,
200902
199899
  updateWatchingWildcardDirectories,