Skip to content

Commit 7e4fa77

Browse files
authored
Updates for deno 2 and latest sveltekit (#2)
* Updates for deno 2 and latest sveltekit * Use deno 2 in workflow
1 parent 94b11e0 commit 7e4fa77

File tree

14 files changed

+282
-597
lines changed

14 files changed

+282
-597
lines changed

.github/workflows/deploy.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,15 @@ jobs:
1919
uses: actions/checkout@v4
2020

2121
- name: Install Deno
22-
uses: denoland/setup-deno@v1
22+
uses: denoland/setup-deno@v2
2323
with:
24-
deno-version: v1.x
25-
26-
- name: Install Node.js
27-
uses: actions/setup-node@v4
28-
with:
29-
node-version: lts/*
24+
deno-version: v2.x
3025

3126
- name: Install step
32-
run: "DENO_FUTURE=1 deno install"
27+
run: "deno install"
3328

3429
- name: Build step
35-
run: "DENO_FUTURE=1 deno task build"
30+
run: "deno task build"
3631

3732
- name: Upload to Deno Deploy
3833
uses: denoland/deployctl@v1

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## create project
44

55
```bash
6-
deno run -A npm:create-svelte@latest my-app
6+
deno run -A npm:sv@latest create my-app
77
cd my-app
88
deno add npm:@types/deno
99
```
@@ -33,19 +33,19 @@ Update `svelte.config.js`
3333
Install dependencies
3434

3535
```bash
36-
DENO_FUTURE=1 deno install
36+
deno install
3737
```
3838

3939
Run the dev server
4040

4141
```bash
42-
DENO_FUTURE=1 deno task dev
42+
deno task dev
4343
```
4444

4545
## build
4646

4747
```bash
48-
DENO_FUTURE=1 deno task build
48+
deno task build
4949
```
5050

5151
Run production server
@@ -62,15 +62,15 @@ Svelte will be automatically selected as the framework preset
6262

6363
Open advanced settings
6464

65-
- Set "Install Step" to `DENO_FUTURE=1 deno install`
66-
- Set "Build Step" to `DENO_FUTURE=1 deno task build`
65+
- Set "Install Step" to `deno install`
66+
- Set "Build Step" to `deno task build`
6767
- Set "Root directory" to `build`
6868
- Set "Entrypoint" to `mod.ts`
6969

7070
Alternatively, deploy from the command line:
7171

7272
```bash
73-
DENO_FUTURE=1 deno task build
73+
deno task build
7474
cd build
7575
deployctl deploy --project=<project-name> --entrypoint=mod.ts
7676
```

deno.lock

Lines changed: 176 additions & 497 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "deno-svelte",
33
"version": "0.0.1",
4+
"type": "module",
45
"scripts": {
56
"dev": "vite dev",
67
"build": "vite build",
@@ -9,16 +10,16 @@
910
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
1011
},
1112
"devDependencies": {
12-
"@fontsource/fira-mono": "^4.5.10",
13-
"@neoconfetti/svelte": "^1.0.0",
13+
"@fontsource/fira-mono": "^5.0.0",
14+
"@neoconfetti/svelte": "^2.0.0",
1415
"@sveltejs/kit": "^2.0.0",
15-
"@sveltejs/vite-plugin-svelte": "^3.0.0",
16-
"@types/deno": "^2.0.0",
17-
"svelte": "^5.0.0-next.1",
18-
"sveltekit-adapter-deno": "^0.12.1",
19-
"svelte-check": "^3.6.0",
16+
"@sveltejs/vite-plugin-svelte": "^4.0.0",
17+
"svelte": "^5.0.0",
18+
"svelte-check": "^4.0.0",
2019
"typescript": "^5.0.0",
2120
"vite": "^5.0.3"
2221
},
23-
"type": "module"
22+
"dependencies": {
23+
"sveltekit-adapter-deno": "^0.16.0"
24+
}
2425
}

src/app.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// See https://kit.svelte.dev/docs/types#app
1+
// See https://svelte.dev/docs/kit/types#app.d.ts
22
// for information about these interfaces
33
declare global {
44
namespace App {

src/routes/+layout.svelte

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
<script>
1+
<script lang="ts">
22
import Header from './Header.svelte';
33
import '../app.css';
4+
5+
let { children } = $props();
46
</script>
57

68
<div class="app">
79
<Header />
810

911
<main>
10-
<slot />
12+
{@render children()}
1113
</main>
1214

1315
<footer>
14-
<p>visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to learn SvelteKit</p>
16+
<p>
17+
visit <a href="https://svelte.dev/docs/kit">svelte.dev/docs/kit</a> to learn about SvelteKit
18+
</p>
1519
</footer>
1620
</div>
1721

src/routes/+page.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<script>
1+
<script lang="ts">
22
import Counter from './Counter.svelte';
33
import welcome from '$lib/images/svelte-welcome.webp';
4-
import welcome_fallback from '$lib/images/svelte-welcome.png';
4+
import welcomeFallback from '$lib/images/svelte-welcome.png';
55
</script>
66

77
<svelte:head>
@@ -14,7 +14,7 @@
1414
<span class="welcome">
1515
<picture>
1616
<source srcset={welcome} type="image/webp" />
17-
<img src={welcome_fallback} alt="Welcome" />
17+
<img src={welcomeFallback} alt="Welcome" />
1818
</picture>
1919
</span>
2020

src/routes/Counter.svelte

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
<script lang="ts">
22
import { spring } from 'svelte/motion';
33
4-
let count = 0;
4+
let count = $state(0);
55
6-
const displayed_count = spring();
7-
$: displayed_count.set(count);
8-
$: offset = modulo($displayed_count, 1);
6+
// svelte-ignore state_referenced_locally
7+
const displayedCount = spring(count);
8+
9+
$effect(() => {
10+
displayedCount.set(count);
11+
});
12+
let offset = $derived(modulo($displayedCount, 1));
913
1014
function modulo(n: number, m: number) {
1115
// handle negative numbers
@@ -14,20 +18,20 @@
1418
</script>
1519

1620
<div class="counter">
17-
<button on:click={() => (count -= 1)} aria-label="Decrease the counter by one">
21+
<button onclick={() => (count -= 1)} aria-label="Decrease the counter by one">
1822
<svg aria-hidden="true" viewBox="0 0 1 1">
1923
<path d="M0,0.5 L1,0.5" />
2024
</svg>
2125
</button>
2226

2327
<div class="counter-viewport">
2428
<div class="counter-digits" style="transform: translate(0, {100 * offset}%)">
25-
<strong class="hidden" aria-hidden="true">{Math.floor($displayed_count + 1)}</strong>
26-
<strong>{Math.floor($displayed_count)}</strong>
29+
<strong class="hidden" aria-hidden="true">{Math.floor($displayedCount + 1)}</strong>
30+
<strong>{Math.floor($displayedCount)}</strong>
2731
</div>
2832
</div>
2933

30-
<button on:click={() => (count += 1)} aria-label="Increase the counter by one">
34+
<button onclick={() => (count += 1)} aria-label="Increase the counter by one">
3135
<svg aria-hidden="true" viewBox="0 0 1 1">
3236
<path d="M0,0.5 L1,0.5 M0.5,0 L0.5,1" />
3337
</svg>

src/routes/Header.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
<script>
1+
<script lang="ts">
22
import { page } from '$app/stores';
33
import logo from '$lib/images/svelte-logo.svg';
44
import github from '$lib/images/github.svg';
55
</script>
66

77
<header>
88
<div class="corner">
9-
<a href="https://kit.svelte.dev">
9+
<a href="https://svelte.dev/docs/kit">
1010
<img src={logo} alt="SvelteKit" />
1111
</a>
1212
</div>

src/routes/about/+page.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
<h1>About this app</h1>
88

99
<p>
10-
This is a <a href="https://kit.svelte.dev">SvelteKit</a> app. You can make your own by typing the
11-
following into your command line and following the prompts:
10+
This is a <a href="https://svelte.dev/docs/kit">SvelteKit</a> app. You can make your own by typing
11+
the following into your command line and following the prompts:
1212
</p>
1313

14-
<pre>npm create svelte@latest</pre>
14+
<pre>npx sv create</pre>
1515

1616
<p>
1717
The page you're looking at is purely static HTML, with no client-side interactivity needed.

0 commit comments

Comments
 (0)