@@ -3,14 +3,21 @@ import MagicString from 'magic-string';
3
3
4
4
const whitespace = / \s / ;
5
5
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 = [
9
9
'DebuggerStatement' ,
10
10
'ImportDeclaration' ,
11
11
'ExportNamedDeclaration' ,
12
12
] ;
13
13
14
+ // these will be removed within the top
15
+ // level properties of the final jsx
16
+ const topLevelDisallowedNodeTypes = [
17
+ ...bodyDisallowedNodeTypes ,
18
+ 'ExpressionStatement' ,
19
+ ] ;
20
+
14
21
// these will also be removed
15
22
const expressionGlobals = [ 'thisComp' , 'thisLayer' , 'thisProperty' ] ;
16
23
@@ -102,7 +109,7 @@ export default function afterEffectsJsx(options = { wrap: false }) {
102
109
}
103
110
// don't process child nodes
104
111
this . skip ( ) ;
105
- } else if ( disallowedNodeTypes . includes ( node . type ) ) {
112
+ } else if ( bodyDisallowedNodeTypes . includes ( node . type ) ) {
106
113
// Remove every top level node that isn't
107
114
// a function or variable, as they're not allowed
108
115
removeStatement ( node ) ;
@@ -174,7 +181,7 @@ export default function afterEffectsJsx(options = { wrap: false }) {
174
181
}
175
182
// don't process child nodes
176
183
this . skip ( ) ;
177
- } else if ( disallowedNodeTypes . includes ( node . type ) ) {
184
+ } else if ( topLevelDisallowedNodeTypes . includes ( node . type ) ) {
178
185
// Remove every top level node that isn't
179
186
// a function or variable, as they're not allowed
180
187
removeStatement ( node ) ;
0 commit comments