@@ -3,14 +3,21 @@ import MagicString from 'magic-string';
33
44const whitespace = / \s / ;
55
6- // these will be removed
7- const disallowedNodeTypes = [
8- 'ExpressionStatement' ,
6+ // these will be removed in the body
7+ // of wrapped functions
8+ const bodyDisallowedNodeTypes = [
99 'DebuggerStatement' ,
1010 'ImportDeclaration' ,
1111 'ExportNamedDeclaration' ,
1212] ;
1313
14+ // these will be removed within the top
15+ // level properties of the final jsx
16+ const topLevelDisallowedNodeTypes = [
17+ ...bodyDisallowedNodeTypes ,
18+ 'ExpressionStatement' ,
19+ ] ;
20+
1421// these will also be removed
1522const expressionGlobals = [ 'thisComp' , 'thisLayer' , 'thisProperty' ] ;
1623
@@ -102,7 +109,7 @@ export default function afterEffectsJsx(options = { wrap: false }) {
102109 }
103110 // don't process child nodes
104111 this . skip ( ) ;
105- } else if ( disallowedNodeTypes . includes ( node . type ) ) {
112+ } else if ( bodyDisallowedNodeTypes . includes ( node . type ) ) {
106113 // Remove every top level node that isn't
107114 // a function or variable, as they're not allowed
108115 removeStatement ( node ) ;
@@ -174,7 +181,7 @@ export default function afterEffectsJsx(options = { wrap: false }) {
174181 }
175182 // don't process child nodes
176183 this . skip ( ) ;
177- } else if ( disallowedNodeTypes . includes ( node . type ) ) {
184+ } else if ( topLevelDisallowedNodeTypes . includes ( node . type ) ) {
178185 // Remove every top level node that isn't
179186 // a function or variable, as they're not allowed
180187 removeStatement ( node ) ;
0 commit comments