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(
322322
323323 for ( let index = statementIndex + 1 ; index < statements . length ; ++ index ) {
324324 const statement = statements [ index ] ;
325+
325326 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+
326334 break ;
327335 }
328336
Original file line number Diff line number Diff line change @@ -88,6 +88,36 @@ describe('wrap enums and classes transformer', () => {
8888 expect ( tags . oneLine `${ transform ( input ) } ` ) . toEqual ( tags . oneLine `${ output } ` ) ;
8989 } ) ;
9090
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+
91121 it ( 'should not wrap enum like which are inside of methods' , ( ) => {
92122 const input = tags . stripIndent `
93123 class LayoutDirective {
You can’t perform that action at this time.
0 commit comments