@@ -884,7 +884,6 @@ runInEachFileSystem(() => {
884
884
'deferred-a.ts' ,
885
885
`
886
886
import {Component} from '@angular/core';
887
-
888
887
@Component({
889
888
standalone: true,
890
889
selector: 'deferred-cmp-a',
@@ -899,7 +898,6 @@ runInEachFileSystem(() => {
899
898
'deferred-b.ts' ,
900
899
`
901
900
import {Component} from '@angular/core';
902
-
903
901
@Component({
904
902
standalone: true,
905
903
selector: 'deferred-cmp-b',
@@ -910,58 +908,81 @@ runInEachFileSystem(() => {
910
908
` ,
911
909
) ;
912
910
911
+ env . write (
912
+ 'pipe-a.ts' ,
913
+ `
914
+ import {Pipe} from '@angular/core';
915
+ @Pipe({
916
+ name: 'pipea',
917
+ })
918
+ export class PipeA {
919
+ }
920
+ ` ,
921
+ ) ;
922
+
913
923
env . write (
914
924
'test.ts' ,
915
925
`
916
926
import {Component} from '@angular/core';
917
927
import {DeferredCmpA} from './deferred-a';
918
928
import {DeferredCmpB} from './deferred-b';
919
-
929
+ import {PipeA} from './pipe-a';
920
930
@Component({
921
931
standalone: true,
922
932
// @ts-ignore
923
- deferredImports: [DeferredCmpA, DeferredCmpB],
933
+ deferredImports: [DeferredCmpA, DeferredCmpB, PipeA ],
924
934
template: \`
925
- @defer {
926
- <deferred-cmp-a />
927
- }
928
- @defer {
929
- <deferred-cmp-b />
935
+ @for (item of items; track item) {
936
+ @if (true) {
937
+ @defer {
938
+ {{ 'Hi!' | pipea }}
939
+ <deferred-cmp-a />
940
+ }
941
+ @defer {
942
+ <deferred-cmp-b />
943
+ }
944
+ }
930
945
}
931
946
\`,
932
947
})
933
948
export class AppCmp {
949
+ items = [1,2,3];
934
950
}
935
951
` ,
936
952
) ;
937
953
938
954
env . driveMain ( ) ;
939
955
const jsContents = env . getContents ( 'test.js' ) ;
940
956
941
- // Expect that all deferrableImports become dynamic imports.
957
+ // Expect that all deferrableImports in local compilation mode
958
+ // are located in a single function (since we can't detect in
959
+ // the local mode which components belong to which block).
942
960
expect ( jsContents ) . toContain (
943
- 'const AppCmp_Defer_1_DepsFn = () => [' +
944
- 'import("./deferred-a").then(m => m.DeferredCmpA)];' ,
961
+ 'const AppCmp_For_1_Conditional_0_Defer_1_DepsFn = () => [' +
962
+ 'import("./deferred-a").then(m => m.DeferredCmpA), ' +
963
+ 'import("./pipe-a").then(m => m.PipeA)];' ,
945
964
) ;
946
965
expect ( jsContents ) . toContain (
947
- 'const AppCmp_Defer_4_DepsFn = () => [' +
966
+ 'const AppCmp_For_1_Conditional_0_Defer_4_DepsFn = () => [' +
948
967
'import("./deferred-b").then(m => m.DeferredCmpB)];' ,
949
968
) ;
950
969
951
970
// Make sure there are no eager imports present in the output.
952
971
expect ( jsContents ) . not . toContain ( `from './deferred-a'` ) ;
953
972
expect ( jsContents ) . not . toContain ( `from './deferred-b'` ) ;
973
+ expect ( jsContents ) . not . toContain ( `from './pipe-a'` ) ;
954
974
955
- // Defer instructions have different dependency functions in full mode.
956
- expect ( jsContents ) . toContain ( 'ɵɵdefer(1, 0, AppCmp_Defer_1_DepsFn );' ) ;
957
- expect ( jsContents ) . toContain ( 'ɵɵdefer(4, 3, AppCmp_Defer_4_DepsFn );' ) ;
975
+ // There's 2 separate defer instructions due to the two separate defer blocks
976
+ expect ( jsContents ) . toContain ( 'ɵɵdefer(1, 0, AppCmp_For_1_Conditional_0_Defer_1_DepsFn );' ) ;
977
+ expect ( jsContents ) . toContain ( 'ɵɵdefer(4, 3, AppCmp_For_1_Conditional_0_Defer_4_DepsFn );' ) ;
958
978
959
979
// Expect `ɵsetClassMetadataAsync` to contain dynamic imports too.
960
980
expect ( jsContents ) . toContain (
961
981
'ɵsetClassMetadataAsync(AppCmp, () => [' +
962
982
'import("./deferred-a").then(m => m.DeferredCmpA), ' +
983
+ 'import("./pipe-a").then(m => m.PipeA), ' +
963
984
'import("./deferred-b").then(m => m.DeferredCmpB)], ' +
964
- '(DeferredCmpA, DeferredCmpB) => {' ,
985
+ '(DeferredCmpA, PipeA, DeferredCmpB) => {' ,
965
986
) ;
966
987
} ) ;
967
988
0 commit comments