Open
Description
Describe the bug
I came across an issue on Discord where someone tried using dynamic import() to load a component and pass it to data in the universal load:
export async function load({ data }) { data.component = (await import('$lib/components/Button.svelte')).default return data // ^ error }This threw an error along the lines of "cannot return non-serializable POJOs" since data was being returned by the server load in +page.server.js. Hopefully my contribution to the docs helps point out this lesser-known nuance.
Reproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-qnnygo?file=src%2Froutes%2F%2Bpage.js
Logs
No response
System Info
StackBlitz
Severity
annoyance
Additional Information
We could:
- Keep the current behaviour where
data
is mutated. - Prevent mutations of
data
from affecting the serialization of the server load data. - Throw an error telling users not to mutate
data
.