File tree Expand file tree Collapse file tree 4 files changed +31
-0
lines changed
test/form/samples/tree-shake-arguments-conditional Expand file tree Collapse file tree 4 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import * as NodeType from './NodeType';
23
23
import { ExpressionEntity } from './shared/Expression' ;
24
24
import { MultiExpression } from './shared/MultiExpression' ;
25
25
import { ExpressionNode , IncludeChildren , NodeBase } from './shared/Node' ;
26
+ import SpreadElement from './SpreadElement' ;
26
27
27
28
export default class ConditionalExpression extends NodeBase implements DeoptimizableEntity {
28
29
alternate ! : ExpressionNode ;
@@ -154,6 +155,15 @@ export default class ConditionalExpression extends NodeBase implements Deoptimiz
154
155
}
155
156
}
156
157
158
+ includeCallArguments ( context : InclusionContext , args : ( ExpressionNode | SpreadElement ) [ ] ) : void {
159
+ if ( this . usedBranch === null ) {
160
+ this . consequent . includeCallArguments ( context , args ) ;
161
+ this . alternate . includeCallArguments ( context , args ) ;
162
+ } else {
163
+ this . usedBranch . includeCallArguments ( context , args ) ;
164
+ }
165
+ }
166
+
157
167
render (
158
168
code : MagicString ,
159
169
options : RenderOptions ,
Original file line number Diff line number Diff line change
1
+ module . exports = {
2
+ description : 'tracks tree-shaking of arguments through simplified conditionals'
3
+ } ;
Original file line number Diff line number Diff line change
1
+ function ignoringArgs ( ) {
2
+ return 'no args' ;
3
+ }
4
+
5
+ const handler = ignoringArgs ;
6
+
7
+ console . log ( handler ( ) ) ;
Original file line number Diff line number Diff line change
1
+ function ignoringArgs ( ) {
2
+ return 'no args' ;
3
+ }
4
+
5
+ function takingArgs ( arg ) {
6
+ return arg ;
7
+ }
8
+
9
+ const handler = false ? takingArgs : ignoringArgs ;
10
+
11
+ console . log ( handler ( 'should be removed' ) ) ;
You can’t perform that action at this time.
0 commit comments