Open janosh opened 3 years ago
The warning is emitted by vite-plugin-svelte when it detects that a file change results in similar compiler output to inform the user of a skipped hmr update.
The output comparison omits add_location()
calls as the arguments change when you edit whitespace. In this case it seems that the svelte compiler itself strips the  
value, so when you remove one of the 2, an add_location call changes and causes the warning you posted.
It seems the svelte compiler removes  
if it is not accompanied by additional non-whitespace characters within the same textnode. you can try it in the svelte repl: https://svelte.dev/repl .
<p>x; <span>y</span></p>
shows the emsp, <p> <span>y</span></p>
doesn't.
This may even be correct according to spec. https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Whitespace I havn't been able to find definitions on how emsp should be treated. https://stackoverflow.com/questions/42463838/html-emsp-entity-exact-behavior is an old question regarding it but not really answered.
This may even be correct according to spec.
Even if (or especially if) the spec says not to render white space entities without following non-whitespace content, it shouldn't be briefly flashing in kit
on reloads, right?
Could be a difference in SSR rendering/hydration. I'll try to summon someone with deeper svelte compiler knowledge.
I found 2 things about it.
SSR
and hydration
.Should we update white space processing for SSR
mode in the compiler?
This is expected behavior I think.
SSR
and hydration
.Regarding compiler,
SSR
mode just render what a developer writes.
https://github.com/sveltejs/svelte/blob/master/src/compiler/compile/render_ssr/handlers/Text.ts
But for hydration
, there is whitespace normalization process.
https://github.com/sveltejs/svelte/blob/4d4f959f1643f45702c71c01dff13f43f64fef77/src/compiler/compile/render_dom/wrappers/Text.ts#L28-L41
And when Kit creates entry HTML
, it compiles as SSR mode.
But bundled index.svelte
is created as hydration
mode.
That's why you can see spaces briefly flashes at the beginning
because entry HTML
has compiled HTML by SSR
mode which doesn't have whitespace processing.
I think already we followed whitespace processing for hydration
.
But for SSR
is not like that.
Should we follow this?
I think we should follow because an initial HTML should be the same between SSR
and hydration
.
123
In the case of HMR, entry HTML
is not updated.
It just updates bundled index.svelte
.
I think this behavior is ok in terms of developer experience.
I mentioned that bundled index.svelte
is created by hydration
mode.
Therefore if you change only spaces, hydration
mode will normalize spaces, and bundled index.svelte
will not change.
Then both entry HTML
and bundled index.svelte
are not changed and briefly flashing is not happen.
Therefore I think this is expected behavior.
Describe the bug
Putting
 
or 
at the start of lines seems to be mishandled in the latest version ofkit
Reproduction
Pick the skeleton project, install deps, start dev server, then paste
into
src/routes/index.svelte
. The white space that should be inserted by  
in front of the numbers only briefly flashes on reloading the page.Logs
If you then delete one
 
, the compiler warnsSystem Info
Severity
annoyance