Skip to content

Commit 8197537

Browse files
committed
no need to push_derived_source with mutable_state, as it never coexists with $.derived
1 parent 6f43265 commit 8197537

File tree

4 files changed

+7
-14
lines changed

4 files changed

+7
-14
lines changed

packages/svelte/src/compiler/phases/3-transform/client/transform-client.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,10 @@ export function client_component(analysis, options) {
219219
for (const [name, binding] of analysis.instance.scope.declarations) {
220220
if (binding.kind === 'legacy_reactive') {
221221
legacy_reactive_declarations.push(
222-
b.const(name, b.call('$.mutable_state', undefined, analysis.immutable ? b.true : undefined))
222+
b.const(
223+
name,
224+
b.call('$.mutable_source', undefined, analysis.immutable ? b.true : undefined)
225+
)
223226
);
224227
}
225228
if (binding.kind === 'store_sub') {

packages/svelte/src/compiler/phases/3-transform/client/visitors/VariableDeclaration.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ function create_state_declarators(declarator, { scope, analysis }, value) {
299299
return [
300300
b.declarator(
301301
declarator.id,
302-
b.call('$.mutable_state', value, analysis.immutable ? b.true : undefined)
302+
b.call('$.mutable_source', value, analysis.immutable ? b.true : undefined)
303303
)
304304
];
305305
}
@@ -314,7 +314,7 @@ function create_state_declarators(declarator, { scope, analysis }, value) {
314314
return b.declarator(
315315
path.node,
316316
binding?.kind === 'state'
317-
? b.call('$.mutable_state', value, analysis.immutable ? b.true : undefined)
317+
? b.call('$.mutable_source', value, analysis.immutable ? b.true : undefined)
318318
: value
319319
);
320320
})

packages/svelte/src/internal/client/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export {
113113
user_effect,
114114
user_pre_effect
115115
} from './reactivity/effects.js';
116-
export { mutable_state, mutate, set, state, update, update_pre } from './reactivity/sources.js';
116+
export { mutable_source, mutate, set, state, update, update_pre } from './reactivity/sources.js';
117117
export {
118118
prop,
119119
rest_props,

packages/svelte/src/internal/client/reactivity/sources.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,6 @@ export function mutable_source(initial_value, immutable = false) {
101101
return s;
102102
}
103103

104-
/**
105-
* @template V
106-
* @param {V} v
107-
* @param {boolean} [immutable]
108-
* @returns {Source<V>}
109-
*/
110-
export function mutable_state(v, immutable = false) {
111-
return push_derived_source(mutable_source(v, immutable));
112-
}
113-
114104
/**
115105
* @template V
116106
* @param {Source<V>} source

0 commit comments

Comments
 (0)