Skip to content

Commit 9c938be

Browse files
fix(cli): properly migrate svelte to v5 in the plugin example template (#13912)
* fix: update vite.config.ts to support Svelte 4 in example app * Migrate the code to svelte 5 instead * Add change file --------- Co-authored-by: Tony <[email protected]>
1 parent 5c81828 commit 9c938be

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri-cli": "patch:bug"
3+
"@tauri-apps/cli": "patch:bug"
4+
---
5+
6+
Properly migrate svelte to v5 in the plugin example template

crates/tauri-cli/templates/plugin/__example-api/tauri-app/jsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"compilerOptions": {
3-
"moduleResolution": "Node",
3+
"moduleResolution": "bundler",
44
"target": "ESNext",
55
"module": "ESNext",
66
/**
77
* svelte-preprocess cannot figure out whether you have
88
* a value or a type, so tell TypeScript to enforce using
99
* `import type` instead of `import` for Types.
1010
*/
11-
"importsNotUsedAsValues": "error",
11+
"verbatimModuleSyntax": true,
1212
"isolatedModules": true,
1313
"resolveJsonModule": true,
1414
/**

crates/tauri-cli/templates/plugin/__example-api/tauri-app/src/App.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import Greet from './lib/Greet.svelte'
33
import { ping } from 'tauri-plugin-{{ plugin_name }}-api'
44
5-
let response = ''
5+
let response = $state('')
66
77
function updateResponse(returnValue) {
88
response += `[${new Date().toLocaleTimeString()}] ` + (typeof returnValue === 'string' ? returnValue : JSON.stringify(returnValue)) + '<br>'
@@ -37,7 +37,7 @@
3737
</div>
3838

3939
<div>
40-
<button on:click="{_ping}">Ping</button>
40+
<button onclick="{_ping}">Ping</button>
4141
<div>{@html response}</div>
4242
</div>
4343

crates/tauri-cli/templates/plugin/__example-api/tauri-app/src/lib/Greet.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script>
22
import { invoke } from "@tauri-apps/api/core"
33
4-
let name = "";
5-
let greetMsg = ""
4+
let name = $state("");
5+
let greetMsg = $state("")
66
77
async function greet(){
88
// Learn more about Tauri commands at https://v2.tauri.app/develop/calling-rust/#commands
@@ -13,7 +13,7 @@
1313
<div>
1414
<div class="row">
1515
<input id="greet-input" placeholder="Enter a name..." bind:value={name} />
16-
<button on:click={greet}>
16+
<button onclick={greet}>
1717
Greet
1818
</button>
1919
</div>

crates/tauri-cli/templates/plugin/__example-api/tauri-app/src/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import "./style.css";
22
import App from "./App.svelte";
3+
import { mount } from 'svelte';
34

4-
const app = new App({
5+
const app = mount(App, {
56
target: document.getElementById("app"),
67
});
78

0 commit comments

Comments
 (0)