Skip to content

Destructuring $derived results in quadratic code size #15996

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

Open
theonlypwner opened this issue May 24, 2025 · 0 comments · May be fixed by #16000
Open

Destructuring $derived results in quadratic code size #15996

theonlypwner opened this issue May 24, 2025 · 0 comments · May be fixed by #16000

Comments

@theonlypwner
Copy link

theonlypwner commented May 24, 2025

Describe the bug

Destructuring $derived with N values results in code size that is quadratic in N. The expected outcome is that it would be linear by destructuring only the value that is actually used.

For example, destructuring 26 values results in code that destructures 26 values being repeated 26 times, resulting in 676 destructurings. See the JS output in the REPL example below.

This issue doesn't occur when destructuring $props.

Reproduction

https://svelte.dev/playground/hello-world?version=5.33.1#H4sIAAAAAAAACrWQzU7DQAyEX2VkcWilUXoPBYkbXBA3DoRD2rh0YbsJWbdpG-Xd0fJXKrVHLpY1tjXjr5dQrlRyuVXva3R16yuMtHKm1VgoC-c1Sv7Ui-2atJcE4c_VTdNkcaPekjYro57S53UwDRYll2mct66x6yIUNpnAxbhWdM6WuKi0dRut0sSroUfT1g0GXOEidXE0vjzMSmJGzImKUGJBvBBLwhGvxBvhiRURiJpoiHeiJSJhxJrYEB2xJXbE_svj236UvJLTdPIbVSimW5Pc2rUOPIPivr5L3zw6Wz6kvCe5nF86DynUR5w-YfwniQPtPwz6cihCP0tlPhQhy7Ii9PvhGM0zxUrnOxcqyReljzp8AC9EOYRgAgAA

System Info

Svelte REPL with version 5.33.1

Severity

annoyance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant