Skip to content

Destructuring $derived results in quadratic code size #15996

Closed
@theonlypwner

Description

@theonlypwner

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions