From d843955d7c92c84c3408b2d9846ae5b72fb669fc Mon Sep 17 00:00:00 2001 From: Ray Tien Date: Fri, 20 Feb 2026 11:06:10 +0800 Subject: [PATCH] perf(tailwind): optimize rendering pipeline with caching and algorithm improvements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Batch class collection and deduplicate before single addUtilities call (N compiler.build → 1) - Cache parsed CSS AST in setup-tailwind with clone-on-read to avoid redundant parsing - Walk rule.prelude instead of entire rule in extractRulesPerClass with early exit for non-matching rules - Add LRU eviction (max 50) to useSuspensedPromise to prevent unbounded memory growth --- .../src/__snapshots__/tailwind.spec.tsx.snap | 8 +++--- .../src/hooks/use-suspended-promise.ts | 11 ++++++++ packages/tailwind/src/tailwind.tsx | 14 +++++----- .../src/utils/css/extract-rules-per-class.ts | 27 ++++++++++--------- .../src/utils/tailwindcss/setup-tailwind.ts | 10 +++++-- 5 files changed, 46 insertions(+), 24 deletions(-) diff --git a/packages/tailwind/src/__snapshots__/tailwind.spec.tsx.snap b/packages/tailwind/src/__snapshots__/tailwind.spec.tsx.snap index c551ac5221..dc364b7123 100644 --- a/packages/tailwind/src/__snapshots__/tailwind.spec.tsx.snap +++ b/packages/tailwind/src/__snapshots__/tailwind.spec.tsx.snap @@ -5,10 +5,10 @@ exports[`Tailwind component > with non-inlinable styles > throws an error when u For the media queries to work properly on rendering, they need to be added into a