Skip to content

Commit 1628bfc

Browse files
perf(frontend): migrate cn to cnfast (#2527)
* perf(frontend): migrate cn to cnfast Swap the vendored `cn` (redpanda-ui/lib/utils.tsx) from `twMerge(clsx(...))` to cnfast — an optimized adaptation of clsx + tailwind-merge with byte-identical output and the same `(...inputs: ClassValue[])` signature. No call site changes. - json-view: switch its direct `import clsx from 'clsx'` to cnfast's `clsx` export so clsx can be dropped as a direct dependency - deps: drop clsx + tailwind-merge, add cnfast (class-variance-authority unchanged) - bunfig: temporarily exclude cnfast from the 72h release-age gate (0.0.8 published 2026-06-22; remove the exclude once it ages past the gate) - vendored redpanda-ui/lib/utils.tsx marked [upstream]; mirrors ui-registry #220 and reconciles on the next registry sync Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * build(frontend): pin cnfast to exact 0.0.8 Address PR review: drop the caret so the intent is explicit. `^0.0.8` already resolves to only 0.0.8 under semver (caret locks the patch on 0.0.x), so this is a no-op in resolution — just clearer for a pre-1.0 dependency. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 22b4352 commit 1628bfc

6 files changed

Lines changed: 202 additions & 88 deletions

File tree

frontend/bun.lock

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/bunfig.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
[install]
22
minimumReleaseAge = 259200 # 72h supply-chain publish delay
3+
# Temporary: cnfast@0.0.8 (the `cn` migration) was published 2026-06-22, below
4+
# the 72h gate; remove from this list once it ages past the gate (~2026-06-25).
5+
minimumReleaseAgeExcludes = ["cnfast"]
36
save = true
47
saveTextLockfile = true
58
print = "yarn"

frontend/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@
9797
"ai": "^6.0.168",
9898
"array-move": "^4.0.0",
9999
"class-variance-authority": "^0.7.1",
100-
"clsx": "^2.1.1",
101100
"cmdk": "^1.1.1",
101+
"cnfast": "0.0.8",
102102
"date-fns": "^4.3.0",
103103
"dexie": "^4.2.1",
104104
"dotenv": "^17.2.3",
@@ -138,7 +138,6 @@
138138
"sql-formatter": "^15.8.1",
139139
"stacktrace-js": "^2.0.2",
140140
"streamdown": "^2.5.0",
141-
"tailwind-merge": "^3.5.0",
142141
"tailwindcss": "^4.2.4",
143142
"tokenlens": "^1.3.1",
144143
"use-stick-to-bottom": "^1.1.1",

frontend/src/components/redpanda-ui/lib/utils.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { cva } from 'class-variance-authority';
2-
import { type ClassValue, clsx } from 'clsx';
2+
import { type ClassValue, cn as cnfast } from 'cnfast';
33
import React from 'react';
4-
import { twMerge } from 'tailwind-merge';
54

5+
/**
6+
* [upstream] `cn` migrated to cnfast ahead of ui-registry PR #220 (byte-identical
7+
* output, same `(...inputs: ClassValue[])` signature). Drop this marker on the
8+
* next registry sync once #220 is released.
9+
*/
610
export function cn(...inputs: ClassValue[]) {
7-
return twMerge(clsx(inputs));
11+
return cnfast(...inputs);
812
}
913

1014
export function wrapStringChild(

frontend/src/components/ui/json/json-view.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** biome-ignore-all lint/suspicious/noArrayIndexKey: part of JSONNode implementation */
22
/** biome-ignore-all lint/a11y/useKeyWithClickEvents: part of JSONNode implementation */
3-
import clsx from 'clsx';
3+
import { clsx } from 'cnfast';
44
import { CopyButton } from 'components/redpanda-ui/components/copy-button';
55
import { memo, useMemo, useState } from 'react';
66

0 commit comments

Comments
 (0)