File tree 1 file changed +5
-20
lines changed
packages/svelte/src/compiler/phases/3-transform/server
1 file changed +5
-20
lines changed Original file line number Diff line number Diff line change @@ -362,25 +362,6 @@ function is_store_name(name) {
362
362
return name [ 0 ] === '$' && / [ A - Z a - z _ ] / . test ( name [ 1 ] ) ;
363
363
}
364
364
365
- /**
366
- *
367
- * @param {Iterable<import('#compiler').Binding> } bindings
368
- */
369
- function store_sub_exist ( bindings ) {
370
- for ( const binding of bindings ) {
371
- if ( binding . kind === 'store_sub' ) {
372
- for ( const reference of binding . references ) {
373
- const node = reference . path . at ( - 1 ) ;
374
-
375
- // hacky way to ensure the sub is not in a directive e.g. use:$store as it is unneeded
376
- if ( node ?. type !== 'RegularElement' ) {
377
- return true ;
378
- }
379
- }
380
- }
381
- }
382
- }
383
-
384
365
/**
385
366
* @param {import('estree').AssignmentExpression } node
386
367
* @param {import('zimmerframe').Context<import('#compiler').SvelteNode, import('./types').ServerTransformState> } context
@@ -2108,7 +2089,11 @@ export function server_component(analysis, options) {
2108
2089
] ;
2109
2090
}
2110
2091
2111
- if ( store_sub_exist ( analysis . instance . scope . declarations . values ( ) ) ) {
2092
+ if (
2093
+ [ ...analysis . instance . scope . declarations . values ( ) ] . some (
2094
+ ( binding ) => binding . kind === 'store_sub'
2095
+ )
2096
+ ) {
2112
2097
instance . body . unshift ( b . const ( '$$store_subs' , b . object ( [ ] ) ) ) ;
2113
2098
template . body . push ( b . stmt ( b . call ( '$.unsubscribe_stores' , b . id ( '$$store_subs' ) ) ) ) ;
2114
2099
}
You can’t perform that action at this time.
0 commit comments