From 5161dbc757b6ef3c59f9420cef27321d74b9dab2 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 13 Sep 2025 16:37:44 +0200 Subject: [PATCH] bui-themer: remove unnecessary css cache Signed-off-by: Patrik Oldsberg --- .../BuiThemerPage/BuiThemerPage.tsx | 39 ++----------------- 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/plugins/bui-themer/src/components/BuiThemerPage/BuiThemerPage.tsx b/plugins/bui-themer/src/components/BuiThemerPage/BuiThemerPage.tsx index 4df3aae006..061ea379cd 100644 --- a/plugins/bui-themer/src/components/BuiThemerPage/BuiThemerPage.tsx +++ b/plugins/bui-themer/src/components/BuiThemerPage/BuiThemerPage.tsx @@ -28,13 +28,7 @@ import { Text, Switch, } from '@backstage/ui'; -import { - convertMuiToBuiTheme, - ConvertMuiToBuiThemeOptions, -} from './convertMuiToBuiTheme'; - -// Memoization cache for generated CSS -const cssCache = new Map(); +import { convertMuiToBuiTheme } from './convertMuiToBuiTheme'; interface ThemeContentProps { themeId: string; @@ -54,37 +48,10 @@ function ThemeContent({ const [includeThemeId, setIncludeThemeId] = useState(false); const css = useMemo(() => { - // Create cache key based on theme properties and options - const cacheKey = `${themeId}-${includeThemeId}-${JSON.stringify({ - palette: muiTheme.palette, - typography: muiTheme.typography, - spacing: muiTheme.spacing, - shape: muiTheme.shape, - })}`; - - // Check cache first - if (cssCache.has(cacheKey)) { - return cssCache.get(cacheKey)!; - } - - const options: ConvertMuiToBuiThemeOptions = { + return convertMuiToBuiTheme(muiTheme, { themeId, includeThemeId, - }; - const result = convertMuiToBuiTheme(muiTheme, options); - - // Cache the result - cssCache.set(cacheKey, result); - - // Clean up old cache entries (keep only last 50) - if (cssCache.size > 50) { - const firstKey = cssCache.keys().next().value; - if (firstKey) { - cssCache.delete(firstKey); - } - } - - return result; + }); }, [muiTheme, themeId, includeThemeId]); useEffect(() => {