@@ -58,7 +58,6 @@ import {
5858 isNumber ,
5959 isString ,
6060 map ,
61- mapDefined ,
6261 maybeBind ,
6362 noop ,
6463 notImplemented ,
@@ -73,6 +72,7 @@ import {
7372 returnUndefined ,
7473 sameMap ,
7574 SemanticDiagnosticsBuilderProgram ,
75+ SignatureInfo ,
7676 skipTypeChecking ,
7777 SourceFile ,
7878 sourceFileMayBeEmitted ,
@@ -242,8 +242,6 @@ export interface BuilderProgramState extends BuilderState, ReusableBuilderProgra
242242 * Already seen emitted files
243243 */
244244 seenEmittedFiles : Map < Path , BuilderFileEmit > | undefined ;
245- /** Stores list of files that change signature during emit - test only */
246- filesChangingSignature ?: Set < Path > ;
247245}
248246
249247/** @internal */
@@ -633,7 +631,6 @@ function getNextAffectedFile(
633631 state . currentChangedFilePath = undefined ;
634632 // Commit the changes in file signature
635633 state . oldSignatures ?. clear ( ) ;
636- state . oldExportedModulesMap ?. clear ( ) ;
637634 state . affectedFiles = undefined ;
638635 }
639636
@@ -845,7 +842,7 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(
845842) {
846843 // If there was change in signature (dts output) for the changed file,
847844 // then only we need to handle pending file emit
848- if ( ! state . exportedModulesMap || ! state . changedFilesSet . has ( affectedFile . resolvedPath ) ) return ;
845+ if ( ! state . referencedMap || ! state . changedFilesSet . has ( affectedFile . resolvedPath ) ) return ;
849846 if ( ! isChangedSignature ( state , affectedFile . resolvedPath ) ) return ;
850847
851848 // Since isolated modules dont change js files, files affected by change in signature is itself
@@ -869,9 +866,8 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(
869866 }
870867
871868 const seenFileAndExportsOfFile = new Set < string > ( ) ;
872- // Go through exported modules from cache first
873- // If exported modules has path, all files referencing file exported from are affected
874- state . exportedModulesMap . getKeys ( affectedFile . resolvedPath ) ?. forEach ( exportedFromPath => {
869+ // Go through files that reference affected file and handle dts emit and semantic diagnostics for them and their references
870+ state . referencedMap . getKeys ( affectedFile . resolvedPath ) ?. forEach ( exportedFromPath => {
875871 if ( handleDtsMayChangeOfGlobalScope ( state , exportedFromPath , cancellationToken , host ) ) return true ;
876872 const references = state . referencedMap ! . getKeys ( exportedFromPath ) ;
877873 return references && forEachKey ( references , filePath =>
@@ -901,23 +897,12 @@ function handleDtsMayChangeOfFileAndExportsOfFile(
901897 if ( handleDtsMayChangeOfGlobalScope ( state , filePath , cancellationToken , host ) ) return true ;
902898 handleDtsMayChangeOf ( state , filePath , cancellationToken , host ) ;
903899
904- // If exported modules has path, all files referencing file exported from are affected
905- state . exportedModulesMap ! . getKeys ( filePath ) ?. forEach ( exportedFromPath =>
906- handleDtsMayChangeOfFileAndExportsOfFile (
907- state ,
908- exportedFromPath ,
909- seenFileAndExportsOfFile ,
910- cancellationToken ,
911- host ,
912- )
913- ) ;
914-
915- // Remove diagnostics of files that import this file (without going to exports of referencing files)
900+ // Remove the diagnostics of files that import this file and handle all its exports too
916901 state . referencedMap ! . getKeys ( filePath ) ?. forEach ( referencingFilePath =>
917- ! seenFileAndExportsOfFile . has ( referencingFilePath ) && // Not already removed diagnostic file
918- handleDtsMayChangeOf ( // Dont add to seen since this is not yet done with the export removal
902+ handleDtsMayChangeOfFileAndExportsOfFile (
919903 state ,
920904 referencingFilePath ,
905+ seenFileAndExportsOfFile ,
921906 cancellationToken ,
922907 host ,
923908 )
@@ -1012,7 +997,6 @@ export interface ProgramMultiFileEmitBuildInfo {
1012997 options : CompilerOptions | undefined ;
1013998 fileIdsList : readonly ( readonly ProgramBuildInfoFileId [ ] ) [ ] | undefined ;
1014999 referencedMap : ProgramBuildInfoReferencedMap | undefined ;
1015- exportedModulesMap : ProgramBuildInfoReferencedMap | undefined ;
10161000 semanticDiagnosticsPerFile : ProgramBuildInfoDiagnostic [ ] | undefined ;
10171001 emitDiagnosticsPerFile : ProgramBuildInfoDiagnostic [ ] | undefined ;
10181002 affectedFilesPendingEmit : ProgramBuilderInfoFilePendingEmit [ ] | undefined ;
@@ -1139,17 +1123,6 @@ function getBuildInfo(state: BuilderProgramState): BuildInfo {
11391123 ] ) ;
11401124 }
11411125
1142- let exportedModulesMap : ProgramBuildInfoReferencedMap | undefined ;
1143- if ( state . exportedModulesMap ) {
1144- exportedModulesMap = mapDefined ( arrayFrom ( state . exportedModulesMap . keys ( ) ) . sort ( compareStringsCaseSensitive ) , key => {
1145- const oldValue = state . oldExportedModulesMap ?. get ( key ) ;
1146- // Not in temporary cache, use existing value
1147- if ( oldValue === undefined ) return [ toFileId ( key ) , toFileIdListId ( state . exportedModulesMap ! . getValues ( key ) ! ) ] ;
1148- if ( oldValue ) return [ toFileId ( key ) , toFileIdListId ( oldValue ) ] ;
1149- return undefined ;
1150- } ) ;
1151- }
1152-
11531126 const semanticDiagnosticsPerFile = convertToProgramBuildInfoDiagnostics ( state . semanticDiagnosticsPerFile ) ;
11541127 let affectedFilesPendingEmit : ProgramBuilderInfoFilePendingEmit [ ] | undefined ;
11551128 if ( state . affectedFilesPendingEmit ?. size ) {
@@ -1185,7 +1158,6 @@ function getBuildInfo(state: BuilderProgramState): BuildInfo {
11851158 options : convertToProgramBuildInfoCompilerOptions ( state . compilerOptions ) ,
11861159 fileIdsList,
11871160 referencedMap,
1188- exportedModulesMap,
11891161 semanticDiagnosticsPerFile,
11901162 emitDiagnosticsPerFile,
11911163 affectedFilesPendingEmit,
@@ -1602,8 +1574,7 @@ export function createBuilderProgram(kind: BuilderProgramKind, { newProgram, hos
16021574 // With d.ts diagnostics they are also part of the signature so emitSignature will be different from it since its just hash of d.ts
16031575 if ( ! data ?. diagnostics ?. length ) emitSignature = signature ;
16041576 if ( signature !== file . version ) { // Update it
1605- if ( host . storeFilesChangingSignatureDuringEmit ) ( state . filesChangingSignature ??= new Set ( ) ) . add ( file . resolvedPath ) ;
1606- if ( state . exportedModulesMap ) BuilderState . updateExportedModules ( state , file , file . exportedModulesFromDeclarationEmit ) ;
1577+ if ( host . storeSignatureInfo ) ( state . signatureInfo ??= new Map ( ) ) . set ( file . resolvedPath , SignatureInfo . StoredSignatureAtEmit ) ;
16071578 if ( state . affectedFiles ) {
16081579 // Keep old signature so we know what to undo if cancellation happens
16091580 const existing = state . oldSignatures ?. get ( file . resolvedPath ) ;
@@ -1613,7 +1584,6 @@ export function createBuilderProgram(kind: BuilderProgramKind, { newProgram, hos
16131584 else {
16141585 // These are directly committed
16151586 info . signature = signature ;
1616- state . oldExportedModulesMap ?. clear ( ) ;
16171587 }
16181588 }
16191589 }
@@ -1862,7 +1832,6 @@ export function createBuilderProgramUsingProgramBuildInfo(buildInfo: BuildInfo,
18621832 fileInfos,
18631833 compilerOptions : program . options ? convertToOptionsWithAbsolutePaths ( program . options , toAbsolutePath ) : { } ,
18641834 referencedMap : toManyToManyPathMap ( program . referencedMap ) ,
1865- exportedModulesMap : toManyToManyPathMap ( program . exportedModulesMap ) ,
18661835 semanticDiagnosticsPerFile : toPerFileDiagnostics ( program . semanticDiagnosticsPerFile ) ,
18671836 emitDiagnosticsPerFile : toPerFileDiagnostics ( program . emitDiagnosticsPerFile ) ,
18681837 hasReusableDiagnostic : true ,
0 commit comments