Skip to content

$derived needs a $effect.root to act reactive #14997

@sanderhahn

Description

@sanderhahn

Describe the bug

As part of asking about how the testing setup of vitest is (#14900). A solution was provided that introduces a $derived, however that example doesn't work without an explict $effect.root. Multiple people have claimed that this should just work without the $effect.root, however this doesn't seem to be the case. At the moment I am not the biggest expert in the Svelte 5 reactivity story, so please correct me if this issue is invalid.

Reproduction

An example is provided by @Thiagolino8:
https://stackblitz.com/edit/vitejs-vite-lqzixy57?file=src%2Fmultiplier.svelte.test.ts

Logs

No response

System Info

System:
    OS: macOS 15.2
    CPU: (8) arm64 Apple M1
    Memory: 160.63 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.12.0 - /usr/local/bin/node
    npm: 10.9.0 - /usr/local/bin/npm
    pnpm: 9.15.3 - ~/.npm-packages/bin/pnpm
    bun: 1.1.43 - ~/.bun/bin/bun
  Browsers:
    Safari: 18.2

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