From a86be350b11387f121e92d832299f47f4cfab9ef Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 1 Oct 2026 23:35:22 +0300 Subject: [PATCH] perf(bundle): load the space-card GUI editor lazily to keep #744 under the initial View budget (#744) The floor-geometry key of #744 (+~143 B gzip) put the initial View graph at 301 097 B gzip, 31 B over the absolute 301 066 B wall in scripts/bundle-budget.mjs. The comment over that wall says the next growth is paid by moving code into lazy graphs, not by raising the budget. `src/space-card.ts` imported its Lovelace GUI config editor (`src/space-editor.ts`, the `houseplan-space-card-editor` element) statically, so every View paid for a form only the dashboard editor opens. `getConfigElement()` now imports it on demand, exactly as `houseplan-card.getConfigElement()` already does for `./editor`; Home Assistant awaits the returned promise. The editor's dependencies (lit, i18n, space-geometry) stay in the shared chunk, so the new `space-editor-*.js` chunk holds only the element itself (~1.1 KB gzip). Measured: initial View 301 097 -> 300 489 B gzip (-608 B), headroom to the 301 066 B budget 577 B. The beta ceiling (300 142 B, band 2 000 B above it, #699) and the budget are unchanged; lazy editor/onboarding graphs are not touched. Issue: #744 User-Visible: no Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_018qZfe7YS4rqEMKoVeS3GKd --- src/space-card.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/space-card.ts b/src/space-card.ts index 894bf09b..70323a0e 100644 --- a/src/space-card.ts +++ b/src/space-card.ts @@ -46,7 +46,6 @@ import { createGlowRuntimeState, disposeGlowRuntime, type GlowRuntimeHost, type GlowRuntimeState, } from './glow-scene'; -import './space-editor'; import { DECOR_ASSETS_API_VERSION, decorAssetIds, resolveDecorAssets, type DecorAsset, } from './decor-assets'; @@ -276,7 +275,10 @@ class HouseplanSpaceCard extends LitElement { this._connHooked = connection; } - public static getConfigElement() { + /** The Lovelace GUI editor is a lazy chunk, as for `houseplan-card` (#744): + * only the dashboard editor asks for it, never the first View frame. */ + public static async getConfigElement() { + await import('./space-editor'); return document.createElement('houseplan-space-card-editor'); }