From 60c0f9e27940001bdbb0126a291d2a9bebe5ba17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Sun, 22 Nov 2026 21:14:59 +0000 Subject: [PATCH] perf(producer): compile time stays linear on pages with thousands of clips or style rules (#8528) * perf(producer): compile time stays linear on pages with thousands of clips or style rules * perf(producer): each background rule's selector matches in bounded time, :has() included * fix(producer): a wrapper's escaped class selector still finds its background --- .../core/src/compiler/timingCompiler.test.ts | 36 +++++ packages/core/src/compiler/timingCompiler.ts | 80 ++++++------ .../src/services/htmlCompiler.test.ts | 65 +++++++++ .../producer/src/services/htmlCompiler.ts | 123 ++++++++++++++++-- 4 files changed, 256 insertions(+), 48 deletions(-) diff --git a/packages/core/src/compiler/timingCompiler.test.ts b/packages/core/src/compiler/timingCompiler.test.ts index 13f73fe0c8..e43aaad969 100644 --- a/packages/core/src/compiler/timingCompiler.test.ts +++ b/packages/core/src/compiler/timingCompiler.test.ts @@ -396,6 +396,16 @@ describe("compileTimingAttrs", () => { }); }); +// 5,000 clips: main rescanned the page once per clip, about a minute for this page. +const CLIPS = 5_000; +const manyClips = (attrs: string) => + Array.from( + { length: CLIPS }, + (_, i) => `