From b31163ddf47a7015d925cbaf56e670792c6797d0 Mon Sep 17 00:00:00 2001 From: Canmi Date: Tue, 31 Mar 2026 21:41:11 +0800 Subject: [PATCH] fix(router-core): trim whitespace from SSR dehydrated script output --- packages/router-core/src/ssr/ssr-server.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/router-core/src/ssr/ssr-server.ts b/packages/router-core/src/ssr/ssr-server.ts index 3fdd8b24bc8..7b90f5518a7 100644 --- a/packages/router-core/src/ssr/ssr-server.ts +++ b/packages/router-core/src/ssr/ssr-server.ts @@ -74,13 +74,13 @@ class ScriptBuffer { constructor(router: AnyRouter) { this.router = router - // Copy INITIAL_SCRIPTS to avoid mutating the shared array - this._queue = INITIAL_SCRIPTS.slice() + // Copy INITIAL_SCRIPTS and trim to avoid unnecessary whitespace in HTML output + this._queue = INITIAL_SCRIPTS.map((s) => s.trim()) } enqueue(script: string) { if (this._cleanedUp) return - this._queue.push(script) + this._queue.push(script.trim()) // If barrier is lifted, schedule injection (if not already scheduled) if (this._scriptBarrierLifted && !this._pendingMicrotask) { this._pendingMicrotask = true