QwikDev / qwik

Instant-loading web apps, without effort
https://qwik.dev
MIT License
20.71k stars 1.29k forks source link

[🐞] Qwik serializes the entire object even when capturing only a specific object property. #6920

Open jacrabb opened 4 days ago

jacrabb commented 4 days ago

Which component is affected?

Qwik Runtime

Describe the bug

Qwik serializes the entire object even when capturing only a specific object property.

As described in https://qwik.dev/tutorial/understanding/capturing/, Qwik should narrowly serialize a listener's data based on the scope of what that listener closes over. For instance, an onClick$ event closing over a single property of a useStore should not serialize the entire useStore.

You can observe this behavior in v2 as well: https://qwikdev-build-v2.qwik-8nx.pages.dev/tutorial/understanding/capturing/

Reproduction

https://stackblitz.com/edit/github-s6wkde?file=src%2Fcomponents%2Fstarter%2Fcounter%2Fcounter.tsx

Steps to reproduce

Load stackblitz link, run npm run dev OR npm run preview, and inspect the source of the preview window. You will find 'PRETEND THIS IS A LARGE DATASET' serialized to the client.

System Info

stackblitz

Additional Information

This was discussed briefly in Discord: https://discord.com/channels/842438759945601056/1275604997500960778