-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
svelte:head repeated in SSR possibly due to bindings/$$settled logic #4982
Comments
Made a repo (svelte-head-ssr-dupe-repro) using the default Sapper template for reproducing the issue. In <script>
let filename
const getCurrentFile = input => {
const split = input.split(/[\\/]/)
return split.splice(split.length - 2, split.length).join('/')
}
try {
// Should output `server/server.js` if run inside Node
filename = getCurrentFile(__filename)
} catch (error) {
// Should output something like `client/client.c11ed98a.js` if run inside browser
filename = getCurrentFile(document.scripts[document.scripts.length-1].src)
}
const style = `<style location="${filename}">p { color: blue; }</style>`
</script>
<svelte:head>
<title>Sapper project template</title>
{@html style}
</svelte:head> When running the Sapper dev server, this is the following output in <style location="server/server.js">p { color: blue; }</style>
<style location="client/client.4cce6104.js">p { color: blue; }</style> |
Im seeing this too when i do: <svelte:head>
{@html page.yoast_head}
</svelte:head> |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I haven't been able to create a simple repro for this unfortunately.
Tags inside
<svelte:head>
are being repeated in SSR output so any scripts defined there are getting loaded twice, e.g.:A console.trace from the top-level
<script>
of the component that has the<svelte:head>
block indicates that that component is being "called" twice also. The trace stack leads to a do-while loop in the callback passed tointernal.create_ssr_component
, which seems to be implementing logic for repeatedly rendering components until the values of bound props are resolved ($$settled
).The code that directly causes the repetition seems to be
$$result.head += ...
added by src/compiler/compile/render_ssr/handlers/Head.ts.The text was updated successfully, but these errors were encountered: