@@ -850,7 +850,7 @@ export class AngularCompilerPlugin {
850
850
851
851
// If nothing we care about changed and it isn't the first run, don't do anything.
852
852
if ( changedFiles . length === 0 && ! this . _firstRun ) {
853
- return Promise . resolve ( ) ;
853
+ return ;
854
854
}
855
855
856
856
// Make a new program and load the Angular structure.
@@ -876,24 +876,9 @@ export class AngularCompilerPlugin {
876
876
}
877
877
}
878
878
879
- // Emit and report errors.
880
-
881
- // We now have the final list of changed TS files.
882
- // Go through each changed file and add transforms as needed.
883
- const sourceFiles = this . _getChangedTsFiles ( )
884
- . map ( ( fileName ) => ( this . _getTsProgram ( ) as ts . Program ) . getSourceFile ( fileName ) )
885
- // At this point we shouldn't need to filter out undefined files, because any ts file
886
- // that changed should be emitted.
887
- // But due to hostReplacementPaths there can be files (the environment files)
888
- // that changed but aren't part of the compilation, specially on `ng test`.
889
- // So we ignore missing source files files here.
890
- // hostReplacementPaths needs to be fixed anyway to take care of the following issue.
891
- // https://github.com/angular/angular-cli/issues/7305#issuecomment-332150230
892
- . filter ( ( x ) => ! ! x ) as ts . SourceFile [ ] ;
893
-
894
879
// Emit files.
895
880
time ( 'AngularCompilerPlugin._update._emit' ) ;
896
- const { emitResult, diagnostics } = this . _emit ( sourceFiles ) ;
881
+ const { emitResult, diagnostics } = this . _emit ( changedFiles ) ;
897
882
timeEnd ( 'AngularCompilerPlugin._update._emit' ) ;
898
883
899
884
// Report diagnostics.
@@ -1036,7 +1021,7 @@ export class AngularCompilerPlugin {
1036
1021
// This code mostly comes from `performCompilation` in `@angular/compiler-cli`.
1037
1022
// It skips the program creation because we need to use `loadNgStructureAsync()`,
1038
1023
// and uses CustomTransformers.
1039
- private _emit ( sourceFiles : ts . SourceFile [ ] ) {
1024
+ private _emit ( changedFiles : string [ ] ) {
1040
1025
time ( 'AngularCompilerPlugin._emit' ) ;
1041
1026
const program = this . _program ;
1042
1027
const allDiagnostics : Array < ts . Diagnostic | Diagnostic > = [ ] ;
@@ -1059,7 +1044,7 @@ export class AngularCompilerPlugin {
1059
1044
}
1060
1045
1061
1046
if ( ! hasErrors ( allDiagnostics ) ) {
1062
- if ( this . _firstRun || sourceFiles . length > 20 ) {
1047
+ if ( this . _firstRun ) {
1063
1048
emitResult = tsProgram . emit (
1064
1049
undefined ,
1065
1050
undefined ,
@@ -1069,15 +1054,19 @@ export class AngularCompilerPlugin {
1069
1054
) ;
1070
1055
allDiagnostics . push ( ...emitResult . diagnostics ) ;
1071
1056
} else {
1072
- sourceFiles . forEach ( ( sf ) => {
1073
- const timeLabel = `AngularCompilerPlugin._emit.ts+${ sf . fileName } +.emit` ;
1074
- time ( timeLabel ) ;
1075
- emitResult = tsProgram . emit ( sf , undefined , undefined , undefined ,
1076
- { before : this . _transformers } ,
1077
- ) ;
1078
- allDiagnostics . push ( ...emitResult . diagnostics ) ;
1079
- timeEnd ( timeLabel ) ;
1080
- } ) ;
1057
+ for ( const file of changedFiles ) {
1058
+ const sourceFile = tsProgram . getSourceFile ( file ) ;
1059
+
1060
+ if ( sourceFile ) {
1061
+ const timeLabel = `AngularCompilerPlugin._emit.ts+${ sourceFile . fileName } +.emit` ;
1062
+ time ( timeLabel ) ;
1063
+ emitResult = tsProgram . emit ( sourceFile , undefined , undefined , undefined ,
1064
+ { before : this . _transformers } ,
1065
+ ) ;
1066
+ allDiagnostics . push ( ...emitResult . diagnostics ) ;
1067
+ timeEnd ( timeLabel ) ;
1068
+ }
1069
+ }
1081
1070
}
1082
1071
}
1083
1072
} else {
0 commit comments