@@ -28,6 +28,7 @@ import { Node, ImportDeclaration, Identifier, Program, ExpressionStatement, Assi
28
28
import add_to_set from './utils/add_to_set' ;
29
29
import check_graph_for_cycles from './utils/check_graph_for_cycles' ;
30
30
import { print , x , b } from 'code-red' ;
31
+ import is_dynamic from './render_dom/wrappers/shared/is_dynamic' ;
31
32
32
33
interface ComponentOptions {
33
34
namespace ?: string ;
@@ -1144,9 +1145,9 @@ export default class Component {
1144
1145
if ( node . type === 'LabeledStatement' && node . label . name === '$' ) {
1145
1146
this . reactive_declaration_nodes . add ( node ) ;
1146
1147
1147
- const assignees = new Set ( ) ;
1148
+ const assignees = new Set < string > ( ) ;
1148
1149
const assignee_nodes = new Set ( ) ;
1149
- const dependencies = new Set ( ) ;
1150
+ const dependencies = new Set < string > ( ) ;
1150
1151
1151
1152
let scope = this . instance_scope ;
1152
1153
const map = this . instance_scope_map ;
@@ -1178,11 +1179,10 @@ export default class Component {
1178
1179
const owner = scope . find_owner ( name ) ;
1179
1180
const variable = component . var_lookup . get ( name ) ;
1180
1181
if ( variable ) variable . is_reactive_dependency = true ;
1181
- const is_writable_or_mutated =
1182
- variable && ( variable . writable || variable . mutated ) ;
1182
+
1183
1183
if (
1184
1184
( ! owner || owner === component . instance_scope ) &&
1185
- ( name [ 0 ] === '$' || is_writable_or_mutated )
1185
+ ( name [ 0 ] === '$' || variable )
1186
1186
) {
1187
1187
dependencies . add ( name ) ;
1188
1188
}
@@ -1202,6 +1202,17 @@ export default class Component {
1202
1202
const { expression } = node . body as ExpressionStatement ;
1203
1203
const declaration = expression && ( expression as AssignmentExpression ) . left ;
1204
1204
1205
+ const is_dependency_static = Array . from ( dependencies ) . every ( dependency => dependency !== '$$props' && ! is_dynamic ( this . var_lookup . get ( dependency ) ) ) ;
1206
+
1207
+ if ( is_dependency_static ) {
1208
+ assignees . forEach ( assignee => {
1209
+ const variable = component . var_lookup . get ( assignee ) ;
1210
+ if ( variable ) {
1211
+ variable . is_reactive_static = true ;
1212
+ }
1213
+ } ) ;
1214
+ }
1215
+
1205
1216
unsorted_reactive_declarations . push ( {
1206
1217
assignees,
1207
1218
dependencies,
0 commit comments