File tree Expand file tree Collapse file tree 3 files changed +22
-17
lines changed
packages/app/src/sandbox/eval/transpilers/babel/convert-esmodule Expand file tree Collapse file tree 3 files changed +22
-17
lines changed Original file line number Diff line number Diff line change 11// Jest Snapshot v1, https://goo.gl/fbAQLP
22
3- exports [` convert-esmodule can convert + + 1` ] = `
4- "\\ "use strict\\ ";
5- c = (10, + +15);
6- "
7- ` ;
8-
93exports [` convert-esmodule can convert class default exports 1` ] = `
104"\\ "use strict\\ ";
115Object.defineProperty(exports, \\ "__esModule\\ ", {
@@ -298,7 +292,7 @@ exports[`convert-esmodule doesn't set var definitions 1`] = `
298292Object.defineProperty(exports, \\ "__esModule\\ ", {
299293 value : true
300294} );
301- var global = typeof window !== \\ "undefined\\ " ? window : { } ;
295+ var global = typeof window !== \\ "undefined\\ " ? window : { } ;
302296exports.global = global;
303297"
304298` ;
@@ -635,6 +629,12 @@ var WS_CHARS = \\"u2000-
\\";
635629"
636630` ;
637631
632+ exports [` convert-esmodule printer issues can convert + + 1` ] = `
633+ "\\ "use strict\\ ";
634+ c = (10, + + 15);
635+ "
636+ ` ;
637+
638638exports [` convert-esmodule renames exports that are already defined, even in block scope 1` ] = `
639639"\\ "use strict\\ ";
640640var __$csb_exports = \\ "testtest\\ ";
Original file line number Diff line number Diff line change @@ -69,10 +69,7 @@ export const customGenerator = {
6969 ) {
7070 if ( node . prefix ) {
7171 state . write ( node . operator ) ;
72- if (
73- node . operator . length > 1 ||
74- node . argument . type === 'UnaryExpression'
75- ) {
72+ if ( node . operator . length > 1 ) {
7673 state . write ( ' ' ) ;
7774 }
7875 if (
@@ -83,6 +80,7 @@ export const customGenerator = {
8380 this [ node . argument . type ] ( node . argument , state ) ;
8481 state . write ( ')' ) ;
8582 } else {
83+ state . write ( ' ' ) ;
8684 this [ node . argument . type ] ( node . argument , state ) ;
8785 }
8886 } else {
Original file line number Diff line number Diff line change @@ -424,11 +424,18 @@ describe('convert-esmodule', () => {
424424 expect ( convertEsModule ( code ) ) . toMatchSnapshot ( ) ;
425425 } ) ;
426426
427- it ( 'can convert + +' , ( ) => {
428- const code = `
429- c = (10.0, + +(15))
430- ` ;
431-
432- expect ( convertEsModule ( code ) ) . toMatchSnapshot ( ) ;
427+ describe ( 'printer issues' , ( ) => {
428+ it ( 'can convert + +' , ( ) => {
429+ const code = `
430+ c = (10.0, + +(15))
431+ ` ;
432+
433+ expect ( convertEsModule ( code ) ) . toMatchSnapshot ( ) ;
434+ } ) ;
435+
436+ it ( 'can convert -(--i)' , ( ) => {
437+ const code = `a = -(--i)` ;
438+ expect ( convertEsModule ( code ) ) . toBe ( '"use strict";\na = - --i;\n' ) ;
439+ } ) ;
433440 } ) ;
434441} ) ;
You can’t perform that action at this time.
0 commit comments