Sunday, 12 January 2025

svelte HMR

https://github.com/sveltejs/svelte-hmr/tree/master/packages/svelte-hmr#preservation-of-local-state says:

On the contrary, if you keep the default preserveLocalState to false, you can enable preservation of all the local state of a given component by adding the following comment: // @hmr:keep-all. You can also preserve only the state of some specific variables, by annotating them with: // @hmr:keep.

How to decide which systems to reboot when code changes? Developing gets waitsy when everything has to complicatedly clunk.

If I change code in audio.svelte.ts,

The reload happens to Call.svelte, which includes it via Peering via Party.


The later "hot updated" messages are for the nearest Component, though nothing seems to mention the test.js location of the change...

That first one though we have hooked in before with the following code, as vite suggested, but it doesn't seem to all be there:

// < HMR can sort-of be listened for
$effect(() => {
if (import.meta.hot) {
import.meta.hot.accept((mod) => {
let of = {
// always rather opaque
mod,
// always Call.svelte?t=...
url:import.meta.url,
// empty, guesses from AI at what it would expect to be here?
hot:import.meta.hot,
id:import.meta.hot.id,
}
console.log("Codechange!", of)
})
// if you write these as import.meta.hot.accept(
// it compiles in a ['default'] as a first argument
// and an error about our strings being a callback occurs elsewhere
// so svelte must be obscuring vite's advertised feature of thus:
let imh = import.meta.hot
// none of these work?
imh.accept('/src/lib/kolektiva/Party.svelte', (newFoo) => {
console.log("Party Codechange!", {url:import.meta.url,newFoo})
})
imh.accept('kolektiva/Party.svelte', (newFoo) => {
console.log("Party short Codechange!", {url:import.meta.url,newFoo})
})
imh.accept('./kolektiva/Party.svelte', (newFoo) => {
console.log("Party ./short Codechange!", {url:import.meta.url,newFoo})
})
}
else {
throw "never here"
}
})

Probably because svelte is between us and vite, doing something I can't find info about - the discord wants me to click squirrels.

And so,

Just separate what should reload into a component! Yay.

I guess this means my UI, which is a list of participants (Y axis) and their features (X axis), may want to be a multi-table join sort of thing.

Which means I'm writing a table class with synthesized absolute positioning! It also seems like the Basket grouper|compressor I built before...

No comments:

Post a Comment