Skip to content

Commit 44f55ea

Browse files
Sync svelte docs (#1019)
sync svelte docs Co-authored-by: Rich-Harris <[email protected]>
1 parent 68718e3 commit 44f55ea

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

apps/svelte.dev/content/docs/svelte/02-runes/07-$inspect.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,20 @@ A convenient way to find the origin of some change is to pass `console.trace` to
4343
// @errors: 2304
4444
$inspect(stuff).with(console.trace);
4545
```
46+
47+
## $inspect.trace(...)
48+
49+
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.
50+
51+
```svelte
52+
<script>
53+
import { doSomeWork } from './elsewhere';
54+
55+
$effect(() => {
56+
+++$inspect.trace();+++
57+
doSomeWork();
58+
});
59+
</script>
60+
```
61+
62+
`$inspect.trace` takes an optional first argument which will be used as the label.

apps/svelte.dev/content/docs/svelte/98-reference/.generated/compile-errors.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,18 @@ Expected whitespace
442442
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
443443
```
444444

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
455+
```
456+
445457
### invalid_arguments_usage
446458

447459
```

apps/svelte.dev/content/docs/svelte/98-reference/30-compiler-errors.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,18 @@ Expected whitespace
447447
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
448448
```
449449

450+
### inspect_trace_generator
451+
452+
```
453+
`$inspect.trace(...)` cannot be used inside a generator function
454+
```
455+
456+
### inspect_trace_invalid_placement
457+
458+
```
459+
`$inspect.trace(...)` must be the first statement of a function body
460+
```
461+
450462
### invalid_arguments_usage
451463

452464
```

0 commit comments

Comments
 (0)