@@ -191,7 +191,7 @@ describe('adjust-static-class-members Babel plugin', () => {
191191 ` ) ;
192192 } ) ;
193193
194- it ( 'does wrap not class with only side effect fields' , ( ) => {
194+ it ( 'does not wrap class with only side effect fields' , ( ) => {
195195 testCaseNoChange ( `
196196 class CustomComponentEffects {
197197 constructor(_actions) {
@@ -203,6 +203,30 @@ describe('adjust-static-class-members Babel plugin', () => {
203203 ` ) ;
204204 } ) ;
205205
206+ it ( 'does not wrap class with only side effect native fields' , ( ) => {
207+ testCaseNoChange ( `
208+ class CustomComponentEffects {
209+ static someFieldWithSideEffects = console.log('foo');
210+ constructor(_actions) {
211+ this._actions = _actions;
212+ this.doThis = this._actions;
213+ }
214+ }
215+ ` ) ;
216+ } ) ;
217+
218+ it ( 'does not wrap class with only instance native fields' , ( ) => {
219+ testCaseNoChange ( `
220+ class CustomComponentEffects {
221+ someFieldWithSideEffects = console.log('foo');
222+ constructor(_actions) {
223+ this._actions = _actions;
224+ this.doThis = this._actions;
225+ }
226+ }
227+ ` ) ;
228+ } ) ;
229+
206230 it ( 'wraps class with pure annotated side effect fields (#__PURE__)' , ( ) => {
207231 testCase ( {
208232 input : `
@@ -229,6 +253,32 @@ describe('adjust-static-class-members Babel plugin', () => {
229253 } ) ;
230254 } ) ;
231255
256+ it ( 'wraps class with pure annotated side effect native fields (#__PURE__)' , ( ) => {
257+ testCase ( {
258+ input : `
259+ class CustomComponentEffects {
260+ static someFieldWithSideEffects = /*#__PURE__*/ console.log('foo');
261+ constructor(_actions) {
262+ this._actions = _actions;
263+ this.doThis = this._actions;
264+ }
265+ }
266+ ` ,
267+ expected : `
268+ let CustomComponentEffects = /*#__PURE__*/ (() => {
269+ class CustomComponentEffects {
270+ static someFieldWithSideEffects = /*#__PURE__*/ console.log('foo');
271+ constructor(_actions) {
272+ this._actions = _actions;
273+ this.doThis = this._actions;
274+ }
275+ }
276+ return CustomComponentEffects;
277+ })();
278+ ` ,
279+ } ) ;
280+ } ) ;
281+
232282 it ( 'wraps class with pure annotated side effect fields (@__PURE__)' , ( ) => {
233283 testCase ( {
234284 input : `
@@ -335,6 +385,32 @@ describe('adjust-static-class-members Babel plugin', () => {
335385 } ) ;
336386 } ) ;
337387
388+ it ( 'wraps exported class with a pure native static field' , ( ) => {
389+ testCase ( {
390+ input : `
391+ export class CustomComponentEffects {
392+ static someField = 42;
393+ constructor(_actions) {
394+ this._actions = _actions;
395+ this.doThis = this._actions;
396+ }
397+ }
398+ ` ,
399+ expected : `
400+ export let CustomComponentEffects = /*#__PURE__*/ (() => {
401+ class CustomComponentEffects {
402+ static someField = 42;
403+ constructor(_actions) {
404+ this._actions = _actions;
405+ this.doThis = this._actions;
406+ }
407+ }
408+ return CustomComponentEffects;
409+ })();
410+ ` ,
411+ } ) ;
412+ } ) ;
413+
338414 it ( 'wraps class with a basic literal static field' , ( ) => {
339415 testCase ( {
340416 input : `
@@ -416,6 +492,32 @@ describe('adjust-static-class-members Babel plugin', () => {
416492 ` ) ;
417493 } ) ;
418494
495+ it ( 'does not wrap class with only pure native static fields and some side effect static fields' , ( ) => {
496+ testCaseNoChange ( `
497+ class CustomComponentEffects {
498+ static someField = 42;
499+ constructor(_actions) {
500+ this._actions = _actions;
501+ this.doThis = this._actions;
502+ }
503+ }
504+ CustomComponentEffects.someFieldWithSideEffects = console.log('foo');
505+ ` ) ;
506+ } ) ;
507+
508+ it ( 'does not wrap class with only some pure native static fields' , ( ) => {
509+ testCaseNoChange ( `
510+ class CustomComponentEffects {
511+ static someField = 42;
512+ static someFieldWithSideEffects = console.log('foo');
513+ constructor(_actions) {
514+ this._actions = _actions;
515+ this.doThis = this._actions;
516+ }
517+ }
518+ ` ) ;
519+ } ) ;
520+
419521 it ( 'does not wrap class with class decorators when wrapDecorators is false' , ( ) => {
420522 testCaseNoChange (
421523 `
@@ -597,7 +699,7 @@ describe('adjust-static-class-members Babel plugin', () => {
597699 } ) ;
598700 } ) ;
599701
600- it ( 'wraps class with multiple Angular static field ' , ( ) => {
702+ it ( 'wraps class with multiple Angular static fields ' , ( ) => {
601703 testCase ( {
602704 input : `
603705 class CommonModule {
@@ -626,6 +728,41 @@ describe('adjust-static-class-members Babel plugin', () => {
626728 } ) ;
627729 } ) ;
628730
731+ it ( 'wraps class with multiple Angular native static fields' , ( ) => {
732+ testCase ( {
733+ input : `
734+ class CommonModule {
735+ static ɵfac = function CommonModule_Factory(t) { return new (t || CommonModule)(); };
736+ static ɵmod = /*@__PURE__*/ ɵngcc0.ɵɵdefineNgModule({ type: CommonModule });
737+ static ɵinj = /*@__PURE__*/ ɵngcc0.ɵɵdefineInjector({ providers: [
738+ { provide: NgLocalization, useClass: NgLocaleLocalization },
739+ ] });
740+ }
741+ ` ,
742+ expected : `
743+ let CommonModule = /*#__PURE__*/ (() => {
744+ class CommonModule {
745+ static ɵfac = function CommonModule_Factory(t) {
746+ return new (t || CommonModule)();
747+ };
748+ static ɵmod = /*@__PURE__*/ ɵngcc0.ɵɵdefineNgModule({
749+ type: CommonModule,
750+ });
751+ static ɵinj = /*@__PURE__*/ ɵngcc0.ɵɵdefineInjector({
752+ providers: [
753+ {
754+ provide: NgLocalization,
755+ useClass: NgLocaleLocalization,
756+ },
757+ ],
758+ });
759+ }
760+ return CommonModule;
761+ })();
762+ ` ,
763+ } ) ;
764+ } ) ;
765+
629766 it ( 'wraps default exported class with pure static fields' , ( ) => {
630767 testCase ( {
631768 input : `
0 commit comments