Skip to content

Commit dc6e808

Browse files
dominikgbluwy
andauthored
fix(inspector): use runes and force runes mode (#1004)
* fix(inspector) use runes and force runes mode to avoid issues in client apps that set runes mode globally * Update .changeset/cold-hats-leave.md Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> * fix: disable prefer-const rule for svelte files as it does not handle deriveds well --------- Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
1 parent 52e4a4f commit dc6e808

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

.changeset/cold-hats-leave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/vite-plugin-svelte-inspector': patch
3+
---
4+
5+
fix(inspector): migrate client component to runes and force runes mode

eslint.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ export default [
116116
},
117117

118118
rules: {
119-
'n/no-missing-import': 'off' // n doesn't know some vite specifics or monorepo imports.
119+
'n/no-missing-import': 'off', // n doesn't know some vite specifics or monorepo imports.
120+
'prefer-const': 'off' // this turns let foo = $derived into a const otherwise
120121
}
121122
},
122123
{

packages/vite-plugin-svelte-inspector/src/runtime/Inspector.svelte

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<svelte:options runes={true} />
2+
13
<script>
24
// do not use TS here so that this component works in non-ts projects too
35
import { onMount } from 'svelte';
@@ -8,8 +10,8 @@
810
const nav_keys = Object.values(options.navKeys).map((k) => k?.toLowerCase());
911
const open_key = options.openKey?.toLowerCase();
1012
11-
let enabled = false;
12-
let has_opened = false;
13+
let enabled = $state(false);
14+
let has_opened = $state(false);
1315
1416
const icon = `data:image/svg+xml;base64,${btoa(
1517
`
@@ -24,17 +26,19 @@
2426
)}`;
2527
2628
// location of code in file
27-
let file_loc;
29+
let file_loc = $state();
2830
// cursor pos and width for file_loc overlay positioning
29-
let x, y, w;
31+
let x = $state(),
32+
y = $state(),
33+
w = $state();
3034
31-
let active_el;
35+
let active_el = $state();
3236
33-
let hold_start_ts;
37+
let hold_start_ts = $state();
3438
35-
$: show_toggle =
36-
// eslint-disable-next-line svelte/valid-compile
37-
options.showToggleButton === 'always' || (options.showToggleButton === 'active' && enabled);
39+
let show_toggle = $derived(
40+
options.showToggleButton === 'always' || (options.showToggleButton === 'active' && enabled)
41+
);
3842
3943
function mousemove(e) {
4044
x = e.x;

0 commit comments

Comments
 (0)