-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bad compilation of valid Svelte 4 components under Svelte 5 #12254
Comments
No need to deploy; The reason Given code like this... <script>
import Input from "./Input.svelte";
</script>
{#each ['tom', 'dick', 'harry'] as author}
<Input bind:value={author} />
{/each} ...Svelte generates this wall of gibberish in SSR mode: import * as $ from "svelte/internal/server";
import Input from "./Input.svelte";
export default function App($$payload) {
let $$settled = true;
let $$inner_payload;
function $$render_inner($$payload) {
const each_array = $.ensure_array_like(['tom', 'dick', 'harry']);
$$payload.out += `<!--[-->`;
for (let $$index = 0; $$index < each_array.length; $$index++) {
const author = each_array[$$index];
$$payload.out += "<!--[-->";
$$payload.out += `<!--[-->`;
Input($$payload, {
get value() {
return author;
},
set value($$value) {
author = $$value;
$$settled = false;
}
});
$$payload.out += `<!--]-->`;
$$payload.out += "<!--]-->";
}
$$payload.out += "<!--]-->";
};
do {
$$settled = true;
$$inner_payload = $.copy_payload($$payload);
$$render_inner($$inner_payload);
} while (!$$settled);
$.assign_payload($$payload, $$inner_payload);
} This all exists because in Svelte 4, if a child component initializes a binding whose value is (Side-note: if you opt the component into runes mode (which needs Luckily, this is an easy fix, because Svelte 4 doesn't properly invalidate everything — it just... reassigns the function parameter: do {
$$settled = true;
// $$result.head is mutated by the literal expression
// need to reset it if we're looping back to prevent duplication
$$result.head = previous_head;
$$rendered = `${each(authors, author => {
return `${validate_component(Input, "Input").$$render(
$$result,
{ value: author },
{
value: $$value => {
author = $$value;
$$settled = false;
}
},
{}
)}`;
})}`;
} while (!$$settled); As such I think all we need to do is turn the |
@Rich-Harris Can you please clarify this?
Which bindings are undefined in my code? If you mean the |
They're not. But as far as the compiler is concerned, they could be |
Describe the bug
Repo is here https://github.com/arackaf/svelte-5-build-debug
Deploy it to Vercel, and you'll see these errors
If you check the git history, commit
1c2912b229c7a4efbb41f444e3ee7584f7d7ced5
imports adapter-vercel in order to set edge runtime settings. If you revert that commit, then the deployment suddenly works.So it looks like adapter-vercel is doing something weird.
Reproduction
See above
Logs
System Info
Severity
blocking an upgrade
The text was updated successfully, but these errors were encountered: