File tree Expand file tree Collapse file tree 5 files changed +60
-13
lines changed
test/form/samples/request-tree-shaking-before-render Expand file tree Collapse file tree 5 files changed +60
-13
lines changed Original file line number Diff line number Diff line change @@ -46,12 +46,22 @@ export default class ConditionalExpression extends NodeBase implements Deoptimiz
46
46
}
47
47
48
48
deoptimizeCache ( ) : void {
49
- this . isBranchResolutionAnalysed = false ;
49
+ if (
50
+ this . usedBranch ||
51
+ this . isBranchResolutionAnalysed ||
52
+ this . expressionsToBeDeoptimized . length > 0
53
+ ) {
54
+ // Request another pass because we need to ensure "include" runs again if it is rendered
55
+ this . scope . context . requestTreeshakingPass ( ) ;
56
+ }
50
57
const { expressionsToBeDeoptimized } = this ;
51
- this . expressionsToBeDeoptimized = [ ] ;
52
- for ( const expression of expressionsToBeDeoptimized ) {
53
- expression . deoptimizeCache ( ) ;
58
+ if ( expressionsToBeDeoptimized . length > 0 ) {
59
+ this . expressionsToBeDeoptimized = [ ] ;
60
+ for ( const expression of expressionsToBeDeoptimized ) {
61
+ expression . deoptimizeCache ( ) ;
62
+ }
54
63
}
64
+ this . isBranchResolutionAnalysed = false ;
55
65
if ( this . usedBranch !== null ) {
56
66
const unusedBranch = this . usedBranch === this . consequent ? this . alternate : this . consequent ;
57
67
this . usedBranch = null ;
Original file line number Diff line number Diff line change @@ -57,20 +57,22 @@ export default class LogicalExpression extends NodeBase implements Deoptimizable
57
57
}
58
58
59
59
deoptimizeCache ( ) : void {
60
- this . isBranchResolutionAnalysed = false ;
61
- if ( this . expressionsToBeDeoptimized . length > 0 ) {
62
- const {
63
- scope : { context } ,
64
- expressionsToBeDeoptimized
65
- } = this ;
60
+ if (
61
+ this . usedBranch ||
62
+ this . isBranchResolutionAnalysed ||
63
+ this . expressionsToBeDeoptimized . length > 0
64
+ ) {
65
+ // Request another pass because we need to ensure "include" runs again if it is rendered
66
+ this . scope . context . requestTreeshakingPass ( ) ;
67
+ }
68
+ const { expressionsToBeDeoptimized } = this ;
69
+ if ( expressionsToBeDeoptimized . length > 0 ) {
66
70
this . expressionsToBeDeoptimized = [ ] ;
67
71
for ( const expression of expressionsToBeDeoptimized ) {
68
72
expression . deoptimizeCache ( ) ;
69
73
}
70
- // Request another pass because we need to ensure "include" runs again if
71
- // it is rendered
72
- context . requestTreeshakingPass ( ) ;
73
74
}
75
+ this . isBranchResolutionAnalysed = false ;
74
76
if ( this . usedBranch ) {
75
77
const unusedBranch = this . usedBranch === this . left ? this . right : this . left ;
76
78
this . usedBranch = null ;
Original file line number Diff line number Diff line change
1
+ module . exports = defineTest ( {
2
+ description : 'a new tree-shaking is required so render will not fail'
3
+ } ) ;
Original file line number Diff line number Diff line change
1
+ function s ( t ) {
2
+ t ( x ) ;
3
+ }
4
+
5
+ function f ( b ) {
6
+ return x . concat ( ( b ? 1 : 0 ) )
7
+ }
8
+
9
+ function w ( b ) {
10
+ f ( b ) ;
11
+ }
12
+
13
+ w ( 1 ) ;
14
+ s ( ( ) => {
15
+ return w ( 0 )
16
+ } ) ;
Original file line number Diff line number Diff line change
1
+ function s ( t ) {
2
+ t ( x )
3
+ }
4
+
5
+ function f ( b ) {
6
+ return x . concat ( ( b ? 1 : 0 ) )
7
+ }
8
+
9
+ function w ( b ) {
10
+ f ( b )
11
+ }
12
+
13
+ w ( 1 )
14
+ s ( ( ) => {
15
+ return w ( 0 )
16
+ } )
You can’t perform that action at this time.
0 commit comments