forked from inertiajs/inertia
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[inertiajs#1872] Merge pull request #5 from jamesst20/svelte5-minimal…
…-main [inertiajs#1872] Svelte 5: Minimalest upgrade
- Loading branch information
Showing
7 changed files
with
2,194 additions
and
866 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
import { createInertiaApp } from '@inertiajs/svelte' | ||
import { hydrate, mount } from 'svelte' | ||
|
||
createInertiaApp({ | ||
resolve: (name) => { | ||
const pages = import.meta.glob('./Pages/**/*.svelte', { eager: true }) | ||
return pages[`./Pages/${name}.svelte`] | ||
}, | ||
setup({ el, App }) { | ||
new App({ target: el, hydrate: true }) | ||
// Svelte 4: new App({ target: el, hydrate: true }) | ||
|
||
// Svelte 5 | ||
if (el.dataset.serverRendered === 'true') { | ||
hydrate(App, { target: el }) | ||
} else { | ||
mount(App, { target: el }) | ||
} | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
import { createInertiaApp } from '@inertiajs/svelte' | ||
import createServer from '@inertiajs/svelte/server' | ||
|
||
import { render } from 'svelte/server' | ||
createServer((page) => | ||
createInertiaApp({ | ||
page, | ||
resolve: (name) => { | ||
const pages = import.meta.glob('./Pages/**/*.svelte', { eager: true }) | ||
return pages[`./Pages/${name}.svelte`] | ||
}, | ||
ssr: (AppSSR, props) => { | ||
// Svelte 4: return AppSSR.render(props) | ||
// Svelte 5: return render(AppSSR, { props }) | ||
return render(AppSSR, { props }) | ||
}, | ||
}), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters