Skip to content

Commit e15eae8

Browse files
committed
WIP
1 parent 4f78f64 commit e15eae8

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

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

+13-2
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,19 @@ export function VariableDeclaration(node, context) {
167167
declarations.push(
168168
b.declarator(
169169
declarator.id,
170-
b.await(
171-
b.call('$.async_derived', rune === '$derived.by' ? value : b.thunk(value, true))
170+
b.call(
171+
b.member(
172+
b.await(
173+
b.call(
174+
'$.suspend',
175+
b.call(
176+
'$.async_derived',
177+
rune === '$derived.by' ? value : b.thunk(value, true)
178+
)
179+
)
180+
),
181+
'exit'
182+
)
172183
)
173184
)
174185
);

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

-12
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,6 @@ export function get_value(node) {
1717
*/
1818
export function add_state_transformers(context) {
1919
for (const [name, binding] of context.state.scope.declarations) {
20-
if (
21-
binding.kind === 'derived' &&
22-
context.state.analysis.async_deriveds.has(/** @type {CallExpression} */ (binding.initial))
23-
) {
24-
// async deriveds are a special case
25-
context.state.transform[name] = {
26-
read: b.call
27-
};
28-
29-
continue;
30-
}
31-
3220
if (
3321
is_state_source(binding, context.state.analysis) ||
3422
binding.kind === 'derived' ||

packages/svelte/src/internal/client/dom/blocks/boundary.js

+3
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ export function trigger_async_boundary(effect, trigger) {
244244
}
245245
}
246246

247+
// TODO separate this stuff out — suspending and context preservation should
248+
// be distinct concepts
249+
247250
/**
248251
* @template T
249252
* @param {Promise<T>} promise

0 commit comments

Comments
 (0)