sveltejs / kit

web development, streamlined
https://kit.svelte.dev
MIT License
18.33k stars 1.87k forks source link

Warn on unused data #12458

Open Rich-Harris opened 1 month ago

Rich-Harris commented 1 month ago

Describe the problem

It's too easy to accidentally send more data from the server than you need. It would be nice if there was an easy way to see what's not being used.

Describe the proposed solution

An approach that would work in 95% of cases is to wrap data in a proxy that tracks which things get accessed during (server or client) render. The other 5% involves non-POJOs and data that's needed after the initial render. For this reason it probably can't be a loud obnoxious warning. I'm not exactly sure where the best place to surface this information would be.

Some years ago I wrote a library called object-cull that does a lot of the heavy lifting. It probably needs a spruce up but could be useful here.

Importance

nice to have

Rich-Harris commented 1 month ago

whoops wrong repo