@typescript-deploys/pr-build 5.9.0-pr-61732-3 → 5.9.0-pr-61746-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.20250521`;
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";
@@ -20359,7 +20350,7 @@ function sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit) {
20359
20350
  if (forceDtsEmit) return true;
20360
20351
  if (host.isSourceOfProjectReferenceRedirect(sourceFile.fileName)) return false;
20361
20352
  if (!isJsonSourceFile(sourceFile)) return true;
20362
- if (host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) return false;
20353
+ if (host.getRedirectFromSourceFile(sourceFile.fileName)) return false;
20363
20354
  if (options.outFile) return true;
20364
20355
  if (!options.outDir) return false;
20365
20356
  if (options.rootDir || options.composite && options.configFilePath) {
@@ -24074,7 +24065,7 @@ function forEachResolvedProjectReference(resolvedProjectReferences, cb) {
24074
24065
  /*projectReferences*/
24075
24066
  void 0,
24076
24067
  resolvedProjectReferences,
24077
- (resolvedRef, parent2) => resolvedRef && cb(resolvedRef, parent2)
24068
+ (resolvedRef) => resolvedRef && cb(resolvedRef)
24078
24069
  );
24079
24070
  }
24080
24071
  function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) {
@@ -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;
@@ -50225,10 +50059,10 @@ function getNearestAncestorDirectoryWithPackageJson(host, fileName) {
50225
50059
  );
50226
50060
  }
50227
50061
  function forEachFileNameOfModule(importingFileName, importedFileName, host, preferSymlinks, cb) {
50228
- var _a;
50062
+ var _a, _b;
50229
50063
  const getCanonicalFileName = hostGetCanonicalFileName(host);
50230
50064
  const cwd = host.getCurrentDirectory();
50231
- const referenceRedirect = host.isSourceOfProjectReferenceRedirect(importedFileName) ? host.getProjectReferenceRedirect(importedFileName) : void 0;
50065
+ const referenceRedirect = host.isSourceOfProjectReferenceRedirect(importedFileName) ? (_a = host.getRedirectFromSourceFile(importedFileName)) == null ? void 0 : _a.outputDts : void 0;
50232
50066
  const importedPath = toPath(importedFileName, cwd, getCanonicalFileName);
50233
50067
  const redirects = host.redirectTargetsMap.get(importedPath) || emptyArray;
50234
50068
  const importedFileNames = [...referenceRedirect ? [referenceRedirect] : emptyArray, importedFileName, ...redirects];
@@ -50238,7 +50072,7 @@ function forEachFileNameOfModule(importingFileName, importedFileName, host, pref
50238
50072
  const result2 = forEach(targets, (p) => !(shouldFilterIgnoredPaths && containsIgnoredPath(p)) && cb(p, referenceRedirect === p));
50239
50073
  if (result2) return result2;
50240
50074
  }
50241
- const symlinkedDirectories = (_a = host.getSymlinkCache) == null ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
50075
+ const symlinkedDirectories = (_b = host.getSymlinkCache) == null ? void 0 : _b.call(host).getSymlinkedDirectoriesByRealpath();
50242
50076
  const fullImportedFileName = getNormalizedAbsolutePath(importedFileName, cwd);
50243
50077
  const result = symlinkedDirectories && forEachAncestorDirectoryStoppingAtGlobalCache(
50244
50078
  host,
@@ -54000,7 +53834,7 @@ function createTypeChecker(host) {
54000
53834
  return isStringLiteralLike(moduleReferenceExpression) ? resolveExternalModule(location, moduleReferenceExpression.text, moduleNotFoundError, !ignoreErrors ? moduleReferenceExpression : void 0, isForAugmentation) : void 0;
54001
53835
  }
54002
53836
  function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation = false) {
54003
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
53837
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
54004
53838
  if (errorNode && startsWith(moduleReference, "@types/")) {
54005
53839
  const diag2 = Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
54006
53840
  const withoutAtTypePrefix = removePrefix(moduleReference, "@types/");
@@ -54059,7 +53893,7 @@ function createTypeChecker(host) {
54059
53893
  getAnyExtensionFromPath(moduleReference)
54060
53894
  );
54061
53895
  } else if (resolvedModule.resolvedUsingTsExtension && shouldRewrite) {
54062
- const redirect = host.getResolvedProjectReferenceToRedirect(sourceFile.path);
53896
+ const redirect = (_i = host.getRedirectFromSourceFile(sourceFile.path)) == null ? void 0 : _i.resolvedRef;
54063
53897
  if (redirect) {
54064
53898
  const ignoreCase = !host.useCaseSensitiveFileNames();
54065
53899
  const ownRootDir = host.getCommonSourceDirectory();
@@ -54099,7 +53933,7 @@ function createTypeChecker(host) {
54099
53933
  if (ext === ".ts" /* Ts */ || ext === ".js" /* Js */ || ext === ".tsx" /* Tsx */ || ext === ".jsx" /* Jsx */) {
54100
53934
  diagnosticDetails = createModeMismatchDetails(currentSourceFile);
54101
53935
  }
54102
- const message = (overrideHost == null ? void 0 : overrideHost.kind) === 272 /* ImportDeclaration */ && ((_i = overrideHost.importClause) == null ? void 0 : _i.isTypeOnly) ? Diagnostics.Type_only_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute : (overrideHost == null ? void 0 : overrideHost.kind) === 205 /* ImportType */ ? Diagnostics.Type_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute : Diagnostics.The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead;
53936
+ const message = (overrideHost == null ? void 0 : overrideHost.kind) === 272 /* ImportDeclaration */ && ((_j = overrideHost.importClause) == null ? void 0 : _j.isTypeOnly) ? Diagnostics.Type_only_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute : (overrideHost == null ? void 0 : overrideHost.kind) === 205 /* ImportType */ ? Diagnostics.Type_import_of_an_ECMAScript_module_from_a_CommonJS_module_must_have_a_resolution_mode_attribute : Diagnostics.The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead;
54103
53937
  diagnostics.add(createDiagnosticForNodeFromMessageChain(
54104
53938
  getSourceFileOfNode(errorNode),
54105
53939
  errorNode,
@@ -54147,9 +53981,9 @@ function createTypeChecker(host) {
54147
53981
  }
54148
53982
  if (moduleNotFoundError) {
54149
53983
  if (resolvedModule) {
54150
- const redirect = host.getProjectReferenceRedirect(resolvedModule.resolvedFileName);
54151
- if (redirect) {
54152
- error2(errorNode, Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, redirect, resolvedModule.resolvedFileName);
53984
+ const redirect = host.getRedirectFromSourceFile(resolvedModule.resolvedFileName);
53985
+ if (redirect == null ? void 0 : redirect.outputDts) {
53986
+ error2(errorNode, Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, redirect.outputDts, resolvedModule.resolvedFileName);
54153
53987
  return void 0;
54154
53988
  }
54155
53989
  }
@@ -54162,14 +53996,14 @@ function createTypeChecker(host) {
54162
53996
  error2(errorNode, Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
54163
53997
  } else if (mode === 99 /* ESNext */ && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) {
54164
53998
  const absoluteRef = getNormalizedAbsolutePath(moduleReference, getDirectoryPath(currentSourceFile.path));
54165
- const suggestedExt = (_j = suggestedExtensions.find(([actualExt, _importExt]) => host.fileExists(absoluteRef + actualExt))) == null ? void 0 : _j[1];
53999
+ const suggestedExt = (_k = suggestedExtensions.find(([actualExt, _importExt]) => host.fileExists(absoluteRef + actualExt))) == null ? void 0 : _k[1];
54166
54000
  if (suggestedExt) {
54167
54001
  error2(errorNode, Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_node16_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt);
54168
54002
  } else {
54169
54003
  error2(errorNode, Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_ECMAScript_imports_when_moduleResolution_is_node16_or_nodenext_Consider_adding_an_extension_to_the_import_path);
54170
54004
  }
54171
54005
  } else {
54172
- if ((_k = host.getResolvedModule(currentSourceFile, moduleReference, mode)) == null ? void 0 : _k.alternateResult) {
54006
+ if ((_l = host.getResolvedModule(currentSourceFile, moduleReference, mode)) == null ? void 0 : _l.alternateResult) {
54173
54007
  const errorInfo = createModuleNotFoundChain(currentSourceFile, host, moduleReference, mode, moduleReference);
54174
54008
  errorOrSuggestion(
54175
54009
  /*isError*/
@@ -94772,7 +94606,7 @@ function createBasicNodeBuilderModuleSpecifierResolutionHost(host) {
94772
94606
  },
94773
94607
  useCaseSensitiveFileNames: () => host.useCaseSensitiveFileNames(),
94774
94608
  redirectTargetsMap: host.redirectTargetsMap,
94775
- getProjectReferenceRedirect: (fileName) => host.getProjectReferenceRedirect(fileName),
94609
+ getRedirectFromSourceFile: (fileName) => host.getRedirectFromSourceFile(fileName),
94776
94610
  isSourceOfProjectReferenceRedirect: (fileName) => host.isSourceOfProjectReferenceRedirect(fileName),
94777
94611
  fileExists: (fileName) => host.fileExists(fileName),
94778
94612
  getFileIncludeReasons: () => host.getFileIncludeReasons(),
@@ -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;
@@ -126881,8 +126711,8 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
126881
126711
  const filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? /* @__PURE__ */ new Map() : void 0;
126882
126712
  let resolvedProjectReferences;
126883
126713
  let projectReferenceRedirects;
126884
- let mapFromFileToProjectReferenceRedirects;
126885
- let mapFromToProjectReferenceRedirectSource;
126714
+ let mapSourceFileToResolvedRef;
126715
+ let mapOutputFileToResolvedRef;
126886
126716
  const useSourceOfProjectReferenceRedirect = !!((_d = host.useSourceOfProjectReferenceRedirect) == null ? void 0 : _d.call(host)) && !options.disableSourceOfProjectReferenceRedirect;
126887
126717
  const { onProgramCreateComplete, fileExists, directoryExists } = updateHostForUseSourceOfProjectReferenceRedirect({
126888
126718
  compilerHost: host,
@@ -126890,7 +126720,7 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
126890
126720
  useSourceOfProjectReferenceRedirect,
126891
126721
  toPath: toPath3,
126892
126722
  getResolvedProjectReferences,
126893
- getSourceOfProjectReferenceRedirect,
126723
+ getRedirectFromOutput,
126894
126724
  forEachResolvedProjectReference: forEachResolvedProjectReference2
126895
126725
  });
126896
126726
  const readFile = host.readFile.bind(host);
@@ -126947,10 +126777,9 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
126947
126777
  automaticTypeDirectiveResolutions = createModeAwareCache();
126948
126778
  if (automaticTypeDirectiveNames.length) {
126949
126779
  (_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
- );
126780
+ const containingDirectory = options.configFilePath ? getDirectoryPath(options.configFilePath) : currentDirectory;
126781
+ const containingFilename = combinePaths(containingDirectory, inferredTypesContainingFile);
126782
+ const resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(automaticTypeDirectiveNames, containingFilename);
126954
126783
  for (let i = 0; i < automaticTypeDirectiveNames.length; i++) {
126955
126784
  automaticTypeDirectiveResolutions.set(
126956
126785
  automaticTypeDirectiveNames[i],
@@ -126971,17 +126800,6 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
126971
126800
  );
126972
126801
  }
126973
126802
  (_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
126803
  }
126986
126804
  if (rootNames.length && !skipDefaultLib) {
126987
126805
  const defaultLibraryFileName = getDefaultLibraryFileName();
@@ -127112,12 +126930,10 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
127112
126930
  getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics2,
127113
126931
  getProjectReferences,
127114
126932
  getResolvedProjectReferences,
127115
- getProjectReferenceRedirect,
127116
- getResolvedProjectReferenceToRedirect,
126933
+ getRedirectFromSourceFile,
127117
126934
  getResolvedProjectReferenceByPath,
127118
126935
  forEachResolvedProjectReference: forEachResolvedProjectReference2,
127119
126936
  isSourceOfProjectReferenceRedirect,
127120
- getRedirectReferenceForResolution,
127121
126937
  getRedirectReferenceForResolutionFromSourceOfProject,
127122
126938
  getCompilerOptionsForFile,
127123
126939
  getDefaultResolutionModeForFile: getDefaultResolutionModeForFile2,
@@ -127129,7 +126945,7 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
127129
126945
  readFile,
127130
126946
  directoryExists,
127131
126947
  getSymlinkCache,
127132
- realpath: (_p = host.realpath) == null ? void 0 : _p.bind(host),
126948
+ realpath: (_o = host.realpath) == null ? void 0 : _o.bind(host),
127133
126949
  useCaseSensitiveFileNames: () => host.useCaseSensitiveFileNames(),
127134
126950
  getCanonicalFileName,
127135
126951
  getFileIncludeReasons: () => programDiagnostics.getFileReasons(),
@@ -127143,7 +126959,7 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
127143
126959
  }
127144
126960
  mark("afterProgram");
127145
126961
  measure("Program", "beforeProgram", "afterProgram");
127146
- (_q = tracing) == null ? void 0 : _q.pop();
126962
+ (_p = tracing) == null ? void 0 : _p.pop();
127147
126963
  return program;
127148
126964
  function getResolvedModule(file, moduleName, mode) {
127149
126965
  var _a2;
@@ -127247,8 +127063,8 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
127247
127063
  return result;
127248
127064
  }
127249
127065
  function getRedirectReferenceForResolution(file) {
127250
- const redirect = getResolvedProjectReferenceToRedirect(file.originalFileName);
127251
- if (redirect || !isDeclarationFileName(file.originalFileName)) return redirect;
127066
+ const redirect = getRedirectFromSourceFile(file.originalFileName);
127067
+ if (redirect || !isDeclarationFileName(file.originalFileName)) return redirect == null ? void 0 : redirect.resolvedRef;
127252
127068
  const resultFromDts = getRedirectReferenceForResolutionFromSourceOfProject(file.path);
127253
127069
  if (resultFromDts) return resultFromDts;
127254
127070
  if (!host.realpath || !options.preserveSymlinks || !file.originalFileName.includes(nodeModulesPathPart)) return void 0;
@@ -127256,14 +127072,8 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
127256
127072
  return realDeclarationPath === file.path ? void 0 : getRedirectReferenceForResolutionFromSourceOfProject(realDeclarationPath);
127257
127073
  }
127258
127074
  function getRedirectReferenceForResolutionFromSourceOfProject(filePath) {
127259
- const source = getSourceOfProjectReferenceRedirect(filePath);
127260
- if (isString(source)) return getResolvedProjectReferenceToRedirect(source);
127261
- if (!source) return void 0;
127262
- return forEachResolvedProjectReference2((resolvedRef) => {
127263
- const out = resolvedRef.commandLine.options.outFile;
127264
- if (!out) return void 0;
127265
- return toPath3(out) === filePath ? resolvedRef : void 0;
127266
- });
127075
+ var _a2;
127076
+ return (_a2 = getRedirectFromOutput(filePath)) == null ? void 0 : _a2.resolvedRef;
127267
127077
  }
127268
127078
  function compareDefaultLibFiles(a, b) {
127269
127079
  return compareValues(getDefaultLibFilePriority(a), getDefaultLibFilePriority(b));
@@ -127321,7 +127131,6 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
127321
127131
  redirectedReference: getRedirectReferenceForResolution(containingFile),
127322
127132
  nameAndModeGetter: moduleResolutionNameAndModeGetter,
127323
127133
  resolutionWorker: resolveModuleNamesWorker,
127324
- onReusedResolutions: maybeBind(host, host.onReusedModuleResolutions),
127325
127134
  getResolutionFromOldProgram: (name, mode) => oldProgram == null ? void 0 : oldProgram.getResolvedModule(containingFile, name, mode),
127326
127135
  getResolved: getResolvedModuleFromResolution,
127327
127136
  canReuseResolutionsInFile: () => containingFile === (oldProgram == null ? void 0 : oldProgram.getSourceFile(containingFile.fileName)) && !hasInvalidatedResolutions(containingFile.path),
@@ -127337,7 +127146,6 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
127337
127146
  redirectedReference: containingSourceFile && getRedirectReferenceForResolution(containingSourceFile),
127338
127147
  nameAndModeGetter: typeReferenceResolutionNameAndModeGetter,
127339
127148
  resolutionWorker: resolveTypeReferenceDirectiveNamesWorker,
127340
- onReusedResolutions: maybeBind(host, host.onReusedTypeReferenceDirectiveResolutions),
127341
127149
  getResolutionFromOldProgram: (name, mode) => {
127342
127150
  var _a2;
127343
127151
  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 +127161,12 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
127353
127161
  redirectedReference,
127354
127162
  nameAndModeGetter,
127355
127163
  resolutionWorker,
127356
- onReusedResolutions,
127357
127164
  getResolutionFromOldProgram,
127358
127165
  getResolved,
127359
127166
  canReuseResolutionsInFile,
127360
127167
  resolveToOwnAmbientModule
127361
127168
  }) {
127362
- if (!entries.length) {
127363
- onReusedResolutions == null ? void 0 : onReusedResolutions(
127364
- entries,
127365
- containingSourceFile,
127366
- redirectedReference,
127367
- options
127368
- );
127369
- return emptyArray;
127370
- }
127169
+ if (!entries.length) return emptyArray;
127371
127170
  if (structureIsReused === 0 /* Not */ && (!resolveToOwnAmbientModule || !containingSourceFile.ambientModuleNames.length)) {
127372
127171
  return resolutionWorker(
127373
127172
  entries,
@@ -127422,20 +127221,8 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
127422
127221
  (unknownEntries ?? (unknownEntries = [])).push(entry);
127423
127222
  (unknownEntryIndices ?? (unknownEntryIndices = [])).push(i);
127424
127223
  }
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
- );
127224
+ if (!unknownEntries) return result;
127225
+ const resolutions = resolutionWorker(unknownEntries, containingFile, reusedNames);
127439
127226
  if (!result) return resolutions;
127440
127227
  resolutions.forEach((resolution, index) => result[unknownEntryIndices[index]] = resolution);
127441
127228
  return result;
@@ -127658,8 +127445,7 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
127658
127445
  getSourceFileByPath: program.getSourceFileByPath,
127659
127446
  getSourceFiles: program.getSourceFiles,
127660
127447
  isSourceFileFromExternalLibrary,
127661
- getResolvedProjectReferenceToRedirect,
127662
- getProjectReferenceRedirect,
127448
+ getRedirectFromSourceFile,
127663
127449
  isSourceOfProjectReferenceRedirect,
127664
127450
  getSymlinkCache,
127665
127451
  writeFile: writeFileCallback || writeFile2,
@@ -128374,9 +128160,9 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
128374
128160
  const sourceFile = getSourceFile2(fileName);
128375
128161
  if (fail) {
128376
128162
  if (!sourceFile) {
128377
- const redirect = getProjectReferenceRedirect(fileName);
128378
- if (redirect) {
128379
- fail(Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, redirect, fileName);
128163
+ const redirect = getRedirectFromSourceFile(fileName);
128164
+ if (redirect == null ? void 0 : redirect.outputDts) {
128165
+ fail(Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, redirect.outputDts, fileName);
128380
128166
  } else {
128381
128167
  fail(Diagnostics.File_0_not_found, fileName);
128382
128168
  }
@@ -128462,16 +128248,16 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
128462
128248
  return typeof result === "object" ? { ...result, languageVersion, setExternalModuleIndicator: setExternalModuleIndicator2, jsDocParsingMode: host2.jsDocParsingMode } : { languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator2, jsDocParsingMode: host2.jsDocParsingMode };
128463
128249
  }
128464
128250
  function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
128465
- var _a2, _b2;
128251
+ var _a2, _b2, _c2, _d2;
128466
128252
  const path = toPath3(fileName);
128467
128253
  if (useSourceOfProjectReferenceRedirect) {
128468
- let source = getSourceOfProjectReferenceRedirect(path);
128254
+ let source = (_a2 = getRedirectFromOutput(path)) == null ? void 0 : _a2.source;
128469
128255
  if (!source && host.realpath && options.preserveSymlinks && isDeclarationFileName(fileName) && fileName.includes(nodeModulesPathPart)) {
128470
128256
  const realPath2 = toPath3(host.realpath(fileName));
128471
- if (realPath2 !== path) source = getSourceOfProjectReferenceRedirect(realPath2);
128257
+ if (realPath2 !== path) source = (_b2 = getRedirectFromOutput(realPath2)) == null ? void 0 : _b2.source;
128472
128258
  }
128473
128259
  if (source) {
128474
- const file2 = isString(source) ? findSourceFile(source, isDefaultLib, ignoreNoDefaultLib, reason, packageId) : void 0;
128260
+ const file2 = findSourceFile(source, isDefaultLib, ignoreNoDefaultLib, reason, packageId);
128475
128261
  if (file2) addFileToFilesByName(
128476
128262
  file2,
128477
128263
  path,
@@ -128495,7 +128281,7 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
128495
128281
  const checkedName = file2.fileName;
128496
128282
  const isRedirect = toPath3(checkedName) !== toPath3(fileName);
128497
128283
  if (isRedirect) {
128498
- fileName = getProjectReferenceRedirect(fileName) || fileName;
128284
+ fileName = ((_c2 = getRedirectFromSourceFile(fileName)) == null ? void 0 : _c2.outputDts) || fileName;
128499
128285
  }
128500
128286
  const checkedAbsolutePath = getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory);
128501
128287
  const inputAbsolutePath = getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory);
@@ -128524,14 +128310,13 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
128524
128310
  }
128525
128311
  let redirectedPath;
128526
128312
  if (!useSourceOfProjectReferenceRedirect) {
128527
- const redirectProject = getProjectReferenceRedirectProject(fileName);
128528
- if (redirectProject) {
128529
- if (redirectProject.commandLine.options.outFile) {
128313
+ const redirectProject = getRedirectFromSourceFile(fileName);
128314
+ if (redirectProject == null ? void 0 : redirectProject.outputDts) {
128315
+ if (redirectProject.resolvedRef.commandLine.options.outFile) {
128530
128316
  return void 0;
128531
128317
  }
128532
- const redirect = getProjectReferenceOutputName(redirectProject, fileName);
128533
- fileName = redirect;
128534
- redirectedPath = toPath3(redirect);
128318
+ fileName = redirectProject.outputDts;
128319
+ redirectedPath = toPath3(redirectProject.outputDts);
128535
128320
  }
128536
128321
  }
128537
128322
  const sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options);
@@ -128575,7 +128360,7 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
128575
128360
  file.path = path;
128576
128361
  file.resolvedPath = toPath3(fileName);
128577
128362
  file.originalFileName = originalFileName;
128578
- file.packageJsonLocations = ((_a2 = sourceFileOptions.packageJsonLocations) == null ? void 0 : _a2.length) ? sourceFileOptions.packageJsonLocations : void 0;
128363
+ file.packageJsonLocations = ((_d2 = sourceFileOptions.packageJsonLocations) == null ? void 0 : _d2.length) ? sourceFileOptions.packageJsonLocations : void 0;
128579
128364
  file.packageJsonScope = sourceFileOptions.packageJsonScope;
128580
128365
  addFileIncludeReason(
128581
128366
  file,
@@ -128607,8 +128392,6 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
128607
128392
  processingOtherFiles.push(file);
128608
128393
  }
128609
128394
  (filesWithReferencesProcessed ?? (filesWithReferencesProcessed = /* @__PURE__ */ new Set())).add(file.path);
128610
- } else {
128611
- (_b2 = host.onSourceFileNotCreated) == null ? void 0 : _b2.call(host, sourceFileOptions);
128612
128395
  }
128613
128396
  return file;
128614
128397
  }
@@ -128632,59 +128415,17 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
128632
128415
  if (file !== void 0) missingFileNames.delete(path);
128633
128416
  else missingFileNames.set(path, fileName);
128634
128417
  }
128635
- function getProjectReferenceRedirect(fileName) {
128636
- const referencedProject = getProjectReferenceRedirectProject(fileName);
128637
- return referencedProject && getProjectReferenceOutputName(referencedProject, fileName);
128638
- }
128639
- function getProjectReferenceRedirectProject(fileName) {
128640
- if (!resolvedProjectReferences || !resolvedProjectReferences.length || isDeclarationFileName(fileName) || fileExtensionIs(fileName, ".json" /* Json */)) {
128641
- return void 0;
128642
- }
128643
- return getResolvedProjectReferenceToRedirect(fileName);
128644
- }
128645
- function getProjectReferenceOutputName(referencedProject, fileName) {
128646
- const out = referencedProject.commandLine.options.outFile;
128647
- return out ? changeExtension(out, ".d.ts" /* Dts */) : getOutputDeclarationFileName(fileName, referencedProject.commandLine, !host.useCaseSensitiveFileNames());
128648
- }
128649
- function getResolvedProjectReferenceToRedirect(fileName) {
128650
- if (mapFromFileToProjectReferenceRedirects === void 0) {
128651
- mapFromFileToProjectReferenceRedirects = /* @__PURE__ */ new Map();
128652
- forEachResolvedProjectReference2((referencedProject) => {
128653
- if (toPath3(options.configFilePath) !== referencedProject.sourceFile.path) {
128654
- referencedProject.commandLine.fileNames.forEach((f) => mapFromFileToProjectReferenceRedirects.set(toPath3(f), referencedProject.sourceFile.path));
128655
- }
128656
- });
128657
- }
128658
- const referencedProjectPath = mapFromFileToProjectReferenceRedirects.get(toPath3(fileName));
128659
- return referencedProjectPath && getResolvedProjectReferenceByPath(referencedProjectPath);
128418
+ function getRedirectFromSourceFile(fileName) {
128419
+ return mapSourceFileToResolvedRef == null ? void 0 : mapSourceFileToResolvedRef.get(toPath3(fileName));
128660
128420
  }
128661
128421
  function forEachResolvedProjectReference2(cb) {
128662
128422
  return forEachResolvedProjectReference(resolvedProjectReferences, cb);
128663
128423
  }
128664
- function getSourceOfProjectReferenceRedirect(path) {
128665
- if (!isDeclarationFileName(path)) return void 0;
128666
- if (mapFromToProjectReferenceRedirectSource === void 0) {
128667
- mapFromToProjectReferenceRedirectSource = /* @__PURE__ */ new Map();
128668
- forEachResolvedProjectReference2((resolvedRef) => {
128669
- const out = resolvedRef.commandLine.options.outFile;
128670
- if (out) {
128671
- const outputDts = changeExtension(out, ".d.ts" /* Dts */);
128672
- mapFromToProjectReferenceRedirectSource.set(toPath3(outputDts), true);
128673
- } else {
128674
- const getCommonSourceDirectory3 = memoize(() => getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()));
128675
- forEach(resolvedRef.commandLine.fileNames, (fileName) => {
128676
- if (!isDeclarationFileName(fileName) && !fileExtensionIs(fileName, ".json" /* Json */)) {
128677
- const outputDts = getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory3);
128678
- mapFromToProjectReferenceRedirectSource.set(toPath3(outputDts), fileName);
128679
- }
128680
- });
128681
- }
128682
- });
128683
- }
128684
- return mapFromToProjectReferenceRedirectSource.get(path);
128424
+ function getRedirectFromOutput(path) {
128425
+ return mapOutputFileToResolvedRef == null ? void 0 : mapOutputFileToResolvedRef.get(path);
128685
128426
  }
128686
128427
  function isSourceOfProjectReferenceRedirect(fileName) {
128687
- return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName);
128428
+ return useSourceOfProjectReferenceRedirect && !!getRedirectFromSourceFile(fileName);
128688
128429
  }
128689
128430
  function getResolvedProjectReferenceByPath(projectReferencePath) {
128690
128431
  if (!projectReferenceRedirects) {
@@ -128706,19 +128447,8 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
128706
128447
  });
128707
128448
  }
128708
128449
  function processTypeReferenceDirectives(file) {
128709
- var _a2;
128710
128450
  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
- }
128451
+ if (!typeDirectives.length) return;
128722
128452
  const resolutions = (resolvedTypeReferenceDirectiveNamesProcessing == null ? void 0 : resolvedTypeReferenceDirectiveNamesProcessing.get(file.path)) || resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectives, file);
128723
128453
  const resolutionsInFile = createModeAwareCache();
128724
128454
  (resolvedTypeReferenceDirectiveNames ?? (resolvedTypeReferenceDirectiveNames = /* @__PURE__ */ new Map())).set(file.path, resolutionsInFile);
@@ -128845,7 +128575,6 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
128845
128575
  return host.getCanonicalFileName(fileName);
128846
128576
  }
128847
128577
  function processImportedModules(file) {
128848
- var _a2;
128849
128578
  collectExternalModuleReferences(file);
128850
128579
  if (file.imports.length || file.moduleAugmentations.length) {
128851
128580
  const moduleNames = getModuleNames(file);
@@ -128864,7 +128593,7 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
128864
128593
  continue;
128865
128594
  }
128866
128595
  const isFromNodeModulesSearch = resolution.isExternalLibraryImport;
128867
- const isJsFile = !resolutionExtensionIsTSOrJson(resolution.extension) && !getProjectReferenceRedirectProject(resolution.resolvedFileName);
128596
+ const isJsFile = !resolutionExtensionIsTSOrJson(resolution.extension) && !getRedirectFromSourceFile(resolution.resolvedFileName);
128868
128597
  const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile && (!resolution.originalPath || pathContainsNodeModules(resolution.resolvedFileName));
128869
128598
  const resolvedFileName = resolution.resolvedFileName;
128870
128599
  if (isFromNodeModulesSearch) {
@@ -128889,15 +128618,6 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
128889
128618
  currentNodeModulesDepth--;
128890
128619
  }
128891
128620
  }
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
128621
  }
128902
128622
  }
128903
128623
  function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) {
@@ -128983,6 +128703,30 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
128983
128703
  sourceFile.originalFileName = refPath;
128984
128704
  const resolvedRef = { commandLine, sourceFile };
128985
128705
  projectReferenceRedirects.set(sourceFilePath, resolvedRef);
128706
+ if (options.configFile !== sourceFile) {
128707
+ mapSourceFileToResolvedRef ?? (mapSourceFileToResolvedRef = /* @__PURE__ */ new Map());
128708
+ mapOutputFileToResolvedRef ?? (mapOutputFileToResolvedRef = /* @__PURE__ */ new Map());
128709
+ let outDts;
128710
+ if (commandLine.options.outFile) {
128711
+ outDts = changeExtension(commandLine.options.outFile, ".d.ts" /* Dts */);
128712
+ mapOutputFileToResolvedRef == null ? void 0 : mapOutputFileToResolvedRef.set(toPath3(outDts), { resolvedRef });
128713
+ }
128714
+ const getCommonSourceDirectory3 = memoize(() => getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()));
128715
+ commandLine.fileNames.forEach((fileName) => {
128716
+ if (isDeclarationFileName(fileName)) return;
128717
+ const path = toPath3(fileName);
128718
+ let outputDts;
128719
+ if (!fileExtensionIs(fileName, ".json" /* Json */)) {
128720
+ if (!commandLine.options.outFile) {
128721
+ outputDts = getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory3);
128722
+ mapOutputFileToResolvedRef.set(toPath3(outputDts), { resolvedRef, source: fileName });
128723
+ } else {
128724
+ outputDts = outDts;
128725
+ }
128726
+ }
128727
+ mapSourceFileToResolvedRef.set(path, { resolvedRef, outputDts });
128728
+ });
128729
+ }
128986
128730
  if (commandLine.projectReferences) {
128987
128731
  resolvedRef.references = commandLine.projectReferences.map(parseProjectReferenceConfigFile);
128988
128732
  }
@@ -129703,7 +129447,7 @@ function updateHostForUseSourceOfProjectReferenceRedirect(host) {
129703
129447
  );
129704
129448
  }
129705
129449
  function fileExistsIfProjectReferenceDts(file) {
129706
- const source = host.getSourceOfProjectReferenceRedirect(host.toPath(file));
129450
+ const source = host.getRedirectFromOutput(host.toPath(file));
129707
129451
  return source !== void 0 ? isString(source) ? originalFileExists.call(host.compilerHost, source) : true : void 0;
129708
129452
  }
129709
129453
  function directoryExistsIfProjectReferenceDeclDir(dir) {
@@ -130247,7 +129991,8 @@ var BuilderState;
130247
129991
  return symbol && getReferencedFilesFromImportedModuleSymbol(symbol);
130248
129992
  }
130249
129993
  function getReferencedFileFromFileName(program, fileName, sourceFileDirectory, getCanonicalFileName) {
130250
- return toPath(program.getProjectReferenceRedirect(fileName) || fileName, sourceFileDirectory, getCanonicalFileName);
129994
+ var _a;
129995
+ return toPath(((_a = program.getRedirectFromSourceFile(fileName)) == null ? void 0 : _a.outputDts) || fileName, sourceFileDirectory, getCanonicalFileName);
130251
129996
  }
130252
129997
  function getReferencedFiles(program, sourceFile, getCanonicalFileName) {
130253
129998
  let referencedFiles;
@@ -132125,7 +131870,7 @@ function createAbstractBuilder(newProgramOrRootNames, hostOrOptions, oldProgramO
132125
131870
  );
132126
131871
  }
132127
131872
 
132128
- // src/compiler/sharedResolutionCache.ts
131873
+ // src/compiler/resolutionCache.ts
132129
131874
  function removeIgnoredPath(path) {
132130
131875
  if (endsWith(path, "/node_modules/.staging")) {
132131
131876
  return removeSuffix(path, "/.staging");
@@ -132256,930 +132001,24 @@ function getDirectoryOfFailedLookupWatch(dirComponents, dirPathComponents, lengt
132256
132001
  packageDirPath: packageDirLength !== void 0 ? getPathFromPathComponents(dirPathComponents, packageDirLength) : void 0
132257
132002
  };
132258
132003
  }
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
132004
+ function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath, rootPath, rootPathComponents, isRootWatchable, getCurrentDirectory, preferNonRecursiveWatch, filterCustomPath) {
132005
+ const typeRootPathComponents = getPathComponents(typeRootPath);
132006
+ if (isRootWatchable && isInDirectoryPath(rootPathComponents, typeRootPathComponents)) {
132007
+ return rootPath;
132008
+ }
132009
+ typeRoot = isRootedDiskPath(typeRoot) ? normalizePath(typeRoot) : getNormalizedAbsolutePath(typeRoot, getCurrentDirectory());
132010
+ const toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(
132011
+ getPathComponents(typeRoot),
132012
+ typeRootPathComponents,
132013
+ typeRootPathComponents.length,
132014
+ perceivedOsRootLengthForWatching(typeRootPathComponents, typeRootPathComponents.length),
132015
+ typeRootPathComponents.indexOf("node_modules"),
132016
+ rootPathComponents,
132017
+ typeRootPathComponents.lastIndexOf("node_modules"),
132018
+ preferNonRecursiveWatch
133173
132019
  );
132020
+ return toWatch && filterCustomPath(toWatch.dirPath) ? toWatch.dirPath : void 0;
133174
132021
  }
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
132022
  function getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory) {
133184
132023
  const normalized = getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory());
133185
132024
  return !isDiskPathRoot(normalized) ? removeTrailingDirectorySeparator(normalized) : normalized;
@@ -133202,157 +132041,103 @@ function createModuleResolutionLoaderUsingGlobalCache(containingFile, redirected
133202
132041
  )
133203
132042
  };
133204
132043
  }
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
132044
  function resolveModuleNameUsingGlobalCache(resolutionHost, moduleResolutionCache, moduleName, containingFile, compilerOptions, redirectedReference, mode) {
133228
- var _a;
133229
132045
  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
- };
132046
+ const primaryResult = resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode);
132047
+ if (!resolutionHost.getGlobalTypingsCacheLocation) {
132048
+ return primaryResult;
132049
+ }
132050
+ const globalCache = resolutionHost.getGlobalTypingsCacheLocation();
132051
+ if (globalCache !== void 0 && !isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && extensionIsTS(primaryResult.resolvedModule.extension))) {
132052
+ const { resolvedModule, failedLookupLocations, affectingLocations, resolutionDiagnostics } = loadModuleFromGlobalCache(
132053
+ Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName),
132054
+ resolutionHost.projectName,
132055
+ compilerOptions,
132056
+ host,
132057
+ globalCache,
132058
+ moduleResolutionCache
132059
+ );
132060
+ if (resolvedModule) {
132061
+ primaryResult.resolvedModule = resolvedModule;
132062
+ primaryResult.failedLookupLocations = updateResolutionField(primaryResult.failedLookupLocations, failedLookupLocations);
132063
+ primaryResult.affectingLocations = updateResolutionField(primaryResult.affectingLocations, affectingLocations);
132064
+ primaryResult.resolutionDiagnostics = updateResolutionField(primaryResult.resolutionDiagnostics, resolutionDiagnostics);
132065
+ return primaryResult;
132066
+ }
133258
132067
  }
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;
132068
+ return primaryResult;
133270
132069
  }
133271
- function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache = createSharedResolutionCache(resolutionHost)) {
132070
+ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
132071
+ let filesWithChangedSetOfUnresolvedImports;
133272
132072
  let filesWithInvalidatedResolutions;
132073
+ let filesWithInvalidatedNonRelativeUnresolvedImports;
132074
+ const nonRelativeExternalModuleResolutions = /* @__PURE__ */ new Set();
132075
+ const resolutionsWithFailedLookups = /* @__PURE__ */ new Set();
132076
+ const resolutionsWithOnlyAffectingLocations = /* @__PURE__ */ new Set();
132077
+ const resolvedFileToResolution = /* @__PURE__ */ new Map();
133273
132078
  const impliedFormatPackageJsons = /* @__PURE__ */ new Map();
133274
- const filesReferencingResolution = /* @__PURE__ */ new Map();
133275
132079
  let hasChangedAutomaticTypeDirectiveNames = false;
133276
132080
  let affectingPathChecksForFile;
132081
+ let affectingPathChecks;
132082
+ let failedLookupChecks;
132083
+ let startsWithPathChecks;
132084
+ let isInDirectoryChecks;
133277
132085
  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
132086
  const getCurrentDirectory = memoize(() => resolutionHost.getCurrentDirectory());
132087
+ const cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
133286
132088
  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
132089
+ const moduleResolutionCache = createModuleResolutionCache(
132090
+ getCurrentDirectory(),
132091
+ resolutionHost.getCanonicalFileName,
132092
+ resolutionHost.getCompilationSettings()
133299
132093
  );
133300
132094
  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
132095
+ const typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(
132096
+ getCurrentDirectory(),
132097
+ resolutionHost.getCanonicalFileName,
132098
+ resolutionHost.getCompilationSettings(),
132099
+ moduleResolutionCache.getPackageJsonInfoCache(),
132100
+ moduleResolutionCache.optionsToRedirectsKey
133312
132101
  );
133313
132102
  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
132103
+ const libraryResolutionCache = createModuleResolutionCache(
132104
+ getCurrentDirectory(),
132105
+ resolutionHost.getCanonicalFileName,
132106
+ getOptionsForLibraryResolution(resolutionHost.getCompilationSettings()),
132107
+ moduleResolutionCache.getPackageJsonInfoCache()
133325
132108
  );
133326
- let resolutionsResolvedWithGlobalCache = 0;
133327
- let resolutionsResolvedWithoutGlobalCache = 0;
133328
- const rootDirInfo = getRootDirInfo(rootDirForResolution);
133329
- const redirectsToRootDirInfo = /* @__PURE__ */ new Map();
132109
+ const directoryWatchesOfFailedLookups = /* @__PURE__ */ new Map();
132110
+ const fileWatchesOfAffectingLocations = /* @__PURE__ */ new Map();
132111
+ const rootDir = getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory);
132112
+ const rootPath = resolutionHost.toPath(rootDir);
132113
+ const rootPathComponents = getPathComponents(rootPath);
132114
+ const isRootWatchable = canWatchDirectoryOrFile(rootPathComponents);
132115
+ const isSymlinkCache = /* @__PURE__ */ new Map();
132116
+ const packageDirWatchers = /* @__PURE__ */ new Map();
132117
+ const dirPathToSymlinkPackageRefCount = /* @__PURE__ */ new Map();
133330
132118
  const typeRootsWatches = /* @__PURE__ */ new Map();
133331
- const cache = {
133332
- resolutionHost,
133333
- sharedCache,
132119
+ return {
133334
132120
  rootDirForResolution,
133335
132121
  resolvedModuleNames,
133336
132122
  resolvedTypeReferenceDirectives,
133337
132123
  resolvedLibraries,
133338
- moduleResolutionCache,
133339
- typeReferenceDirectiveResolutionCache,
133340
- libraryResolutionCache,
133341
- filesReferencingResolution,
133342
- typeRootsWatches,
133343
- countResolutionsResolvedWithGlobalCache: () => resolutionsResolvedWithGlobalCache,
133344
- countResolutionsResolvedWithoutGlobalCache: () => resolutionsResolvedWithoutGlobalCache,
133345
- watchResolution,
132124
+ resolvedFileToResolution,
132125
+ resolutionsWithFailedLookups,
132126
+ resolutionsWithOnlyAffectingLocations,
132127
+ directoryWatchesOfFailedLookups,
132128
+ fileWatchesOfAffectingLocations,
132129
+ packageDirWatchers,
132130
+ dirPathToSymlinkPackageRefCount,
132131
+ watchFailedLookupLocationsOfExternalModuleResolutions,
132132
+ getModuleResolutionCache: () => moduleResolutionCache,
132133
+ startRecordingFilesWithChangedResolutions,
132134
+ finishRecordingFilesWithChangedResolutions,
133346
132135
  // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
133347
132136
  // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
133348
132137
  startCachingPerDirectoryResolution,
133349
132138
  finishCachingPerDirectoryResolution,
133350
- compactCaches,
133351
132139
  resolveModuleNameLiterals,
133352
132140
  resolveTypeReferenceDirectiveReferences,
133353
- onReusedModuleResolutions,
133354
- onReusedTypeReferenceDirectiveResolutions,
133355
- onSourceFileNotCreated,
133356
132141
  resolveLibrary: resolveLibrary2,
133357
132142
  resolveSingleModuleNameWithoutWatching,
133358
132143
  removeResolutionsFromProjectReferenceRedirects,
@@ -133360,72 +132145,37 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133360
132145
  hasChangedAutomaticTypeDirectiveNames: () => hasChangedAutomaticTypeDirectiveNames,
133361
132146
  invalidateResolutionOfFile,
133362
132147
  invalidateResolutionsOfFailedLookupLocations,
133363
- invalidateResolutionsWithGlobalCachePass,
133364
- invalidateResolutionsWithoutGlobalCachePass,
133365
- invalidateUnresolvedResolutionsWithGlobalCachePass,
132148
+ setFilesWithInvalidatedNonRelativeUnresolvedImports,
133366
132149
  createHasInvalidatedResolutions,
132150
+ isFileWithInvalidatedNonRelativeUnresolvedImports,
133367
132151
  updateTypeRootsWatch,
133368
132152
  closeTypeRootsWatch,
133369
132153
  clear: clear2,
133370
- onChangesAffectModuleResolution,
133371
- // Used by shared cache
133372
- getRootDirInfoForResolution: maybeBind(resolutionHost, resolutionHost.getRootDirInfoForResolution) ?? getRootDirInfoOfRedirectedReference,
133373
- invalidateAffectingFileWatcher,
133374
- invalidateResolution,
133375
- invalidateTypeRoot,
133376
- getValidResolution
132154
+ onChangesAffectModuleResolution
133377
132155
  };
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
132156
  function clear2() {
133411
- pendingRemoveResolutionsOfFile = void 0;
133412
- potentiallyUnreferencedResolutions = void 0;
133413
- newUnresolvedResolutionCachePassResolutions = void 0;
133414
- redirectsToRootDirInfo.clear();
132157
+ clearMap(directoryWatchesOfFailedLookups, closeFileWatcherOf);
132158
+ clearMap(fileWatchesOfAffectingLocations, closeFileWatcherOf);
132159
+ isSymlinkCache.clear();
132160
+ packageDirWatchers.clear();
132161
+ dirPathToSymlinkPackageRefCount.clear();
132162
+ nonRelativeExternalModuleResolutions.clear();
133415
132163
  closeTypeRootsWatch();
133416
- sharedCache.clear(cache);
133417
132164
  resolvedModuleNames.clear();
133418
132165
  resolvedTypeReferenceDirectives.clear();
133419
- filesReferencingResolution.clear();
133420
- resolutionsResolvedWithGlobalCache = 0;
133421
- resolutionsResolvedWithoutGlobalCache = 0;
132166
+ resolvedFileToResolution.clear();
132167
+ resolutionsWithFailedLookups.clear();
132168
+ resolutionsWithOnlyAffectingLocations.clear();
132169
+ failedLookupChecks = void 0;
132170
+ startsWithPathChecks = void 0;
132171
+ isInDirectoryChecks = void 0;
132172
+ affectingPathChecks = void 0;
133422
132173
  affectingPathChecksForFile = void 0;
133423
132174
  allModuleAndTypeResolutionsAreInvalidated = false;
133424
- resolutionsWithGlobalCachePassAreInvalidated = false;
133425
- resolutionsWithoutGlobalCachePassAreInvalidated = false;
133426
- unresolvedResolutionsWithGlobalCachePassAreInvalidated = false;
133427
132175
  moduleResolutionCache.clear();
133428
132176
  typeReferenceDirectiveResolutionCache.clear();
132177
+ moduleResolutionCache.update(resolutionHost.getCompilationSettings());
132178
+ typeReferenceDirectiveResolutionCache.update(resolutionHost.getCompilationSettings());
133429
132179
  libraryResolutionCache.clear();
133430
132180
  impliedFormatPackageJsons.clear();
133431
132181
  resolvedLibraries.clear();
@@ -133433,28 +132183,48 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133433
132183
  }
133434
132184
  function onChangesAffectModuleResolution() {
133435
132185
  allModuleAndTypeResolutionsAreInvalidated = true;
132186
+ moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
132187
+ typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
132188
+ moduleResolutionCache.update(resolutionHost.getCompilationSettings());
132189
+ typeReferenceDirectiveResolutionCache.update(resolutionHost.getCompilationSettings());
132190
+ }
132191
+ function startRecordingFilesWithChangedResolutions() {
132192
+ filesWithChangedSetOfUnresolvedImports = [];
132193
+ }
132194
+ function finishRecordingFilesWithChangedResolutions() {
132195
+ const collected = filesWithChangedSetOfUnresolvedImports;
132196
+ filesWithChangedSetOfUnresolvedImports = void 0;
132197
+ return collected;
132198
+ }
132199
+ function isFileWithInvalidatedNonRelativeUnresolvedImports(path) {
132200
+ if (!filesWithInvalidatedNonRelativeUnresolvedImports) {
132201
+ return false;
132202
+ }
132203
+ const value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
132204
+ return !!value && !!value.length;
133436
132205
  }
133437
132206
  function createHasInvalidatedResolutions(customHasInvalidatedResolutions, customHasInvalidatedLibResolutions) {
133438
132207
  invalidateResolutionsOfFailedLookupLocations();
133439
132208
  const collected = filesWithInvalidatedResolutions;
133440
132209
  filesWithInvalidatedResolutions = void 0;
133441
132210
  return {
133442
- hasInvalidatedResolutions: (path) => customHasInvalidatedResolutions(path) || allModuleAndTypeResolutionsAreInvalidated || resolutionsWithGlobalCachePassAreInvalidated || resolutionsWithoutGlobalCachePassAreInvalidated || unresolvedResolutionsWithGlobalCachePassAreInvalidated || !!(collected == null ? void 0 : collected.has(path)),
132211
+ hasInvalidatedResolutions: (path) => customHasInvalidatedResolutions(path) || allModuleAndTypeResolutionsAreInvalidated || !!(collected == null ? void 0 : collected.has(path)) || isFileWithInvalidatedNonRelativeUnresolvedImports(path),
133443
132212
  hasInvalidatedLibResolutions: (libFileName) => {
133444
132213
  var _a;
133445
- return customHasInvalidatedLibResolutions(libFileName) || !!((_a = sharedCache.watchedResolutionInfoMap.get(resolvedLibraries == null ? void 0 : resolvedLibraries.get(libFileName))) == null ? void 0 : _a.isInvalidated);
132214
+ return customHasInvalidatedLibResolutions(libFileName) || !!((_a = resolvedLibraries == null ? void 0 : resolvedLibraries.get(libFileName)) == null ? void 0 : _a.isInvalidated);
133446
132215
  }
133447
132216
  };
133448
132217
  }
133449
- function startCachingPerDirectoryResolution(options) {
132218
+ function startCachingPerDirectoryResolution() {
133450
132219
  moduleResolutionCache.isReadonly = void 0;
133451
132220
  typeReferenceDirectiveResolutionCache.isReadonly = void 0;
133452
132221
  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;
132222
+ moduleResolutionCache.getPackageJsonInfoCache().isReadonly = void 0;
132223
+ moduleResolutionCache.clearAllExceptPackageJsonInfoCache();
132224
+ typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache();
132225
+ libraryResolutionCache.clearAllExceptPackageJsonInfoCache();
132226
+ watchFailedLookupLocationOfNonRelativeModuleResolutions();
132227
+ isSymlinkCache.clear();
133458
132228
  }
133459
132229
  function cleanupLibResolutionWatching(newProgram) {
133460
132230
  resolvedLibraries.forEach((resolution, libFileName) => {
@@ -133463,35 +132233,32 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133463
132233
  stopWatchFailedLookupLocationOfResolution(
133464
132234
  resolution,
133465
132235
  resolutionHost.toPath(getInferredLibraryNameResolveFrom(resolutionHost.getCompilationSettings(), getCurrentDirectory(), libFileName)),
133466
- libraryResolutionCache
132236
+ getResolvedModuleFromResolution
133467
132237
  );
133468
132238
  resolvedLibraries.delete(libFileName);
133469
132239
  }
133470
132240
  });
133471
132241
  }
133472
- function finishCachingPerDirectoryResolution(newProgram, oldProgram, skipCacheCompact) {
132242
+ function finishCachingPerDirectoryResolution(newProgram, oldProgram) {
132243
+ filesWithInvalidatedNonRelativeUnresolvedImports = void 0;
133473
132244
  allModuleAndTypeResolutionsAreInvalidated = false;
133474
- resolutionsWithGlobalCachePassAreInvalidated = false;
133475
- resolutionsWithoutGlobalCachePassAreInvalidated = false;
133476
- unresolvedResolutionsWithGlobalCachePassAreInvalidated = false;
133477
- newUnresolvedResolutionCachePassResolutions = void 0;
133478
- let potentiallyUnReferencedFileWatcherOfAffectingLocation;
132245
+ watchFailedLookupLocationOfNonRelativeModuleResolutions();
133479
132246
  if (newProgram !== oldProgram) {
133480
- const releaseFileWatcherOfAffectingLocation = (location) => {
133481
- sharedCache.releaseFileWatcherOfAffectingLocation(location);
133482
- (potentiallyUnReferencedFileWatcherOfAffectingLocation ?? (potentiallyUnReferencedFileWatcherOfAffectingLocation = /* @__PURE__ */ new Set())).add(location);
133483
- };
133484
132247
  cleanupLibResolutionWatching(newProgram);
133485
132248
  newProgram == null ? void 0 : newProgram.getSourceFiles().forEach((newFile) => {
133486
132249
  var _a;
133487
132250
  const expected = ((_a = newFile.packageJsonLocations) == null ? void 0 : _a.length) ?? 0;
133488
132251
  const existing = impliedFormatPackageJsons.get(newFile.resolvedPath) ?? emptyArray;
133489
132252
  for (let i = existing.length; i < expected; i++) {
133490
- sharedCache.createFileWatcherOfAffectingLocation(newFile.packageJsonLocations[i]);
132253
+ createFileWatcherOfAffectingLocation(
132254
+ newFile.packageJsonLocations[i],
132255
+ /*forResolution*/
132256
+ false
132257
+ );
133491
132258
  }
133492
132259
  if (existing.length > expected) {
133493
132260
  for (let i = expected; i < existing.length; i++) {
133494
- releaseFileWatcherOfAffectingLocation(existing[i]);
132261
+ fileWatchesOfAffectingLocations.get(existing[i]).files--;
133495
132262
  }
133496
132263
  }
133497
132264
  if (expected) impliedFormatPackageJsons.set(newFile.resolvedPath, newFile.packageJsonLocations);
@@ -133500,68 +132267,38 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133500
132267
  impliedFormatPackageJsons.forEach((existing, path) => {
133501
132268
  const newFile = newProgram == null ? void 0 : newProgram.getSourceFileByPath(path);
133502
132269
  if (!newFile || newFile.resolvedPath !== path) {
133503
- existing.forEach(releaseFileWatcherOfAffectingLocation);
132270
+ existing.forEach((location) => fileWatchesOfAffectingLocations.get(location).files--);
133504
132271
  impliedFormatPackageJsons.delete(path);
133505
132272
  }
133506
132273
  });
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
132274
  }
133515
- sharedCache.finishCachingPerDirectoryResolution();
132275
+ directoryWatchesOfFailedLookups.forEach(closeDirectoryWatchesOfFailedLookup);
132276
+ fileWatchesOfAffectingLocations.forEach(closeFileWatcherOfAffectingLocation);
132277
+ packageDirWatchers.forEach(closePackageDirWatcher);
133516
132278
  hasChangedAutomaticTypeDirectiveNames = false;
133517
- if (!skipCacheCompact) compactCaches(newProgram);
133518
132279
  moduleResolutionCache.isReadonly = true;
133519
132280
  typeReferenceDirectiveResolutionCache.isReadonly = true;
133520
132281
  libraryResolutionCache.isReadonly = true;
133521
132282
  moduleResolutionCache.getPackageJsonInfoCache().isReadonly = true;
132283
+ isSymlinkCache.clear();
133522
132284
  }
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
- });
132285
+ function closePackageDirWatcher(watcher, packageDirPath) {
132286
+ if (watcher.dirPathToWatcher.size === 0) {
132287
+ packageDirWatchers.delete(packageDirPath);
133530
132288
  }
133531
- moduleResolutionCache.compact(
133532
- availableOptions,
133533
- /*skipOptionsToRedirectsKeyCleanup*/
133534
- true
133535
- );
133536
- typeReferenceDirectiveResolutionCache.compact(availableOptions);
133537
- libraryResolutionCache.compact();
133538
- sharedCache.compactCaches(availableOptions, cache);
133539
132289
  }
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;
132290
+ function closeDirectoryWatchesOfFailedLookup(watcher, path) {
132291
+ if (watcher.refCount === 0) {
132292
+ directoryWatchesOfFailedLookups.delete(path);
132293
+ watcher.watcher.close();
133547
132294
  }
133548
132295
  }
133549
- function onSourceFileNotCreated(sourceFileOptions) {
132296
+ function closeFileWatcherOfAffectingLocation(watcher, path) {
133550
132297
  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) {
133557
- 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);
132298
+ if (watcher.files === 0 && watcher.resolutions === 0 && !((_a = watcher.symlinks) == null ? void 0 : _a.size)) {
132299
+ fileWatchesOfAffectingLocations.delete(path);
132300
+ watcher.watcher.close();
132301
+ }
133565
132302
  }
133566
132303
  function resolveNamesWithLocalCache({
133567
132304
  entries,
@@ -133570,24 +132307,28 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133570
132307
  redirectedReference,
133571
132308
  options,
133572
132309
  perFileCache,
133573
- moduleOrTypeRefCache,
133574
132310
  reusedNames,
133575
132311
  loader,
133576
132312
  getResolutionWithResolvedFileName,
133577
- onNewResolution
132313
+ deferWatchingNonRelativeResolution,
132314
+ shouldRetryResolution,
132315
+ logChanges
133578
132316
  }) {
132317
+ var _a;
133579
132318
  const path = resolutionHost.toPath(containingFile);
133580
132319
  const resolutionsInFile = perFileCache.get(path) || perFileCache.set(path, createModeAwareCache()).get(path);
133581
132320
  const resolvedModules = [];
132321
+ const hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
133582
132322
  const program = resolutionHost.getCurrentProgram();
133583
- const oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
132323
+ const oldRedirect = program && ((_a = program.getRedirectFromSourceFile(containingFile)) == null ? void 0 : _a.resolvedRef);
133584
132324
  const unmatchedRedirects = oldRedirect ? !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path : !!redirectedReference;
133585
132325
  const seenNamesInFile = createModeAwareCache();
133586
132326
  for (const entry of entries) {
133587
132327
  const name = loader.nameAndMode.getName(entry);
133588
132328
  const mode = loader.nameAndMode.getMode(entry, containingSourceFile, (redirectedReference == null ? void 0 : redirectedReference.commandLine.options) || options);
133589
132329
  let resolution = resolutionsInFile.get(name, mode);
133590
- if (!seenNamesInFile.has(name, mode) && (allModuleAndTypeResolutionsAreInvalidated || unmatchedRedirects || isInvalidatedResolution(resolution))) {
132330
+ if (!seenNamesInFile.has(name, mode) && (allModuleAndTypeResolutionsAreInvalidated || unmatchedRedirects || !resolution || resolution.isInvalidated || // If the name is unresolved import that was invalidated, recalculate
132331
+ hasInvalidatedNonRelativeUnresolvedImport && !isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
133591
132332
  const existingResolution = resolution;
133592
132333
  resolution = loader.resolve(name, mode);
133593
132334
  if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
@@ -133595,15 +132336,15 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133595
132336
  }
133596
132337
  resolutionsInFile.set(name, mode, resolution);
133597
132338
  if (resolution !== existingResolution) {
133598
- watchResolution(resolution, path, getResolutionWithResolvedFileName, redirectedReference);
132339
+ watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName, deferWatchingNonRelativeResolution);
133599
132340
  if (existingResolution) {
133600
- stopWatchFailedLookupLocationOfResolution(existingResolution, path, moduleOrTypeRefCache);
132341
+ stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
133601
132342
  }
133602
132343
  }
133603
- if (isInvalidatedUnResolvedGlobalCachePassResolution(resolution)) {
133604
- (newUnresolvedResolutionCachePassResolutions ?? (newUnresolvedResolutionCachePassResolutions = /* @__PURE__ */ new Set())).add(resolution);
132344
+ if (logChanges && filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) {
132345
+ filesWithChangedSetOfUnresolvedImports.push(path);
132346
+ logChanges = false;
133605
132347
  }
133606
- onNewResolution == null ? void 0 : onNewResolution(existingResolution, resolution, path, name, mode);
133607
132348
  } else {
133608
132349
  const host = getModuleResolutionHost(resolutionHost);
133609
132350
  if (isTraceEnabled(options, host) && !seenNamesInFile.has(name, mode)) {
@@ -133618,76 +132359,43 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133618
132359
  );
133619
132360
  }
133620
132361
  }
133621
- Debug.assert(resolution !== void 0 && !sharedCache.watchedResolutionInfoMap.get(resolution).isInvalidated);
132362
+ Debug.assert(resolution !== void 0 && !resolution.isInvalidated);
133622
132363
  seenNamesInFile.set(name, mode, true);
133623
132364
  resolvedModules.push(resolution);
133624
132365
  }
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
132366
  reusedNames == null ? void 0 : reusedNames.forEach(
133652
132367
  (entry) => seenNamesInFile.set(
133653
- nameAndModeGetter.getName(entry),
133654
- nameAndModeGetter.getMode(entry, containingSourceFile, (redirectedReference == null ? void 0 : redirectedReference.commandLine.options) || options),
132368
+ loader.nameAndMode.getName(entry),
132369
+ loader.nameAndMode.getMode(entry, containingSourceFile, (redirectedReference == null ? void 0 : redirectedReference.commandLine.options) || options),
133655
132370
  true
133656
132371
  )
133657
132372
  );
133658
132373
  if (resolutionsInFile.size() !== seenNamesInFile.size()) {
133659
132374
  resolutionsInFile.forEach((resolution, name, mode) => {
133660
132375
  if (!seenNamesInFile.has(name, mode)) {
133661
- stopWatchFailedLookupLocationOfResolution(resolution, path, moduleOrTypeRefCache);
132376
+ stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
133662
132377
  resolutionsInFile.delete(name, mode);
133663
132378
  }
133664
132379
  });
133665
132380
  }
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
- });
132381
+ return resolvedModules;
132382
+ function resolutionIsEqualTo(oldResolution, newResolution) {
132383
+ if (oldResolution === newResolution) {
132384
+ return true;
132385
+ }
132386
+ if (!oldResolution || !newResolution) {
132387
+ return false;
132388
+ }
132389
+ const oldResult = getResolutionWithResolvedFileName(oldResolution);
132390
+ const newResult = getResolutionWithResolvedFileName(newResolution);
132391
+ if (oldResult === newResult) {
132392
+ return true;
132393
+ }
132394
+ if (!oldResult || !newResult) {
132395
+ return false;
132396
+ }
132397
+ return oldResult.resolvedFileName === newResult.resolvedFileName;
132398
+ }
133691
132399
  }
133692
132400
  function resolveTypeReferenceDirectiveReferences(typeDirectiveReferences, containingFile, redirectedReference, options, containingSourceFile, reusedNames) {
133693
132401
  return resolveNamesWithLocalCache({
@@ -133698,7 +132406,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133698
132406
  options,
133699
132407
  reusedNames,
133700
132408
  perFileCache: resolvedTypeReferenceDirectives,
133701
- moduleOrTypeRefCache: typeReferenceDirectiveResolutionCache,
133702
132409
  loader: createTypeReferenceResolutionLoader(
133703
132410
  containingFile,
133704
132411
  redirectedReference,
@@ -133706,10 +132413,12 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133706
132413
  getModuleResolutionHost(resolutionHost),
133707
132414
  typeReferenceDirectiveResolutionCache
133708
132415
  ),
133709
- getResolutionWithResolvedFileName: getResolvedTypeReferenceDirectiveFromResolution
132416
+ getResolutionWithResolvedFileName: getResolvedTypeReferenceDirectiveFromResolution,
132417
+ shouldRetryResolution: (resolution) => resolution.resolvedTypeReferenceDirective === void 0,
132418
+ deferWatchingNonRelativeResolution: false
133710
132419
  });
133711
132420
  }
133712
- function resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options, containingSourceFile, reusedNames, onNewResolution) {
132421
+ function resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options, containingSourceFile, reusedNames) {
133713
132422
  return resolveNamesWithLocalCache({
133714
132423
  entries: moduleLiterals,
133715
132424
  containingFile,
@@ -133718,7 +132427,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133718
132427
  options,
133719
132428
  reusedNames,
133720
132429
  perFileCache: resolvedModuleNames,
133721
- moduleOrTypeRefCache: moduleResolutionCache,
133722
132430
  loader: createModuleResolutionLoaderUsingGlobalCache(
133723
132431
  containingFile,
133724
132432
  redirectedReference,
@@ -133727,26 +132435,30 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133727
132435
  moduleResolutionCache
133728
132436
  ),
133729
132437
  getResolutionWithResolvedFileName: getResolvedModuleFromResolution,
133730
- onNewResolution
132438
+ shouldRetryResolution: (resolution) => !resolution.resolvedModule || !resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension),
132439
+ logChanges: logChangesWhenResolvingModule,
132440
+ deferWatchingNonRelativeResolution: true
132441
+ // Defer non relative resolution watch because we could be using ambient modules
133731
132442
  });
133732
132443
  }
133733
132444
  function resolveLibrary2(libraryName, resolveFrom, options, libFileName) {
133734
132445
  const host = getModuleResolutionHost(resolutionHost);
133735
132446
  let resolution = resolvedLibraries == null ? void 0 : resolvedLibraries.get(libFileName);
133736
- if (isInvalidatedResolution(resolution)) {
132447
+ if (!resolution || resolution.isInvalidated) {
133737
132448
  const existingResolution = resolution;
133738
132449
  resolution = resolveLibrary(libraryName, resolveFrom, options, host, libraryResolutionCache);
133739
132450
  const path = resolutionHost.toPath(resolveFrom);
133740
- watchResolution(
132451
+ watchFailedLookupLocationsOfExternalModuleResolutions(
132452
+ libraryName,
133741
132453
  resolution,
133742
132454
  path,
133743
132455
  getResolvedModuleFromResolution,
133744
- /*redirectedReference*/
133745
- void 0
132456
+ /*deferWatchingNonRelativeResolution*/
132457
+ false
133746
132458
  );
133747
132459
  resolvedLibraries.set(libFileName, resolution);
133748
132460
  if (existingResolution) {
133749
- stopWatchFailedLookupLocationOfResolution(existingResolution, path, libraryResolutionCache);
132461
+ stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolvedModuleFromResolution);
133750
132462
  }
133751
132463
  } else {
133752
132464
  if (isTraceEnabled(options, host)) {
@@ -133772,7 +132484,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133772
132484
  /*mode*/
133773
132485
  void 0
133774
132486
  );
133775
- if (resolution && !sharedCache.watchedResolutionInfoMap.get(resolution).isInvalidated) return resolution;
132487
+ if (resolution && !resolution.isInvalidated) return resolution;
133776
132488
  const data = (_a = resolutionHost.beforeResolveSingleModuleNameWithoutWatching) == null ? void 0 : _a.call(resolutionHost, moduleResolutionCache);
133777
132489
  const host = getModuleResolutionHost(resolutionHost);
133778
132490
  const result = resolveModuleName(
@@ -133785,48 +132497,306 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133785
132497
  (_b = resolutionHost.afterResolveSingleModuleNameWithoutWatching) == null ? void 0 : _b.call(resolutionHost, moduleResolutionCache, moduleName, containingFile, result, data);
133786
132498
  return result;
133787
132499
  }
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;
132500
+ function isNodeModulesAtTypesDirectory(dirPath) {
132501
+ return endsWith(dirPath, "/node_modules/@types");
132502
+ }
132503
+ function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName, deferWatchingNonRelativeResolution) {
132504
+ (resolution.files ?? (resolution.files = /* @__PURE__ */ new Set())).add(filePath);
132505
+ if (resolution.files.size !== 1) return;
132506
+ if (!deferWatchingNonRelativeResolution || isExternalModuleNameRelative(name)) {
132507
+ watchFailedLookupLocationOfResolution(resolution);
132508
+ } else {
132509
+ nonRelativeExternalModuleResolutions.add(resolution);
132510
+ }
132511
+ const resolved = getResolutionWithResolvedFileName(resolution);
132512
+ if (resolved && resolved.resolvedFileName) {
132513
+ const key = resolutionHost.toPath(resolved.resolvedFileName);
132514
+ let resolutions = resolvedFileToResolution.get(key);
132515
+ if (!resolutions) resolvedFileToResolution.set(key, resolutions = /* @__PURE__ */ new Set());
132516
+ resolutions.add(resolution);
132517
+ }
132518
+ }
132519
+ function watchFailedLookupLocation(failedLookupLocation, setAtRoot) {
132520
+ const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
132521
+ const toWatch = getDirectoryToWatchFailedLookupLocation(
132522
+ failedLookupLocation,
132523
+ failedLookupLocationPath,
132524
+ rootDir,
132525
+ rootPath,
132526
+ rootPathComponents,
132527
+ isRootWatchable,
132528
+ getCurrentDirectory,
132529
+ resolutionHost.preferNonRecursiveWatch
132530
+ );
132531
+ if (toWatch) {
132532
+ const { dir, dirPath, nonRecursive, packageDir, packageDirPath } = toWatch;
132533
+ if (dirPath === rootPath) {
132534
+ Debug.assert(nonRecursive);
132535
+ Debug.assert(!packageDir);
132536
+ setAtRoot = true;
132537
+ } else {
132538
+ setDirectoryWatcher(dir, dirPath, packageDir, packageDirPath, nonRecursive);
132539
+ }
132540
+ }
132541
+ return setAtRoot;
132542
+ }
132543
+ function watchFailedLookupLocationOfResolution(resolution) {
132544
+ var _a;
132545
+ Debug.assert(!!((_a = resolution.files) == null ? void 0 : _a.size));
132546
+ const { failedLookupLocations, affectingLocations, alternateResult } = resolution;
132547
+ if (!(failedLookupLocations == null ? void 0 : failedLookupLocations.length) && !(affectingLocations == null ? void 0 : affectingLocations.length) && !alternateResult) return;
132548
+ if ((failedLookupLocations == null ? void 0 : failedLookupLocations.length) || alternateResult) resolutionsWithFailedLookups.add(resolution);
132549
+ let setAtRoot = false;
132550
+ if (failedLookupLocations) {
132551
+ for (const failedLookupLocation of failedLookupLocations) {
132552
+ setAtRoot = watchFailedLookupLocation(failedLookupLocation, setAtRoot);
132553
+ }
132554
+ }
132555
+ if (alternateResult) setAtRoot = watchFailedLookupLocation(alternateResult, setAtRoot);
132556
+ if (setAtRoot) {
132557
+ setDirectoryWatcher(
132558
+ rootDir,
132559
+ rootPath,
132560
+ /*packageDir*/
132561
+ void 0,
132562
+ /*packageDirPath*/
132563
+ void 0,
132564
+ /*nonRecursive*/
132565
+ true
132566
+ );
132567
+ }
132568
+ watchAffectingLocationsOfResolution(resolution, !(failedLookupLocations == null ? void 0 : failedLookupLocations.length) && !alternateResult);
132569
+ }
132570
+ function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
132571
+ var _a;
132572
+ Debug.assert(!!((_a = resolution.files) == null ? void 0 : _a.size));
132573
+ const { affectingLocations } = resolution;
132574
+ if (!(affectingLocations == null ? void 0 : affectingLocations.length)) return;
132575
+ if (addToResolutionsWithOnlyAffectingLocations) resolutionsWithOnlyAffectingLocations.add(resolution);
132576
+ for (const affectingLocation of affectingLocations) {
132577
+ createFileWatcherOfAffectingLocation(
132578
+ affectingLocation,
132579
+ /*forResolution*/
132580
+ true
132581
+ );
132582
+ }
132583
+ }
132584
+ function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) {
132585
+ const fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation);
132586
+ if (fileWatcher) {
132587
+ if (forResolution) fileWatcher.resolutions++;
132588
+ else fileWatcher.files++;
132589
+ return;
132590
+ }
132591
+ let locationToWatch = affectingLocation;
132592
+ let isSymlink = false;
132593
+ let symlinkWatcher;
132594
+ if (resolutionHost.realpath) {
132595
+ locationToWatch = resolutionHost.realpath(affectingLocation);
132596
+ if (affectingLocation !== locationToWatch) {
132597
+ isSymlink = true;
132598
+ symlinkWatcher = fileWatchesOfAffectingLocations.get(locationToWatch);
132599
+ }
132600
+ }
132601
+ const resolutions = forResolution ? 1 : 0;
132602
+ const files = forResolution ? 0 : 1;
132603
+ if (!isSymlink || !symlinkWatcher) {
132604
+ const watcher = {
132605
+ watcher: canWatchAffectingLocation(resolutionHost.toPath(locationToWatch)) ? resolutionHost.watchAffectingFileLocation(locationToWatch, (fileName, eventKind) => {
132606
+ cachedDirectoryStructureHost == null ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
132607
+ invalidateAffectingFileWatcher(locationToWatch, moduleResolutionCache.getPackageJsonInfoCache().getInternalMap());
132608
+ resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
132609
+ }) : noopFileWatcher,
132610
+ resolutions: isSymlink ? 0 : resolutions,
132611
+ files: isSymlink ? 0 : files,
132612
+ symlinks: void 0
132613
+ };
132614
+ fileWatchesOfAffectingLocations.set(locationToWatch, watcher);
132615
+ if (isSymlink) symlinkWatcher = watcher;
132616
+ }
132617
+ if (isSymlink) {
132618
+ Debug.assert(!!symlinkWatcher);
132619
+ const watcher = {
132620
+ watcher: {
132621
+ close: () => {
132622
+ var _a;
132623
+ const symlinkWatcher2 = fileWatchesOfAffectingLocations.get(locationToWatch);
132624
+ if (((_a = symlinkWatcher2 == null ? void 0 : symlinkWatcher2.symlinks) == null ? void 0 : _a.delete(affectingLocation)) && !symlinkWatcher2.symlinks.size && !symlinkWatcher2.resolutions && !symlinkWatcher2.files) {
132625
+ fileWatchesOfAffectingLocations.delete(locationToWatch);
132626
+ symlinkWatcher2.watcher.close();
132627
+ }
132628
+ }
132629
+ },
132630
+ resolutions,
132631
+ files,
132632
+ symlinks: void 0
132633
+ };
132634
+ fileWatchesOfAffectingLocations.set(affectingLocation, watcher);
132635
+ (symlinkWatcher.symlinks ?? (symlinkWatcher.symlinks = /* @__PURE__ */ new Set())).add(affectingLocation);
132636
+ }
132637
+ }
132638
+ function invalidateAffectingFileWatcher(path, packageJsonMap) {
132639
+ var _a;
132640
+ const watcher = fileWatchesOfAffectingLocations.get(path);
132641
+ if (watcher == null ? void 0 : watcher.resolutions) (affectingPathChecks ?? (affectingPathChecks = /* @__PURE__ */ new Set())).add(path);
132642
+ if (watcher == null ? void 0 : watcher.files) (affectingPathChecksForFile ?? (affectingPathChecksForFile = /* @__PURE__ */ new Set())).add(path);
132643
+ (_a = watcher == null ? void 0 : watcher.symlinks) == null ? void 0 : _a.forEach((path2) => invalidateAffectingFileWatcher(path2, packageJsonMap));
132644
+ packageJsonMap == null ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path));
132645
+ }
132646
+ function watchFailedLookupLocationOfNonRelativeModuleResolutions() {
132647
+ nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfResolution);
132648
+ nonRelativeExternalModuleResolutions.clear();
132649
+ }
132650
+ function createDirectoryWatcherForPackageDir(dir, dirPath, packageDir, packageDirPath, nonRecursive) {
132651
+ Debug.assert(!nonRecursive);
132652
+ let isSymlink = isSymlinkCache.get(packageDirPath);
132653
+ let packageDirWatcher = packageDirWatchers.get(packageDirPath);
132654
+ if (isSymlink === void 0) {
132655
+ const realPath2 = resolutionHost.realpath(packageDir);
132656
+ isSymlink = realPath2 !== packageDir && resolutionHost.toPath(realPath2) !== packageDirPath;
132657
+ isSymlinkCache.set(packageDirPath, isSymlink);
132658
+ if (!packageDirWatcher) {
132659
+ packageDirWatchers.set(
132660
+ packageDirPath,
132661
+ packageDirWatcher = {
132662
+ dirPathToWatcher: /* @__PURE__ */ new Map(),
132663
+ isSymlink
132664
+ }
132665
+ );
132666
+ } else if (packageDirWatcher.isSymlink !== isSymlink) {
132667
+ packageDirWatcher.dirPathToWatcher.forEach((watcher) => {
132668
+ removeDirectoryWatcher(packageDirWatcher.isSymlink ? packageDirPath : dirPath);
132669
+ watcher.watcher = createDirPathToWatcher();
132670
+ });
132671
+ packageDirWatcher.isSymlink = isSymlink;
132672
+ }
132673
+ } else {
132674
+ Debug.assertIsDefined(packageDirWatcher);
132675
+ Debug.assert(isSymlink === packageDirWatcher.isSymlink);
132676
+ }
132677
+ const forDirPath = packageDirWatcher.dirPathToWatcher.get(dirPath);
132678
+ if (forDirPath) {
132679
+ forDirPath.refCount++;
132680
+ } else {
132681
+ packageDirWatcher.dirPathToWatcher.set(dirPath, {
132682
+ watcher: createDirPathToWatcher(),
132683
+ refCount: 1
132684
+ });
132685
+ if (isSymlink) dirPathToSymlinkPackageRefCount.set(dirPath, (dirPathToSymlinkPackageRefCount.get(dirPath) ?? 0) + 1);
132686
+ }
132687
+ function createDirPathToWatcher() {
132688
+ return isSymlink ? createOrAddRefToDirectoryWatchOfFailedLookups(packageDir, packageDirPath, nonRecursive) : createOrAddRefToDirectoryWatchOfFailedLookups(dir, dirPath, nonRecursive);
132689
+ }
132690
+ }
132691
+ function setDirectoryWatcher(dir, dirPath, packageDir, packageDirPath, nonRecursive) {
132692
+ if (!packageDirPath || !resolutionHost.realpath) {
132693
+ createOrAddRefToDirectoryWatchOfFailedLookups(dir, dirPath, nonRecursive);
132694
+ } else {
132695
+ createDirectoryWatcherForPackageDir(dir, dirPath, packageDir, packageDirPath, nonRecursive);
132696
+ }
132697
+ }
132698
+ function createOrAddRefToDirectoryWatchOfFailedLookups(dir, dirPath, nonRecursive) {
132699
+ let dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
132700
+ if (dirWatcher) {
132701
+ Debug.assert(!!nonRecursive === !!dirWatcher.nonRecursive);
132702
+ dirWatcher.refCount++;
132703
+ } else {
132704
+ directoryWatchesOfFailedLookups.set(dirPath, dirWatcher = { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive });
132705
+ }
132706
+ return dirWatcher;
132707
+ }
132708
+ function stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot) {
132709
+ const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
132710
+ const toWatch = getDirectoryToWatchFailedLookupLocation(
132711
+ failedLookupLocation,
132712
+ failedLookupLocationPath,
132713
+ rootDir,
132714
+ rootPath,
132715
+ rootPathComponents,
132716
+ isRootWatchable,
132717
+ getCurrentDirectory,
132718
+ resolutionHost.preferNonRecursiveWatch
132719
+ );
132720
+ if (toWatch) {
132721
+ const { dirPath, packageDirPath } = toWatch;
132722
+ if (dirPath === rootPath) {
132723
+ removeAtRoot = true;
132724
+ } else if (packageDirPath && resolutionHost.realpath) {
132725
+ const packageDirWatcher = packageDirWatchers.get(packageDirPath);
132726
+ const forDirPath = packageDirWatcher.dirPathToWatcher.get(dirPath);
132727
+ forDirPath.refCount--;
132728
+ if (forDirPath.refCount === 0) {
132729
+ removeDirectoryWatcher(packageDirWatcher.isSymlink ? packageDirPath : dirPath);
132730
+ packageDirWatcher.dirPathToWatcher.delete(dirPath);
132731
+ if (packageDirWatcher.isSymlink) {
132732
+ const refCount = dirPathToSymlinkPackageRefCount.get(dirPath) - 1;
132733
+ if (refCount === 0) {
132734
+ dirPathToSymlinkPackageRefCount.delete(dirPath);
132735
+ } else {
132736
+ dirPathToSymlinkPackageRefCount.set(dirPath, refCount);
132737
+ }
132738
+ }
132739
+ }
132740
+ } else {
132741
+ removeDirectoryWatcher(dirPath);
132742
+ }
132743
+ }
132744
+ return removeAtRoot;
132745
+ }
132746
+ function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
132747
+ Debug.checkDefined(resolution.files).delete(filePath);
132748
+ if (resolution.files.size) return;
132749
+ resolution.files = void 0;
132750
+ const resolved = getResolutionWithResolvedFileName(resolution);
132751
+ if (resolved && resolved.resolvedFileName) {
132752
+ const key = resolutionHost.toPath(resolved.resolvedFileName);
132753
+ const resolutions = resolvedFileToResolution.get(key);
132754
+ if ((resolutions == null ? void 0 : resolutions.delete(resolution)) && !resolutions.size) resolvedFileToResolution.delete(key);
132755
+ }
132756
+ const { failedLookupLocations, affectingLocations, alternateResult } = resolution;
132757
+ if (resolutionsWithFailedLookups.delete(resolution)) {
132758
+ let removeAtRoot = false;
132759
+ if (failedLookupLocations) {
132760
+ for (const failedLookupLocation of failedLookupLocations) {
132761
+ removeAtRoot = stopWatchFailedLookupLocation(failedLookupLocation, removeAtRoot);
132762
+ }
132763
+ }
132764
+ if (alternateResult) removeAtRoot = stopWatchFailedLookupLocation(alternateResult, removeAtRoot);
132765
+ if (removeAtRoot) removeDirectoryWatcher(rootPath);
132766
+ } else if (affectingLocations == null ? void 0 : affectingLocations.length) {
132767
+ resolutionsWithOnlyAffectingLocations.delete(resolution);
132768
+ }
132769
+ if (affectingLocations) {
132770
+ for (const affectingLocation of affectingLocations) {
132771
+ const watcher = fileWatchesOfAffectingLocations.get(affectingLocation);
132772
+ watcher.resolutions--;
132773
+ }
132774
+ }
133818
132775
  }
133819
- function removeResolutionsOfFileFromCache(cache2, filePath, moduleOrTypeRefCache) {
133820
- const resolutions = cache2.get(filePath);
132776
+ function removeDirectoryWatcher(dirPath) {
132777
+ const dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
132778
+ dirWatcher.refCount--;
132779
+ }
132780
+ function createDirectoryWatcher(directory, dirPath, nonRecursive) {
132781
+ return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, (fileOrDirectory) => {
132782
+ const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
132783
+ if (cachedDirectoryStructureHost) {
132784
+ cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
132785
+ }
132786
+ scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
132787
+ }, nonRecursive ? 0 /* None */ : 1 /* Recursive */);
132788
+ }
132789
+ function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) {
132790
+ const resolutions = cache.get(filePath);
133821
132791
  if (resolutions) {
133822
132792
  resolutions.forEach(
133823
132793
  (resolution) => stopWatchFailedLookupLocationOfResolution(
133824
132794
  resolution,
133825
132795
  filePath,
133826
- moduleOrTypeRefCache
132796
+ getResolutionWithResolvedFileName
133827
132797
  )
133828
132798
  );
133829
- cache2.delete(filePath);
132799
+ cache.delete(filePath);
133830
132800
  }
133831
132801
  }
133832
132802
  function removeResolutionsFromProjectReferenceRedirects(filePath) {
@@ -133838,62 +132808,149 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133838
132808
  resolvedProjectReference.commandLine.fileNames.forEach((f) => removeResolutionsOfFile(resolutionHost.toPath(f)));
133839
132809
  }
133840
132810
  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
- }
132811
+ removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModuleFromResolution);
132812
+ removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirectiveFromResolution);
133847
132813
  }
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
- }
132814
+ function invalidateResolutions(resolutions, canInvalidate) {
132815
+ if (!resolutions) return false;
132816
+ let invalidated = false;
132817
+ resolutions.forEach((resolution) => {
132818
+ if (resolution.isInvalidated || !canInvalidate(resolution)) return;
132819
+ resolution.isInvalidated = invalidated = true;
132820
+ for (const containingFilePath of Debug.checkDefined(resolution.files)) {
132821
+ (filesWithInvalidatedResolutions ?? (filesWithInvalidatedResolutions = /* @__PURE__ */ new Set())).add(containingFilePath);
132822
+ hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || endsWith(containingFilePath, inferredTypesContainingFile);
132823
+ }
132824
+ });
132825
+ return invalidated;
133854
132826
  }
133855
132827
  function invalidateResolutionOfFile(filePath) {
133856
132828
  removeResolutionsOfFile(filePath);
133857
132829
  const prevHasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
133858
- if (sharedCache.invalidateResolutionOfFile(filePath) && hasChangedAutomaticTypeDirectiveNames && !prevHasChangedAutomaticTypeDirectiveNames) {
132830
+ if (invalidateResolutions(resolvedFileToResolution.get(filePath), returnTrue) && hasChangedAutomaticTypeDirectiveNames && !prevHasChangedAutomaticTypeDirectiveNames) {
133859
132831
  resolutionHost.onChangedAutomaticTypeDirectiveNames();
133860
132832
  }
133861
132833
  }
133862
- function invalidateResolutionsWithGlobalCachePass() {
133863
- if (resolutionsResolvedWithGlobalCache) resolutionsWithGlobalCachePassAreInvalidated = true;
132834
+ function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) {
132835
+ Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === void 0);
132836
+ filesWithInvalidatedNonRelativeUnresolvedImports = filesMap;
133864
132837
  }
133865
- function invalidateResolutionsWithoutGlobalCachePass() {
133866
- if (resolutionsResolvedWithoutGlobalCache) resolutionsWithoutGlobalCachePassAreInvalidated = true;
132838
+ function scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, isCreatingWatchedDirectory) {
132839
+ if (isCreatingWatchedDirectory) {
132840
+ (isInDirectoryChecks || (isInDirectoryChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
132841
+ } else {
132842
+ const updatedPath = removeIgnoredPath(fileOrDirectoryPath);
132843
+ if (!updatedPath) return false;
132844
+ fileOrDirectoryPath = updatedPath;
132845
+ if (resolutionHost.fileIsOpen(fileOrDirectoryPath)) {
132846
+ return false;
132847
+ }
132848
+ const dirOfFileOrDirectory = getDirectoryPath(fileOrDirectoryPath);
132849
+ if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || isNodeModulesDirectory(fileOrDirectoryPath) || isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || isNodeModulesDirectory(dirOfFileOrDirectory)) {
132850
+ (failedLookupChecks || (failedLookupChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
132851
+ (startsWithPathChecks || (startsWithPathChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
132852
+ } else {
132853
+ if (isEmittedFileOfProgram(resolutionHost.getCurrentProgram(), fileOrDirectoryPath)) {
132854
+ return false;
132855
+ }
132856
+ if (fileExtensionIs(fileOrDirectoryPath, ".map")) {
132857
+ return false;
132858
+ }
132859
+ (failedLookupChecks || (failedLookupChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
132860
+ (startsWithPathChecks || (startsWithPathChecks = /* @__PURE__ */ new Set())).add(fileOrDirectoryPath);
132861
+ const packagePath = parseNodeModuleFromPath(
132862
+ fileOrDirectoryPath,
132863
+ /*isFolder*/
132864
+ true
132865
+ );
132866
+ if (packagePath) (startsWithPathChecks || (startsWithPathChecks = /* @__PURE__ */ new Set())).add(packagePath);
132867
+ }
132868
+ }
132869
+ resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
133867
132870
  }
133868
- function invalidateUnresolvedResolutionsWithGlobalCachePass() {
133869
- if (resolutionsResolvedWithGlobalCache) unresolvedResolutionsWithGlobalCachePassAreInvalidated = true;
132871
+ function invalidatePackageJsonMap() {
132872
+ const packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
132873
+ if (packageJsonMap && (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks)) {
132874
+ packageJsonMap.forEach((_value, path) => isInvalidatedFailedLookup(path) ? packageJsonMap.delete(path) : void 0);
132875
+ }
133870
132876
  }
133871
132877
  function invalidateResolutionsOfFailedLookupLocations() {
133872
132878
  var _a;
133873
- let invalidated = allModuleAndTypeResolutionsAreInvalidated;
133874
- if (!allModuleAndTypeResolutionsAreInvalidated && affectingPathChecksForFile) {
132879
+ if (allModuleAndTypeResolutionsAreInvalidated) {
132880
+ affectingPathChecksForFile = void 0;
132881
+ invalidatePackageJsonMap();
132882
+ if (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks || affectingPathChecks) {
132883
+ invalidateResolutions(resolvedLibraries, canInvalidateFailedLookupResolution);
132884
+ }
132885
+ failedLookupChecks = void 0;
132886
+ startsWithPathChecks = void 0;
132887
+ isInDirectoryChecks = void 0;
132888
+ affectingPathChecks = void 0;
132889
+ return true;
132890
+ }
132891
+ let invalidated = false;
132892
+ if (affectingPathChecksForFile) {
133875
132893
  (_a = resolutionHost.getCurrentProgram()) == null ? void 0 : _a.getSourceFiles().forEach((f) => {
133876
132894
  if (some(f.packageJsonLocations, (location) => affectingPathChecksForFile.has(location))) {
133877
132895
  (filesWithInvalidatedResolutions ?? (filesWithInvalidatedResolutions = /* @__PURE__ */ new Set())).add(f.path);
133878
132896
  invalidated = true;
133879
132897
  }
133880
132898
  });
132899
+ affectingPathChecksForFile = void 0;
133881
132900
  }
133882
- affectingPathChecksForFile = void 0;
133883
- return sharedCache.invalidateResolutionsOfFailedLookupLocations() || invalidated;
132901
+ if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) {
132902
+ return invalidated;
132903
+ }
132904
+ invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution) || invalidated;
132905
+ invalidatePackageJsonMap();
132906
+ failedLookupChecks = void 0;
132907
+ startsWithPathChecks = void 0;
132908
+ isInDirectoryChecks = void 0;
132909
+ invalidated = invalidateResolutions(resolutionsWithOnlyAffectingLocations, canInvalidatedFailedLookupResolutionWithAffectingLocation) || invalidated;
132910
+ affectingPathChecks = void 0;
132911
+ return invalidated;
132912
+ }
132913
+ function canInvalidateFailedLookupResolution(resolution) {
132914
+ var _a;
132915
+ if (canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution)) return true;
132916
+ if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) return false;
132917
+ return ((_a = resolution.failedLookupLocations) == null ? void 0 : _a.some((location) => isInvalidatedFailedLookup(resolutionHost.toPath(location)))) || !!resolution.alternateResult && isInvalidatedFailedLookup(resolutionHost.toPath(resolution.alternateResult));
132918
+ }
132919
+ function isInvalidatedFailedLookup(locationPath) {
132920
+ 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);
132921
+ }
132922
+ function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) {
132923
+ var _a;
132924
+ return !!affectingPathChecks && ((_a = resolution.affectingLocations) == null ? void 0 : _a.some((location) => affectingPathChecks.has(location)));
133884
132925
  }
133885
132926
  function closeTypeRootsWatch() {
133886
132927
  clearMap(typeRootsWatches, closeFileWatcher);
133887
132928
  }
133888
132929
  function createTypeRootsWatch(typeRoot) {
133889
- return sharedCache.createTypeRootsWatch(typeRoot, cache);
133890
- }
133891
- function invalidateTypeRoot() {
133892
- hasChangedAutomaticTypeDirectiveNames = true;
133893
- resolutionHost.onChangedAutomaticTypeDirectiveNames();
132930
+ return canWatchTypeRootPath(typeRoot) ? resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
132931
+ const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
132932
+ if (cachedDirectoryStructureHost) {
132933
+ cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
132934
+ }
132935
+ hasChangedAutomaticTypeDirectiveNames = true;
132936
+ resolutionHost.onChangedAutomaticTypeDirectiveNames();
132937
+ const dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(
132938
+ typeRoot,
132939
+ resolutionHost.toPath(typeRoot),
132940
+ rootPath,
132941
+ rootPathComponents,
132942
+ isRootWatchable,
132943
+ getCurrentDirectory,
132944
+ resolutionHost.preferNonRecursiveWatch,
132945
+ (dirPath2) => directoryWatchesOfFailedLookups.has(dirPath2) || dirPathToSymlinkPackageRefCount.has(dirPath2)
132946
+ );
132947
+ if (dirPath) {
132948
+ scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
132949
+ }
132950
+ }, 1 /* Recursive */) : noopFileWatcher;
133894
132951
  }
133895
- function updateTypeRootsWatch(options) {
133896
- options ?? (options = resolutionHost.getCompilationSettings());
132952
+ function updateTypeRootsWatch() {
132953
+ const options = resolutionHost.getCompilationSettings();
133897
132954
  if (options.types) {
133898
132955
  closeTypeRootsWatch();
133899
132956
  return;
@@ -133912,6 +132969,10 @@ function createResolutionCache(resolutionHost, rootDirForResolution, sharedCache
133912
132969
  closeTypeRootsWatch();
133913
132970
  }
133914
132971
  }
132972
+ function canWatchTypeRootPath(typeRoot) {
132973
+ if (resolutionHost.getCompilationSettings().typeRoots) return true;
132974
+ return canWatchAtTypes(resolutionHost.toPath(typeRoot));
132975
+ }
133915
132976
  }
133916
132977
  function resolutionIsSymlink(resolution) {
133917
132978
  var _a, _b;
@@ -134704,23 +133765,22 @@ function createWatchProgram(host) {
134704
133765
  compilerHost.getParsedCommandLine = getParsedCommandLine;
134705
133766
  const resolutionCache = createResolutionCache(
134706
133767
  compilerHost,
134707
- configFileName ? getDirectoryPath(getNormalizedAbsolutePath(configFileName, currentDirectory)) : currentDirectory
133768
+ configFileName ? getDirectoryPath(getNormalizedAbsolutePath(configFileName, currentDirectory)) : currentDirectory,
133769
+ /*logChangesWhenResolvingModule*/
133770
+ false
134708
133771
  );
134709
- compilerHost.onSourceFileNotCreated = resolutionCache.onSourceFileNotCreated.bind(resolutionCache);
134710
133772
  compilerHost.resolveModuleNameLiterals = maybeBind(host, host.resolveModuleNameLiterals);
134711
133773
  compilerHost.resolveModuleNames = maybeBind(host, host.resolveModuleNames);
134712
133774
  if (!compilerHost.resolveModuleNameLiterals && !compilerHost.resolveModuleNames) {
134713
133775
  compilerHost.resolveModuleNameLiterals = resolutionCache.resolveModuleNameLiterals.bind(resolutionCache);
134714
- compilerHost.onReusedModuleResolutions = resolutionCache.onReusedModuleResolutions.bind(resolutionCache);
134715
133776
  }
134716
133777
  compilerHost.resolveTypeReferenceDirectiveReferences = maybeBind(host, host.resolveTypeReferenceDirectiveReferences);
134717
133778
  compilerHost.resolveTypeReferenceDirectives = maybeBind(host, host.resolveTypeReferenceDirectives);
134718
133779
  if (!compilerHost.resolveTypeReferenceDirectiveReferences && !compilerHost.resolveTypeReferenceDirectives) {
134719
133780
  compilerHost.resolveTypeReferenceDirectiveReferences = resolutionCache.resolveTypeReferenceDirectiveReferences.bind(resolutionCache);
134720
- compilerHost.onReusedTypeReferenceDirectiveResolutions = resolutionCache.onReusedTypeReferenceDirectiveResolutions.bind(resolutionCache);
134721
133781
  }
134722
133782
  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;
133783
+ compilerHost.getModuleResolutionCache = host.resolveModuleNameLiterals || host.resolveModuleNames ? maybeBind(host, host.getModuleResolutionCache) : () => resolutionCache.getModuleResolutionCache();
134724
133784
  const userProvidedResolution = !!host.resolveModuleNameLiterals || !!host.resolveTypeReferenceDirectiveReferences || !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
134725
133785
  const customHasInvalidatedResolutions = userProvidedResolution ? maybeBind(host, host.hasInvalidatedResolutions) || returnTrue : returnFalse;
134726
133786
  const customHasInvalidLibResolutions = host.resolveLibrary ? maybeBind(host, host.hasInvalidatedLibResolutions) || returnTrue : returnFalse;
@@ -141407,7 +140467,7 @@ function createModuleSpecifierResolutionHost(program, host) {
141407
140467
  },
141408
140468
  getGlobalTypingsCacheLocation: maybeBind(host, host.getGlobalTypingsCacheLocation),
141409
140469
  redirectTargetsMap: program.redirectTargetsMap,
141410
- getProjectReferenceRedirect: (fileName) => program.getProjectReferenceRedirect(fileName),
140470
+ getRedirectFromSourceFile: (fileName) => program.getRedirectFromSourceFile(fileName),
141411
140471
  isSourceOfProjectReferenceRedirect: (fileName) => program.isSourceOfProjectReferenceRedirect(fileName),
141412
140472
  getNearestAncestorDirectoryWithPackageJson: maybeBind(host, host.getNearestAncestorDirectoryWithPackageJson),
141413
140473
  getFileIncludeReasons: () => program.getFileIncludeReasons(),
@@ -153406,10 +152466,7 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
153406
152466
  resolveTypeReferenceDirectives: maybeBind(host, host.resolveTypeReferenceDirectives),
153407
152467
  resolveModuleNameLiterals: maybeBind(host, host.resolveModuleNameLiterals),
153408
152468
  resolveTypeReferenceDirectiveReferences: maybeBind(host, host.resolveTypeReferenceDirectiveReferences),
153409
- onReusedModuleResolutions: maybeBind(host, host.onReusedModuleResolutions),
153410
- onReusedTypeReferenceDirectiveResolutions: maybeBind(host, host.onReusedTypeReferenceDirectiveResolutions),
153411
152469
  resolveLibrary: maybeBind(host, host.resolveLibrary),
153412
- onSourceFileNotCreated: maybeBind(host, host.onSourceFileNotCreated),
153413
152470
  useSourceOfProjectReferenceRedirect: maybeBind(host, host.useSourceOfProjectReferenceRedirect),
153414
152471
  getParsedCommandLine,
153415
152472
  jsDocParsingMode: host.jsDocParsingMode,
@@ -184115,7 +183172,6 @@ __export(ts_exports2, {
184115
183172
  computeLineOfPosition: () => computeLineOfPosition,
184116
183173
  computeLineStarts: () => computeLineStarts,
184117
183174
  computePositionOfLineAndCharacter: () => computePositionOfLineAndCharacter,
184118
- computeRedirectsCacheKey: () => computeRedirectsCacheKey,
184119
183175
  computeSignatureWithDiagnostics: () => computeSignatureWithDiagnostics,
184120
183176
  computeSuggestionDiagnostics: () => computeSuggestionDiagnostics,
184121
183177
  computedOptions: () => computedOptions,
@@ -184240,7 +183296,6 @@ __export(ts_exports2, {
184240
183296
  createScanner: () => createScanner,
184241
183297
  createSemanticDiagnosticsBuilderProgram: () => createSemanticDiagnosticsBuilderProgram,
184242
183298
  createSet: () => createSet,
184243
- createSharedResolutionCache: () => createSharedResolutionCache,
184244
183299
  createSolutionBuilder: () => createSolutionBuilder,
184245
183300
  createSolutionBuilderHost: () => createSolutionBuilderHost,
184246
183301
  createSolutionBuilderWithWatch: () => createSolutionBuilderWithWatch,
@@ -184308,8 +183363,6 @@ __export(ts_exports2, {
184308
183363
  emptyFileSystemEntries: () => emptyFileSystemEntries,
184309
183364
  emptyMap: () => emptyMap,
184310
183365
  emptyOptions: () => emptyOptions,
184311
- emptyResolution: () => emptyResolution,
184312
- enableSharingModuleOrTypeReferenceResolutionCache: () => enableSharingModuleOrTypeReferenceResolutionCache,
184313
183366
  endsWith: () => endsWith,
184314
183367
  ensurePathIsNonModuleName: () => ensurePathIsNonModuleName,
184315
183368
  ensureScriptKind: () => ensureScriptKind,
@@ -184447,7 +183500,6 @@ __export(ts_exports2, {
184447
183500
  getAssignmentDeclarationKind: () => getAssignmentDeclarationKind,
184448
183501
  getAssignmentDeclarationPropertyAccessKind: () => getAssignmentDeclarationPropertyAccessKind,
184449
183502
  getAssignmentTargetKind: () => getAssignmentTargetKind,
184450
- getAutomaticTypeDirectiveContainingFile: () => getAutomaticTypeDirectiveContainingFile,
184451
183503
  getAutomaticTypeDirectiveNames: () => getAutomaticTypeDirectiveNames,
184452
183504
  getBaseFileName: () => getBaseFileName,
184453
183505
  getBinaryOperatorPrecedence: () => getBinaryOperatorPrecedence,
@@ -184507,6 +183559,7 @@ __export(ts_exports2, {
184507
183559
  getDiagnosticsWithinSpan: () => getDiagnosticsWithinSpan,
184508
183560
  getDirectoryPath: () => getDirectoryPath,
184509
183561
  getDirectoryToWatchFailedLookupLocation: () => getDirectoryToWatchFailedLookupLocation,
183562
+ getDirectoryToWatchFailedLookupLocationFromTypeRoot: () => getDirectoryToWatchFailedLookupLocationFromTypeRoot,
184510
183563
  getDocumentPositionMapper: () => getDocumentPositionMapper,
184511
183564
  getDocumentSpansEqualityComparer: () => getDocumentSpansEqualityComparer,
184512
183565
  getESModuleInterop: () => getESModuleInterop,
@@ -185474,9 +184527,6 @@ __export(ts_exports2, {
185474
184527
  isRegularExpressionLiteral: () => isRegularExpressionLiteral,
185475
184528
  isRequireCall: () => isRequireCall,
185476
184529
  isRequireVariableStatement: () => isRequireVariableStatement,
185477
- isResolvedWithGlobalCachePass: () => isResolvedWithGlobalCachePass,
185478
- isResolvedWithGlobalCachePassButStillUnresolved: () => isResolvedWithGlobalCachePassButStillUnresolved,
185479
- isResolvedWithoutGlobalCachePass: () => isResolvedWithoutGlobalCachePass,
185480
184530
  isRestParameter: () => isRestParameter,
185481
184531
  isRestTypeNode: () => isRestTypeNode,
185482
184532
  isReturnStatement: () => isReturnStatement,
@@ -185596,7 +184646,6 @@ __export(ts_exports2, {
185596
184646
  isUnaryExpressionWithWrite: () => isUnaryExpressionWithWrite,
185597
184647
  isUnicodeIdentifierStart: () => isUnicodeIdentifierStart,
185598
184648
  isUnionTypeNode: () => isUnionTypeNode,
185599
- isUnresolvedOrResolvedToJs: () => isUnresolvedOrResolvedToJs,
185600
184649
  isUrl: () => isUrl,
185601
184650
  isValidBigIntString: () => isValidBigIntString,
185602
184651
  isValidESSymbolDeclaration: () => isValidESSymbolDeclaration,
@@ -185681,7 +184730,6 @@ __export(ts_exports2, {
185681
184730
  mutateMap: () => mutateMap,
185682
184731
  mutateMapSkippingNewValues: () => mutateMapSkippingNewValues,
185683
184732
  needsParentheses: () => needsParentheses,
185684
- needsResolutionFromGlobalCache: () => needsResolutionFromGlobalCache,
185685
184733
  needsScopeMarker: () => needsScopeMarker,
185686
184734
  newCaseClauseTracker: () => newCaseClauseTracker,
185687
184735
  newPrivateEnvironment: () => newPrivateEnvironment,
@@ -186039,7 +185087,6 @@ __export(ts_exports2, {
186039
185087
  typeDirectiveIsEqualTo: () => typeDirectiveIsEqualTo,
186040
185088
  typeKeywords: () => typeKeywords,
186041
185089
  typeParameterNamePart: () => typeParameterNamePart,
186042
- typeReferenceResolutionNameAndModeGetter: () => typeReferenceResolutionNameAndModeGetter,
186043
185090
  typeToDisplayParts: () => typeToDisplayParts,
186044
185091
  unchangedPollThresholds: () => unchangedPollThresholds,
186045
185092
  unchangedTextChangeRange: () => unchangedTextChangeRange,
@@ -186055,6 +185102,7 @@ __export(ts_exports2, {
186055
185102
  updateErrorForNoInputFiles: () => updateErrorForNoInputFiles,
186056
185103
  updateLanguageServiceSourceFile: () => updateLanguageServiceSourceFile,
186057
185104
  updateMissingFilePathsWatch: () => updateMissingFilePathsWatch,
185105
+ updateResolutionField: () => updateResolutionField,
186058
185106
  updateSharedExtendedConfigFileWatcher: () => updateSharedExtendedConfigFileWatcher,
186059
185107
  updateSourceFile: () => updateSourceFile,
186060
185108
  updateWatchingWildcardDirectories: () => updateWatchingWildcardDirectories,
@@ -186261,7 +185309,6 @@ __export(ts_server_exports3, {
186261
185309
  getBaseConfigFileName: () => getBaseConfigFileName,
186262
185310
  getDetailWatchInfo: () => getDetailWatchInfo,
186263
185311
  getLocationInNewDocument: () => getLocationInNewDocument,
186264
- getUnresolvedImports: () => getUnresolvedImports,
186265
185312
  hasArgument: () => hasArgument,
186266
185313
  hasNoTypeScriptSource: () => hasNoTypeScriptSource,
186267
185314
  indent: () => indent2,
@@ -186668,7 +185715,7 @@ var TypingsInstaller = class {
186668
185715
  }
186669
185716
  const existing = this.projectWatchers.get(projectName);
186670
185717
  const newSet = new Set(files);
186671
- if (!existing || newSet.size !== existing.size || forEachKey(newSet, (s) => !existing.has(s)) || forEachKey(existing, (s) => !newSet.has(s))) {
185718
+ if (!existing || forEachKey(newSet, (s) => !existing.has(s)) || forEachKey(existing, (s) => !newSet.has(s))) {
186672
185719
  this.projectWatchers.set(projectName, newSet);
186673
185720
  this.sendResponse({ kind: ActionWatchTypingLocations, projectName, files });
186674
185721
  } else {
@@ -187683,16 +186730,11 @@ function compilerOptionsChanged(opt1, opt2) {
187683
186730
  return getAllowJSCompilerOption(opt1) !== getAllowJSCompilerOption(opt2);
187684
186731
  }
187685
186732
  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;
186733
+ if (imports1 === imports2) {
186734
+ return false;
186735
+ }
187688
186736
  return !arrayIsEqualTo(imports1, imports2);
187689
186737
  }
187690
- var disabledTypeAcquisition = {};
187691
- var enabledTypeAcquisition = {
187692
- enable: true,
187693
- include: emptyArray,
187694
- exclude: emptyArray
187695
- };
187696
186738
  var Project2 = class _Project {
187697
186739
  /** @internal */
187698
186740
  constructor(projectName, projectKind, projectService, hasExplicitListOfFiles, lastFileExceededProgramSize, compilerOptions, compileOnSaveEnabled, watchOptions, directoryStructureHost, currentDirectory) {
@@ -187712,7 +186754,6 @@ var Project2 = class _Project {
187712
186754
  * @internal
187713
186755
  */
187714
186756
  this.cachedUnresolvedImportsPerFile = /* @__PURE__ */ new Map();
187715
- this.recordChangesToUnresolvedImports = false;
187716
186757
  this.hasAddedorRemovedFiles = false;
187717
186758
  this.hasAddedOrRemovedSymlinks = false;
187718
186759
  /**
@@ -187789,7 +186830,8 @@ var Project2 = class _Project {
187789
186830
  this.resolutionCache = createResolutionCache(
187790
186831
  this,
187791
186832
  this.currentDirectory,
187792
- this.projectService.sharedResolutionCache
186833
+ /*logChangesWhenResolvingModule*/
186834
+ true
187793
186835
  );
187794
186836
  this.languageService = createLanguageService(
187795
186837
  this,
@@ -187806,7 +186848,7 @@ var Project2 = class _Project {
187806
186848
  this.projectService.onProjectCreation(this);
187807
186849
  }
187808
186850
  /** @internal */
187809
- getResolvedProjectReferenceToRedirect(_fileName) {
186851
+ getRedirectFromSourceFile(_fileName) {
187810
186852
  return void 0;
187811
186853
  }
187812
186854
  isNonTsProject() {
@@ -187979,35 +187021,11 @@ var Project2 = class _Project {
187979
187021
  }
187980
187022
  /** @internal */
187981
187023
  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
- );
187024
+ return this.resolutionCache.resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options, containingSourceFile, reusedNames);
188007
187025
  }
188008
187026
  /** @internal */
188009
187027
  getModuleResolutionCache() {
188010
- return this.resolutionCache.moduleResolutionCache;
187028
+ return this.resolutionCache.getModuleResolutionCache();
188011
187029
  }
188012
187030
  /** @internal */
188013
187031
  resolveTypeReferenceDirectiveReferences(typeDirectiveReferences, containingFile, redirectedReference, options, containingSourceFile, reusedNames) {
@@ -188021,22 +187039,9 @@ var Project2 = class _Project {
188021
187039
  );
188022
187040
  }
188023
187041
  /** @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
187042
  resolveLibrary(libraryName, resolveFrom, options, libFileName) {
188034
187043
  return this.resolutionCache.resolveLibrary(libraryName, resolveFrom, options, libFileName);
188035
187044
  }
188036
- /** @internal */
188037
- onSourceFileNotCreated(sourceFileOptions) {
188038
- this.resolutionCache.onSourceFileNotCreated(sourceFileOptions);
188039
- }
188040
187045
  directoryExists(path) {
188041
187046
  return this.directoryStructureHost.directoryExists(path);
188042
187047
  }
@@ -188122,7 +187127,7 @@ var Project2 = class _Project {
188122
187127
  }
188123
187128
  /** @internal */
188124
187129
  fileIsOpen(filePath) {
188125
- return this.projectService.fileIsOpen(filePath);
187130
+ return this.projectService.openFiles.has(filePath);
188126
187131
  }
188127
187132
  /** @internal */
188128
187133
  writeLog(s) {
@@ -188232,9 +187237,6 @@ var Project2 = class _Project {
188232
187237
  }
188233
187238
  this.languageServiceEnabled = true;
188234
187239
  this.lastFileExceededProgramSize = void 0;
188235
- if (this.projectService.serverMode === 0 /* Semantic */) {
188236
- this.resolutionCache.updateTypeRootsWatch();
188237
- }
188238
187240
  this.projectService.onUpdateLanguageServiceStateForProject(
188239
187241
  this,
188240
187242
  /*languageServiceEnabled*/
@@ -188554,10 +187556,6 @@ var Project2 = class _Project {
188554
187556
  updateFromProject() {
188555
187557
  updateProjectIfDirty(this);
188556
187558
  }
188557
- /** @internal */
188558
- useTypingsFromGlobalCache() {
188559
- return !this.isOrphan() && !!this.languageServiceEnabled && this.projectService.serverMode === 0 /* Semantic */ && this.projectService.typingsInstaller !== nullTypingsInstaller && !!this.getTypeAcquisition().enable;
188560
- }
188561
187559
  /**
188562
187560
  * Updates set of files that contribute to this project
188563
187561
  * @returns: true if set of files in the project stays the same and false - otherwise.
@@ -188565,27 +187563,23 @@ var Project2 = class _Project {
188565
187563
  updateGraph() {
188566
187564
  var _a, _b;
188567
187565
  (_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;
187566
+ this.resolutionCache.startRecordingFilesWithChangedResolutions();
188572
187567
  const hasNewProgram = this.updateGraphWorker();
188573
187568
  const hasAddedorRemovedFiles = this.hasAddedorRemovedFiles;
188574
187569
  this.hasAddedorRemovedFiles = false;
188575
187570
  this.hasAddedOrRemovedSymlinks = false;
188576
- this.recordChangesToUnresolvedImports = false;
188577
- if (useTypingsFromGlobalCache) {
188578
- this.lastCachedUnresolvedImportsList ?? (this.lastCachedUnresolvedImportsList = getUnresolvedImports(
188579
- this.program,
188580
- this.cachedUnresolvedImportsPerFile
188581
- ));
187571
+ const changedFiles = this.resolutionCache.finishRecordingFilesWithChangedResolutions() || emptyArray2;
187572
+ for (const file of changedFiles) {
187573
+ this.cachedUnresolvedImportsPerFile.delete(file);
187574
+ }
187575
+ if (this.languageServiceEnabled && this.projectService.serverMode === 0 /* Semantic */ && !this.isOrphan()) {
187576
+ if (hasNewProgram || changedFiles.length) {
187577
+ this.lastCachedUnresolvedImportsList = getUnresolvedImports(this.program, this.cachedUnresolvedImportsPerFile);
187578
+ }
188582
187579
  this.enqueueInstallTypingsForProject(hasAddedorRemovedFiles);
188583
187580
  } else {
188584
187581
  this.lastCachedUnresolvedImportsList = void 0;
188585
- this.cachedUnresolvedImportsPerFile.clear();
188586
- this.typingsCache = void 0;
188587
187582
  }
188588
- this.projectService.verifyUnresovedImports(this);
188589
187583
  const isFirstProgramLoad = this.projectProgramVersion === 0 && hasNewProgram;
188590
187584
  if (hasNewProgram) {
188591
187585
  this.projectProgramVersion++;
@@ -188601,7 +187595,6 @@ var Project2 = class _Project {
188601
187595
  }
188602
187596
  /** @internal */
188603
187597
  enqueueInstallTypingsForProject(forceRefresh) {
188604
- var _a;
188605
187598
  const typeAcquisition = this.getTypeAcquisition();
188606
187599
  if (!typeAcquisition || !typeAcquisition.enable || this.projectService.typingsInstaller === nullTypingsInstaller) {
188607
187600
  return;
@@ -188611,31 +187604,29 @@ var Project2 = class _Project {
188611
187604
  this.typingsCache = {
188612
187605
  compilerOptions: this.getCompilationSettings(),
188613
187606
  typeAcquisition,
188614
- unresolvedImports: ((_a = this.lastCachedUnresolvedImportsList) == null ? void 0 : _a.length) ? this.lastCachedUnresolvedImportsList : void 0
187607
+ unresolvedImports: this.lastCachedUnresolvedImportsList
188615
187608
  };
188616
- this.projectService.typingsInstaller.enqueueInstallTypingsRequest(
188617
- this,
188618
- typeAcquisition,
188619
- this.typingsCache.unresolvedImports
188620
- );
187609
+ this.projectService.typingsInstaller.enqueueInstallTypingsRequest(this, typeAcquisition, this.lastCachedUnresolvedImportsList);
188621
187610
  }
188622
187611
  }
188623
187612
  /** @internal */
188624
- updateTypingFiles({ compilerOptions, typeAcquisition, unresolvedImports, typings }) {
188625
- if (!this.getTypeAcquisition().enable) return;
187613
+ updateTypingFiles(compilerOptions, typeAcquisition, unresolvedImports, newTypings) {
188626
187614
  this.typingsCache = {
188627
187615
  compilerOptions,
188628
187616
  typeAcquisition,
188629
187617
  unresolvedImports
188630
187618
  };
188631
- const typingFiles = typings.length ? toSorted(typings) : emptyArray2;
188632
- if (!arrayIsEqualTo(
187619
+ const typingFiles = !typeAcquisition || !typeAcquisition.enable ? emptyArray2 : toSorted(newTypings);
187620
+ if (enumerateInsertsAndDeletes(
188633
187621
  typingFiles,
188634
187622
  this.typingFiles,
188635
- this.useCaseSensitiveFileNames() ? equateStringsCaseSensitive : equateStringsCaseInsensitive
187623
+ getStringComparer(!this.useCaseSensitiveFileNames()),
187624
+ /*inserted*/
187625
+ noop,
187626
+ (removed) => this.detachScriptInfoFromProject(removed)
188636
187627
  )) {
188637
187628
  this.typingFiles = typingFiles;
188638
- if (this.typingFiles.length) this.resolutionCache.invalidateUnresolvedResolutionsWithGlobalCachePass();
187629
+ this.resolutionCache.setFilesWithInvalidatedNonRelativeUnresolvedImports(this.cachedUnresolvedImportsPerFile);
188639
187630
  this.projectService.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(this);
188640
187631
  }
188641
187632
  }
@@ -189052,19 +188043,10 @@ var Project2 = class _Project {
189052
188043
  setTypeAcquisition(newTypeAcquisition) {
189053
188044
  if (newTypeAcquisition) {
189054
188045
  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
188046
  }
189065
188047
  }
189066
188048
  getTypeAcquisition() {
189067
- return this.typeAcquisition ?? (this.typeAcquisition = disabledTypeAcquisition);
188049
+ return this.typeAcquisition || {};
189068
188050
  }
189069
188051
  /** @internal */
189070
188052
  getChangesSinceVersion(lastKnownVersion, includeProjectReferenceRedirectInfo) {
@@ -189396,8 +188378,8 @@ function getUnresolvedImports(program, cachedUnresolvedImportsPerFile) {
189396
188378
  function extractUnresolvedImportsFromSourceFile(program, file, ambientModules, cachedUnresolvedImportsPerFile) {
189397
188379
  return getOrUpdate(cachedUnresolvedImportsPerFile, file.path, () => {
189398
188380
  let unresolvedImports;
189399
- program.forEachResolvedModule((resolution, name) => {
189400
- if (needsResolutionFromGlobalCache(name, resolution) && !ambientModules.some((m) => m === name)) {
188381
+ program.forEachResolvedModule(({ resolvedModule }, name) => {
188382
+ if ((!resolvedModule || !resolutionExtensionIsTSOrJson(resolvedModule.extension)) && !isExternalModuleNameRelative(name) && !ambientModules.some((m) => m === name)) {
189401
188383
  unresolvedImports = append(unresolvedImports, parsePackageName(name).packageName);
189402
188384
  }
189403
188385
  }, file);
@@ -189463,12 +188445,10 @@ var InferredProject2 = class extends Project2 {
189463
188445
  false
189464
188446
  );
189465
188447
  }
189466
- this.inferredTypeAcquisition = void 0;
189467
188448
  super.addRoot(info);
189468
188449
  }
189469
188450
  removeRoot(info) {
189470
188451
  this.projectService.stopWatchingConfigFilesForScriptInfo(info);
189471
- this.inferredTypeAcquisition = void 0;
189472
188452
  super.removeRoot(info);
189473
188453
  if (!this.isOrphan() && this._isJsInferredProject && info.isJavaScript()) {
189474
188454
  if (every(this.getRootScriptInfos(), (rootInfo) => !rootInfo.isJavaScript())) {
@@ -189490,12 +188470,12 @@ var InferredProject2 = class extends Project2 {
189490
188470
  forEach(this.getRootScriptInfos(), (info) => this.projectService.stopWatchingConfigFilesForScriptInfo(info));
189491
188471
  super.close();
189492
188472
  }
189493
- setTypeAcquisition(newTypeAcquisition) {
189494
- this.inferredTypeAcquisition = void 0;
189495
- super.setTypeAcquisition(newTypeAcquisition);
189496
- }
189497
188473
  getTypeAcquisition() {
189498
- return this.typeAcquisition || (this.inferredTypeAcquisition ?? (this.inferredTypeAcquisition = allRootFilesAreJsOrDts(this) ? enabledTypeAcquisition : disabledTypeAcquisition));
188474
+ return this.typeAcquisition || {
188475
+ enable: allRootFilesAreJsOrDts(this),
188476
+ include: emptyArray,
188477
+ exclude: emptyArray
188478
+ };
189499
188479
  }
189500
188480
  };
189501
188481
  var AuxiliaryProject = class extends Project2 {
@@ -189773,6 +188753,11 @@ var _AutoImportProviderProject = class _AutoImportProviderProject extends Projec
189773
188753
  getSymlinkCache() {
189774
188754
  return this.hostProject.getSymlinkCache();
189775
188755
  }
188756
+ /** @internal */
188757
+ getModuleResolutionCache() {
188758
+ var _a;
188759
+ return (_a = this.hostProject.getCurrentProgram()) == null ? void 0 : _a.getModuleResolutionCache();
188760
+ }
189776
188761
  };
189777
188762
  _AutoImportProviderProject.maxDependencies = 10;
189778
188763
  /** @internal */
@@ -189912,9 +188897,9 @@ var ConfiguredProject2 = class extends Project2 {
189912
188897
  (this.potentialProjectReferences || (this.potentialProjectReferences = /* @__PURE__ */ new Set())).add(canonicalConfigPath);
189913
188898
  }
189914
188899
  /** @internal */
189915
- getResolvedProjectReferenceToRedirect(fileName) {
188900
+ getRedirectFromSourceFile(fileName) {
189916
188901
  const program = this.getCurrentProgram();
189917
- return program && program.getResolvedProjectReferenceToRedirect(fileName);
188902
+ return program && program.getRedirectFromSourceFile(fileName);
189918
188903
  }
189919
188904
  /** @internal */
189920
188905
  forEachResolvedProjectReference(cb) {
@@ -190645,8 +189630,6 @@ var _ProjectService = class _ProjectService {
190645
189630
  /** @internal */
190646
189631
  this.verifyProgram = noop;
190647
189632
  /** @internal */
190648
- this.verifyUnresovedImports = noop;
190649
- /** @internal */
190650
189633
  this.onProjectCreation = noop;
190651
189634
  var _a;
190652
189635
  this.host = opts.host;
@@ -190710,19 +189693,8 @@ var _ProjectService = class _ProjectService {
190710
189693
  getDetailWatchInfo
190711
189694
  );
190712
189695
  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
189696
  (_a = opts.incrementalVerifier) == null ? void 0 : _a.call(opts, this);
190721
189697
  }
190722
- /** @internal */
190723
- fileIsOpen(filePath) {
190724
- return this.openFiles.has(filePath);
190725
- }
190726
189698
  toPath(fileName) {
190727
189699
  return toPath(fileName, this.currentDirectory, this.toCanonicalFileName);
190728
189700
  }
@@ -190794,7 +189766,12 @@ var _ProjectService = class _ProjectService {
190794
189766
  }
190795
189767
  switch (response.kind) {
190796
189768
  case ActionSet:
190797
- project.updateTypingFiles(response);
189769
+ project.updateTypingFiles(
189770
+ response.compilerOptions,
189771
+ response.typeAcquisition,
189772
+ response.unresolvedImports,
189773
+ response.typings
189774
+ );
190798
189775
  return;
190799
189776
  case ActionInvalidate:
190800
189777
  project.enqueueInstallTypingsForProject(
@@ -195993,7 +194970,7 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
195993
194970
  );
195994
194971
  const packageName = getPackageNameFromTypesPackageName(unmangleScopedPackageName(packageNamePathPart));
195995
194972
  const path = project.toPath(fileName);
195996
- if (some(entrypoints, (e) => project.toPath(e) === path)) {
194973
+ if (entrypoints && some(entrypoints, (e) => project.toPath(e) === path)) {
195997
194974
  return (_b = auxiliaryProject.resolutionCache.resolveSingleModuleNameWithoutWatching(packageName, resolveFromFile).resolvedModule) == null ? void 0 : _b.resolvedFileName;
195998
194975
  } else {
195999
194976
  const pathToFileInPackage = fileName.substring(nodeModulesPathParts.packageRootIndex + 1);
@@ -198619,7 +197596,6 @@ __export(ts_server_exports4, {
198619
197596
  getBaseConfigFileName: () => getBaseConfigFileName,
198620
197597
  getDetailWatchInfo: () => getDetailWatchInfo,
198621
197598
  getLocationInNewDocument: () => getLocationInNewDocument,
198622
- getUnresolvedImports: () => getUnresolvedImports,
198623
197599
  hasArgument: () => hasArgument,
198624
197600
  hasNoTypeScriptSource: () => hasNoTypeScriptSource,
198625
197601
  indent: () => indent2,
@@ -198957,7 +197933,6 @@ if (typeof console !== "undefined") {
198957
197933
  computeLineOfPosition,
198958
197934
  computeLineStarts,
198959
197935
  computePositionOfLineAndCharacter,
198960
- computeRedirectsCacheKey,
198961
197936
  computeSignatureWithDiagnostics,
198962
197937
  computeSuggestionDiagnostics,
198963
197938
  computedOptions,
@@ -199082,7 +198057,6 @@ if (typeof console !== "undefined") {
199082
198057
  createScanner,
199083
198058
  createSemanticDiagnosticsBuilderProgram,
199084
198059
  createSet,
199085
- createSharedResolutionCache,
199086
198060
  createSolutionBuilder,
199087
198061
  createSolutionBuilderHost,
199088
198062
  createSolutionBuilderWithWatch,
@@ -199150,8 +198124,6 @@ if (typeof console !== "undefined") {
199150
198124
  emptyFileSystemEntries,
199151
198125
  emptyMap,
199152
198126
  emptyOptions,
199153
- emptyResolution,
199154
- enableSharingModuleOrTypeReferenceResolutionCache,
199155
198127
  endsWith,
199156
198128
  ensurePathIsNonModuleName,
199157
198129
  ensureScriptKind,
@@ -199289,7 +198261,6 @@ if (typeof console !== "undefined") {
199289
198261
  getAssignmentDeclarationKind,
199290
198262
  getAssignmentDeclarationPropertyAccessKind,
199291
198263
  getAssignmentTargetKind,
199292
- getAutomaticTypeDirectiveContainingFile,
199293
198264
  getAutomaticTypeDirectiveNames,
199294
198265
  getBaseFileName,
199295
198266
  getBinaryOperatorPrecedence,
@@ -199349,6 +198320,7 @@ if (typeof console !== "undefined") {
199349
198320
  getDiagnosticsWithinSpan,
199350
198321
  getDirectoryPath,
199351
198322
  getDirectoryToWatchFailedLookupLocation,
198323
+ getDirectoryToWatchFailedLookupLocationFromTypeRoot,
199352
198324
  getDocumentPositionMapper,
199353
198325
  getDocumentSpansEqualityComparer,
199354
198326
  getESModuleInterop,
@@ -200316,9 +199288,6 @@ if (typeof console !== "undefined") {
200316
199288
  isRegularExpressionLiteral,
200317
199289
  isRequireCall,
200318
199290
  isRequireVariableStatement,
200319
- isResolvedWithGlobalCachePass,
200320
- isResolvedWithGlobalCachePassButStillUnresolved,
200321
- isResolvedWithoutGlobalCachePass,
200322
199291
  isRestParameter,
200323
199292
  isRestTypeNode,
200324
199293
  isReturnStatement,
@@ -200438,7 +199407,6 @@ if (typeof console !== "undefined") {
200438
199407
  isUnaryExpressionWithWrite,
200439
199408
  isUnicodeIdentifierStart,
200440
199409
  isUnionTypeNode,
200441
- isUnresolvedOrResolvedToJs,
200442
199410
  isUrl,
200443
199411
  isValidBigIntString,
200444
199412
  isValidESSymbolDeclaration,
@@ -200523,7 +199491,6 @@ if (typeof console !== "undefined") {
200523
199491
  mutateMap,
200524
199492
  mutateMapSkippingNewValues,
200525
199493
  needsParentheses,
200526
- needsResolutionFromGlobalCache,
200527
199494
  needsScopeMarker,
200528
199495
  newCaseClauseTracker,
200529
199496
  newPrivateEnvironment,
@@ -200881,7 +199848,6 @@ if (typeof console !== "undefined") {
200881
199848
  typeDirectiveIsEqualTo,
200882
199849
  typeKeywords,
200883
199850
  typeParameterNamePart,
200884
- typeReferenceResolutionNameAndModeGetter,
200885
199851
  typeToDisplayParts,
200886
199852
  unchangedPollThresholds,
200887
199853
  unchangedTextChangeRange,
@@ -200897,6 +199863,7 @@ if (typeof console !== "undefined") {
200897
199863
  updateErrorForNoInputFiles,
200898
199864
  updateLanguageServiceSourceFile,
200899
199865
  updateMissingFilePathsWatch,
199866
+ updateResolutionField,
200900
199867
  updateSharedExtendedConfigFileWatcher,
200901
199868
  updateSourceFile,
200902
199869
  updateWatchingWildcardDirectories,