Skip to content

Commit

Permalink
[Svelte] Fix SSR for Svelte 5 build 179+
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesst20 committed Sep 4, 2024
1 parent 7d04716 commit c8493ab
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 197 deletions.
3 changes: 2 additions & 1 deletion packages/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@types/lodash": "^4.17.7",
"axios": "^1.7.6",
"publint": "^0.2.10",
"svelte": "5.0.0-next.178",
"svelte": "5.0.0-next.243",
"svelte-check": "^3.8.6",
"tslib": "^2.7.0",
"typescript": "^5.5.4",
Expand All @@ -62,6 +62,7 @@
"type": "module",
"dependencies": {
"@jamesst20/inertia-core": "workspace:*",
"html-entities": "^2.5.2",
"lodash": "^4.17.21"
}
}
15 changes: 0 additions & 15 deletions packages/svelte/src/lib/components/SSR.svelte

This file was deleted.

8 changes: 4 additions & 4 deletions packages/svelte/src/lib/createInertiaApp.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { router, setupProgress, type InertiaAppResponse, type Page } from '@jamesst20/inertia-core'
import { encode } from 'html-entities'
import type { ComponentType } from 'svelte'
import { render } from 'svelte/server'
import App from './components/App.svelte'
import SSR, { type SSRProps } from './components/SSR.svelte'
import store from './store.svelte'
import type { ComponentResolver, ResolvedComponent } from './types'
import { render } from 'svelte/server'

interface CreateInertiaAppProps {
id?: string
Expand Down Expand Up @@ -46,10 +46,10 @@ export default async function createInertiaApp({
})

if (isServer) {
const { html, head } = render(SSR, { props: { id, initialPage } as SSRProps})
const { html, head } = render(App, {})

return {
body: html,
body: `<div data-server-rendered="true" id="${id}" data-page="${encode(JSON.stringify(initialPage))}">${html}</div>`,
head: [head],
}
}
Expand Down
2 changes: 1 addition & 1 deletion playgrounds/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"laravel-vite-plugin": "^1.0.5",
"lodash": "^4.17.21",
"postcss": "^8.4.42",
"svelte": "5.0.0-next.178",
"svelte": "5.0.0-next.243",
"svelte-check": "^3.8.6",
"tailwindcss": "^3.4.10",
"tslib": "^2.7.0",
Expand Down
Loading

0 comments on commit c8493ab

Please sign in to comment.