Merge branch 'main' into outro-transition-fix

pull/17186/head
Rich Harris 19 hours ago committed by GitHub
commit c9ef13cd8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
perf: don't use tracing overeager during dev

@ -53,6 +53,7 @@ export interface Analysis {
/** @deprecated use `runes` from `state.js` instead */
runes: boolean;
immutable: boolean;
/** True if `$inspect.trace` is used */
tracing: boolean;
comments: AST.JSComment[];

@ -57,10 +57,12 @@ function log_entry(signal, entry) {
if (dirty && signal.updated) {
for (const updated of signal.updated.values()) {
if (updated.error) {
// eslint-disable-next-line no-console
console.log(updated.error);
}
}
}
if (entry) {
for (var trace of entry.traces) {

@ -608,6 +608,8 @@ function flush_effects() {
var was_updating_effect = is_updating_effect;
is_flushing = true;
var source_stacks = DEV ? new Set() : null;
try {
var flush_count = 0;
set_is_updating_effect(true);
@ -633,22 +635,36 @@ function flush_effects() {
}
for (const update of updates.values()) {
if (update.error) {
// eslint-disable-next-line no-console
console.error(update.error);
}
}
}
infinite_loop_guard();
}
batch.process(queued_root_effects);
old_values.clear();
if (DEV) {
for (const source of batch.current.keys()) {
/** @type {Set<Source>} */ (source_stacks).add(source);
}
}
}
} finally {
is_flushing = false;
set_is_updating_effect(was_updating_effect);
last_scheduled_effect = null;
if (DEV) {
for (const source of /** @type {Set<Source>} */ (source_stacks)) {
source.updated = null;
}
}
}
}

@ -188,10 +188,17 @@ export function internal_set(source, value) {
if (DEV) {
if (tracing_mode_flag || active_effect !== null) {
source.updated ??= new Map();
// For performance reasons, when not using $inspect.trace, we only start collecting stack traces
// after the same source has been updated more than 5 times in the same flush cycle.
const count = (source.updated.get('')?.count ?? 0) + 1;
source.updated.set('', { error: /** @type {any} */ (null), count });
if (tracing_mode_flag || count > 5) {
const error = get_stack('updated at');
if (error !== null) {
source.updated ??= new Map();
let entry = source.updated.get(error.stack);
if (!entry) {
@ -202,6 +209,7 @@ export function internal_set(source, value) {
entry.count++;
}
}
}
if (active_effect !== null) {
source.set_during_effect = true;

@ -1,5 +1,8 @@
/** True if experimental.async=true */
export let async_mode_flag = false;
/** True if we're not certain that we only have Svelte 5 code in the compilation */
export let legacy_mode_flag = false;
/** True if $inspect.trace is used */
export let tracing_mode_flag = false;
export function enable_async_mode_flag() {

Loading…
Cancel
Save