Skip to content

Commit 7b5f9ac

Browse files
committed
Get Svelte version from package
1 parent fad8640 commit 7b5f9ac

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

lib/generators/inertia/install/templates/svelte/InertiaExample.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<script>
2+
import { VERSION } from 'svelte/compiler'
3+
24
import railsSvg from '/assets/rails.svg'
35
import svelteSvg from '/assets/svelte.svg'
46
import inertiaSvg from '/assets/inertia.svg'
57
68
let { rails_version, rack_version, ruby_version, inertia_rails_version } = $props()
7-
let svelte_version = Array.from(window.__svelte.v).join(".")
89
</script>
910

1011
<svelte:head>
@@ -42,7 +43,7 @@
4243
<li>
4344
<ul>
4445
<li><strong>Inertia Rails version:</strong> {inertia_rails_version}</li>
45-
<li><strong>Svelte version:</strong> {svelte_version}</li>
46+
<li><strong>Svelte version:</strong> {VERSION}</li>
4647
</ul>
4748
</li>
4849
</ul>

lib/generators/inertia/install/templates/svelte/InertiaExample.ts.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<script lang="ts">
2+
import { VERSION } from 'svelte/compiler'
3+
24
import railsSvg from '/assets/rails.svg'
35
import svelteSvg from '/assets/svelte.svg'
46
import inertiaSvg from '/assets/inertia.svg'
57
68
let { rails_version, rack_version, ruby_version, inertia_rails_version }:
79
{ rails_version: string, rack_version: string, ruby_version: string, inertia_rails_version: string } = $props()
8-
let svelte_version = Array.from(window.__svelte.v).join(".")
910
</script>
1011

1112
<svelte:head>
@@ -43,7 +44,7 @@
4344
<li>
4445
<ul>
4546
<li><strong>Inertia Rails version:</strong> {inertia_rails_version}</li>
46-
<li><strong>Svelte version:</strong> {svelte_version}</li>
47+
<li><strong>Svelte version:</strong> {VERSION}</li>
4748
</ul>
4849
</li>
4950
</ul>

lib/generators/inertia/install/templates/svelte/types/globals.d.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
import type { SharedProps } from '@/types'
22

3-
type windowSvelteType = {
4-
v: Set<string>;
5-
};
6-
7-
declare global {
8-
interface Window {
9-
__svelte: windowSvelteType;
10-
}
11-
}
123
declare module '@inertiajs/core' {
134
export interface InertiaConfig {
145
sharedPageProps: SharedProps

0 commit comments

Comments
 (0)