Skip to content

Commit

Permalink
use cache for program creation on watch mode. (#49958)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheetalkamat committed Aug 10, 2022
1 parent 90cfbae commit 924c68c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/compiler/watchPublic.ts
Expand Up @@ -445,7 +445,11 @@ namespace ts {

// All resolutions are invalid if user provided resolutions
const hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
if (isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
const {
originalReadFile, originalFileExists, originalDirectoryExists,
originalCreateDirectory, originalWriteFile,
} = changeCompilerHostLikeToUseCache(compilerHost, toPath);
if (isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileName => compilerHost.fileExists(fileName), hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
if (hasChangedConfigFileParsingErrors) {
if (reportFileChangeDetectedOnCreateProgram) {
reportWatchDiagnostic(Diagnostics.File_change_detected_Starting_incremental_compilation);
Expand All @@ -462,11 +466,16 @@ namespace ts {
}

reportFileChangeDetectedOnCreateProgram = false;

if (host.afterProgramCreate && program !== builderProgram) {
host.afterProgramCreate(builderProgram);
}

compilerHost.readFile = originalReadFile;
compilerHost.fileExists = originalFileExists;
compilerHost.directoryExists = originalDirectoryExists;
compilerHost.createDirectory = originalCreateDirectory;
compilerHost.writeFile = originalWriteFile!;

return builderProgram;
}

Expand Down

0 comments on commit 924c68c

Please sign in to comment.