pull/17165/head
Simon Holthausen 5 days ago
parent 31a239833e
commit b73a22849f

@ -48,7 +48,11 @@ export function SvelteBoundary(node, context) {
if (child.type === 'ConstTag') { if (child.type === 'ConstTag') {
has_const = true; has_const = true;
if (!context.state.options.experimental.async) { if (!context.state.options.experimental.async) {
context.visit(child, { ...context.state, consts: const_tags }); context.visit(child, {
...context.state,
consts: const_tags,
scope: context.state.scopes.get(node.fragment) ?? context.state.scope
});
} }
} }
} }

@ -25,20 +25,23 @@ export default function Async_in_derived($$anchor, $$props) {
{ {
var consequent = ($$anchor) => { var consequent = ($$anchor) => {
$.async_body($$anchor, async ($$anchor) => { let yes1;
const yes1 = (await $.save($.async_derived(async () => (await $.save(1))())))(); let yes2;
const yes2 = (await $.save($.async_derived(async () => foo((await $.save(1))()))))(); let no1;
let no2;
const no1 = $.derived(() => (async () => { var promises = $.run([
return await 1; async () => yes1 = (await $.save($.async_derived(async () => (await $.save(1))())))(),
})()); async () => yes2 = (await $.save($.async_derived(async () => foo((await $.save(1))()))))(),
const no2 = $.derived(() => (async () => { () => no1 = $.derived(() => (async () => {
return await 1; return await 1;
})()); })()),
if ($.aborted()) return; () => no2 = $.derived(() => (async () => {
}); return await 1;
})())
]);
}; };
$.if(node, ($$render) => { $.if(node, ($$render) => {

@ -18,24 +18,38 @@ export default function Async_in_derived($$renderer, $$props) {
} }
]); ]);
$$renderer.async_block([], async ($$renderer) => {
if (true) { if (true) {
$$renderer.push('<!--[-->'); $$renderer.push('<!--[-->');
const yes1 = (await $.save(1))(); let yes1;
const yes2 = foo((await $.save(1))()); let yes2;
let no1;
let no2;
const no1 = (async () => { var promises = $$renderer.run([
async () => {
yes1 = (await $.save(1))();
},
async () => {
yes2 = foo((await $.save(1))());
},
() => {
no1 = (async () => {
return await 1; return await 1;
})(); })();
},
const no2 = (async () => { () => {
no2 = (async () => {
return await 1; return await 1;
})(); })();
}
]);
} else { } else {
$$renderer.push('<!--[!-->'); $$renderer.push('<!--[!-->');
} }
});
$$renderer.push(`<!--]-->`); $$renderer.push(`<!--]-->`);
}); });

Loading…
Cancel
Save