@@ -137,6 +137,46 @@ const inputArrowFnWithImplicitReturn = tags.stripIndent`
137
137
}], null, null))();
138
138
` ;
139
139
140
+ const inputAsync = tags . stripIndent `
141
+ export class TestCmp {
142
+ }
143
+ TestCmp.ɵfac = function TestCmp_Factory(t) { return new (t || TestCmp)(); };
144
+ TestCmp.ɵcmp = i0.ɵɵdefineComponent({ type: TestCmp, selectors: [["test-cmp"]], standalone: true, features: [i0.ɵɵStandaloneFeature], decls: 3, vars: 0, template: function TestCmp_Template(rf, ctx) { }, encapsulation: 2 });
145
+ (function () {
146
+ (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵsetClassMetadataAsync(TestCmp,
147
+ function () { return [import("./cmp-a").then(function (m) { return m.CmpA; })]; },
148
+ function (CmpA) { i0.ɵsetClassMetadata(TestCmp, [{
149
+ type: Component,
150
+ args: [{
151
+ selector: 'test-cmp',
152
+ standalone: true,
153
+ imports: [CmpA],
154
+ template: '{#defer}<cmp-a />{/defer}',
155
+ }]
156
+ }], null, null); }); })();
157
+ ` ;
158
+
159
+ const inputAsyncArrowFn = tags . stripIndent `
160
+ export class TestCmp {
161
+ }
162
+ TestCmp.ɵfac = function TestCmp_Factory(t) { return new (t || TestCmp)(); };
163
+ TestCmp.ɵcmp = i0.ɵɵdefineComponent({ type: TestCmp, selectors: [["test-cmp"]], standalone: true, features: [i0.ɵɵStandaloneFeature], decls: 3, vars: 0, template: function TestCmp_Template(rf, ctx) { }, encapsulation: 2 });
164
+ (() => {
165
+ (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵsetClassMetadataAsync(TestCmp,
166
+ () => [import("./cmp-a").then((m) => m.CmpA)],
167
+ (CmpA) => {
168
+ i0.ɵsetClassMetadata(TestCmp, [{
169
+ type: Component,
170
+ args: [{
171
+ selector: 'test-cmp',
172
+ standalone: true,
173
+ imports: [CmpA],
174
+ template: '{#defer}<cmp-a />{/defer}',
175
+ }]
176
+ }], null, null);
177
+ }); })();
178
+ ` ;
179
+
140
180
describe ( '@ngtools/webpack transformers' , ( ) => {
141
181
describe ( 'remove-ivy-dev-calls' , ( ) => {
142
182
it ( 'should allow removing only set class metadata with pure annotation' , ( ) => {
@@ -396,5 +436,35 @@ describe('@ngtools/webpack transformers', () => {
396
436
397
437
expect ( tags . oneLine `${ result } ` ) . toEqual ( tags . oneLine `${ output } ` ) ;
398
438
} ) ;
439
+
440
+ it ( 'should remove setClassMetadataAsync calls' , ( ) => {
441
+ const output = tags . stripIndent `
442
+ export class TestCmp {
443
+ }
444
+ TestCmp.ɵfac = function TestCmp_Factory(t) { return new (t || TestCmp)(); };
445
+ TestCmp.ɵcmp = i0.ɵɵdefineComponent({ type: TestCmp, selectors: [["test-cmp"]], standalone: true, features: [i0.ɵɵStandaloneFeature], decls: 3, vars: 0, template: function TestCmp_Template(rf, ctx) { }, encapsulation: 2 });
446
+ ` ;
447
+
448
+ const result = transform ( inputAsync , ( getTypeChecker ) =>
449
+ removeIvyJitSupportCalls ( true , false , getTypeChecker ) ,
450
+ ) ;
451
+
452
+ expect ( tags . oneLine `${ result } ` ) . toEqual ( tags . oneLine `${ output } ` ) ;
453
+ } ) ;
454
+
455
+ it ( 'should remove arrow-function-based setClassMetadataAsync calls' , ( ) => {
456
+ const output = tags . stripIndent `
457
+ export class TestCmp {
458
+ }
459
+ TestCmp.ɵfac = function TestCmp_Factory(t) { return new (t || TestCmp)(); };
460
+ TestCmp.ɵcmp = i0.ɵɵdefineComponent({ type: TestCmp, selectors: [["test-cmp"]], standalone: true, features: [i0.ɵɵStandaloneFeature], decls: 3, vars: 0, template: function TestCmp_Template(rf, ctx) { }, encapsulation: 2 });
461
+ ` ;
462
+
463
+ const result = transform ( inputAsyncArrowFn , ( getTypeChecker ) =>
464
+ removeIvyJitSupportCalls ( true , false , getTypeChecker ) ,
465
+ ) ;
466
+
467
+ expect ( tags . oneLine `${ result } ` ) . toEqual ( tags . oneLine `${ output } ` ) ;
468
+ } ) ;
399
469
} ) ;
400
470
} ) ;
0 commit comments