File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
packages/angular_devkit/build_optimizer/src/transforms Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -322,7 +322,15 @@ function findStatements(
322
322
323
323
for ( let index = statementIndex + 1 ; index < statements . length ; ++ index ) {
324
324
const statement = statements [ index ] ;
325
+
325
326
if ( ! ts . isExpressionStatement ( statement ) ) {
327
+ // The below is a workaround for NGCC as TS will never emit an EmptyStatement.
328
+ // See: https://github.com/angular/angular-cli/issues/16509#issuecomment-570198398
329
+ if ( ts . isEmptyStatement ( statement ) ) {
330
+ count ++ ;
331
+ continue ;
332
+ }
333
+
326
334
break ;
327
335
}
328
336
Original file line number Diff line number Diff line change @@ -88,6 +88,36 @@ describe('wrap enums and classes transformer', () => {
88
88
expect ( tags . oneLine `${ transform ( input ) } ` ) . toEqual ( tags . oneLine `${ output } ` ) ;
89
89
} ) ;
90
90
91
+ it ( 'should wrap classes which contain EmptyStatement' , ( ) => {
92
+ const input = tags . stripIndent `
93
+ let JigsawTrustedHtml = JigsawTrustedHtml_1 = class JigsawTrustedHtml {
94
+ constructor(_sanitizer, zone) {
95
+ }
96
+ static _getContext(magicNumber) {
97
+ return JigsawTrustedHtml_1._contexts[magicNumber];
98
+ }
99
+ };
100
+ JigsawTrustedHtml.ɵfac = function JigsawTrustedHtml_Factory(t) { };
101
+ // NGCC outputs an empty statement sometimes like the below:
102
+ // https://github.com/angular/angular-cli/issues/16509#issuecomment-570198398
103
+ JigsawTrustedHtml.ɵdir = ɵngcc0.ɵɵdefineDirective(); ;
104
+ JigsawTrustedHtml.ctorParameters = () => [
105
+ { type: DomSanitizer },
106
+ { type: NgZone }
107
+ ];
108
+ ` ;
109
+
110
+ const output = tags . stripIndent `
111
+ let JigsawTrustedHtml = /*@__PURE__*/ (() => {
112
+ ${ input }
113
+
114
+ return JigsawTrustedHtml;
115
+ })();
116
+ ` ;
117
+
118
+ expect ( tags . oneLine `${ transform ( input ) } ` ) . toEqual ( tags . oneLine `${ output } ` ) ;
119
+ } ) ;
120
+
91
121
it ( 'should not wrap enum like which are inside of methods' , ( ) => {
92
122
const input = tags . stripIndent `
93
123
class LayoutDirective {
You can’t perform that action at this time.
0 commit comments