Skip to content

Commit 3470d4d

Browse files
committed
more tweaks
1 parent 0c8575f commit 3470d4d

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

packages/svelte/src/internal/client/dev/tracing.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,22 @@ export function trace(fn, label, computed) {
126126
var read_stack = ['read', get_stack()];
127127

128128
if (tracing_expression_reactive !== NOT_REACTIVE) {
129-
var write_stack;
129+
var set_stack;
130130
if (signals.size === 1) {
131-
write_stack = Array.from(signals)[0].stack;
131+
set_stack = Array.from(signals)[0].stack;
132+
}
133+
var sub = null;
134+
if (tracing_expressions.length !== 0) {
135+
sub = tracing_expressions.slice();
136+
tracing_expressions = [];
132137
}
133138
tracing_expressions.push({
134139
changed: tracing_expression_reactive === REACTIVE_CHANGED,
135140
label,
136141
value,
137142
time,
138-
stacks: write_stack ? [read_stack, write_stack] : [read_stack],
139-
sub: null
143+
stacks: set_stack ? [read_stack, set_stack] : [read_stack],
144+
sub
140145
});
141146

142147
if (previously_tracing_expressions !== null) {

packages/svelte/src/internal/client/reactivity/deriveds.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { equals, safe_equals } from './equality.js';
2424
import * as e from '../errors.js';
2525
import { destroy_effect } from './effects.js';
2626
import { inspect_effects, set_inspect_effects } from './sources.js';
27+
import { get_stack } from '../dev/tracing.js';
2728

2829
/**
2930
* @template V
@@ -56,6 +57,10 @@ export function derived(fn) {
5657
parent: active_effect
5758
};
5859

60+
if (DEV) {
61+
signal.stack = ['created', get_stack()];
62+
}
63+
5964
if (active_reaction !== null && (active_reaction.f & DERIVED) !== 0) {
6065
var derived = /** @type {Derived} */ (active_reaction);
6166
(derived.children ??= []).push(signal);

0 commit comments

Comments
 (0)