You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/docs/02-runes/07-$inspect.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,3 +42,20 @@ A convenient way to find the origin of some change is to pass `console.trace` to
42
42
// @errors: 2304
43
43
$inspect(stuff).with(console.trace);
44
44
```
45
+
46
+
## $inspect.trace(...)
47
+
48
+
This rune, added in 5.14, causes the surrounding function to be _traced_ in development. Any time the function re-runs as part of an [effect]($effect) or a [derived]($derived), information will be printed to the console about which pieces of reactive state caused the effect to fire.
49
+
50
+
```svelte
51
+
<script>
52
+
import { doSomeWork } from './elsewhere';
53
+
54
+
$effect(() => {
55
+
+++$inspect.trace();+++
56
+
doSomeWork();
57
+
});
58
+
</script>
59
+
```
60
+
61
+
`$inspect.trace` takes an optional first argument which will be used as the label.
Copy file name to clipboardExpand all lines: documentation/docs/98-reference/.generated/compile-errors.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -442,6 +442,18 @@ Expected whitespace
442
442
Imports of `svelte/internal/*` are forbidden. It contains private runtime code which is subject to change without notice. If you're importing from `svelte/internal/*` to work around a limitation of Svelte, please open an issue at https://github.com/sveltejs/svelte and explain your use case
443
443
```
444
444
445
+
### inspect_trace_generator
446
+
447
+
```
448
+
`$inspect.trace(...)` cannot be used inside a generator function
449
+
```
450
+
451
+
### inspect_trace_invalid_placement
452
+
453
+
```
454
+
`$inspect.trace(...)` must be the first statement of a function body
Copy file name to clipboardExpand all lines: documentation/docs/99-legacy/30-legacy-svelte-component.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: <svelte:component>
3
3
---
4
4
5
-
In runes mode, `<MyComponent>` will re-render if the value of `MyComponent` changes.
5
+
In runes mode, `<MyComponent>` will re-render if the value of `MyComponent` changes. See the [Svelte 5 migration guide](/docs/svelte/v5-migration-guide#Breaking-changes-in-runes-mode-svelte:component-is-no-longer-necessary) for an example.
6
6
7
7
In legacy mode, it won't — we must use `<svelte:component>`, which destroys and recreates the component instance when the value of its `this` expression changes:
Copy file name to clipboardExpand all lines: packages/svelte/messages/compile-errors/script.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,6 +54,14 @@
54
54
55
55
> Imports of `svelte/internal/*` are forbidden. It contains private runtime code which is subject to change without notice. If you're importing from `svelte/internal/*` to work around a limitation of Svelte, please open an issue at https://github.com/sveltejs/svelte and explain your use case
56
56
57
+
## inspect_trace_generator
58
+
59
+
> `$inspect.trace(...)` cannot be used inside a generator function
60
+
61
+
## inspect_trace_invalid_placement
62
+
63
+
> `$inspect.trace(...)` must be the first statement of a function body
64
+
57
65
## invalid_arguments_usage
58
66
59
67
> The arguments keyword cannot be used within the template or at the top level of a component
Copy file name to clipboardExpand all lines: packages/svelte/src/compiler/errors.js
+18Lines changed: 18 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -206,6 +206,24 @@ export function import_svelte_internal_forbidden(node) {
206
206
e(node,"import_svelte_internal_forbidden",`Imports of \`svelte/internal/*\` are forbidden. It contains private runtime code which is subject to change without notice. If you're importing from \`svelte/internal/*\` to work around a limitation of Svelte, please open an issue at https://github.com/sveltejs/svelte and explain your use case\nhttps://svelte.dev/e/import_svelte_internal_forbidden`);
207
207
}
208
208
209
+
/**
210
+
* `$inspect.trace(...)` cannot be used inside a generator function
211
+
* @param {null | number | NodeLike} node
212
+
* @returns {never}
213
+
*/
214
+
exportfunctioninspect_trace_generator(node){
215
+
e(node,"inspect_trace_generator",`\`$inspect.trace(...)\` cannot be used inside a generator function\nhttps://svelte.dev/e/inspect_trace_generator`);
216
+
}
217
+
218
+
/**
219
+
* `$inspect.trace(...)` must be the first statement of a function body
e(node,"inspect_trace_invalid_placement",`\`$inspect.trace(...)\` must be the first statement of a function body\nhttps://svelte.dev/e/inspect_trace_invalid_placement`);
225
+
}
226
+
209
227
/**
210
228
* The arguments keyword cannot be used within the template or at the top level of a component
0 commit comments