@@ -256,10 +256,8 @@ export class BuilderState {
256256 return true ;
257257 }
258258
259- for ( const file of this . #pendingCompilationFiles) {
260- if ( this . #watchedCompilationFiles. has ( file ) ) {
261- return true ;
262- }
259+ if ( ! this . #pendingCompilationFiles. isDisjointFrom ( this . #watchedCompilationFiles) ) {
260+ return true ;
263261 }
264262
265263 this . #pendingCompilationFiles. clear ( ) ;
@@ -281,12 +279,7 @@ export class BuilderState {
281279 return undefined ;
282280 }
283281
284- const files = new Set ( modifiedFiles ) ;
285- for ( const file of this . #pendingCompilationFiles) {
286- files . add ( file ) ;
287- }
288-
289- return files ;
282+ return modifiedFiles . union ( this . #pendingCompilationFiles) ;
290283 }
291284
292285 /**
@@ -380,7 +373,7 @@ export class BuilderState {
380373 collectedAssets : CollectedAssets ,
381374 manifestFiles ?: readonly OutputFile [ ] ,
382375 ) : ReadonlySet < string > {
383- const filesToDelete = new Set < string > ( ) ;
376+ let filesToDelete = new Set < string > ( ) ;
384377
385378 if ( this . #hasUpdatedBundles) {
386379 this . #hasUpdatedBundles = false ;
@@ -394,21 +387,14 @@ export class BuilderState {
394387 }
395388 }
396389
397- for ( const prevFile of this . #emittedBundleFiles) {
398- if ( ! nextBundleFiles . has ( prevFile ) ) {
399- filesToDelete . add ( prevFile ) ;
400- }
401- }
402-
390+ filesToDelete = this . #emittedBundleFiles. difference ( nextBundleFiles ) ;
403391 this . #emittedBundleFiles = nextBundleFiles ;
404392 }
405393
406394 if ( manifestFiles ) {
407395 const nextManifestFiles = new Set ( manifestFiles . map ( ( file ) => file . path ) ) ;
408- for ( const prevFile of this . #emittedManifestFiles) {
409- if ( ! nextManifestFiles . has ( prevFile ) ) {
410- filesToDelete . add ( prevFile ) ;
411- }
396+ for ( const prevFile of this . #emittedManifestFiles. difference ( nextManifestFiles ) ) {
397+ filesToDelete . add ( prevFile ) ;
412398 }
413399
414400 this . #emittedManifestFiles = nextManifestFiles ;
0 commit comments