Commit 2c345bd
committed
refactor(emcn): use tailwind-merge v3 instead of the cn package
The cn swap did not earn its keep. Benchmarked on this repo's own 4,673 class
strings, with both libraries' caches warm — which is what a re-rendering UI is
almost always in — cn is 4.2x faster per call (4.7ns vs 19.5ns). On a heavy
5,000-call render that is a 0.074ms saving: below anything perceivable, and far
below React's own reconciliation. The 13.7x cold-path win only applies to
strings neither cache has seen.
Against that it cost 2.1 KB gzip over tailwind-merge v3, paid on every cold
load on the critical path to first paint. cn trades gzip-compressibility for
parse speed: its tables are pre-encoded data that gzip cannot squeeze, where
tailwind-merge's config is repetitive JS that it can.
Reverting also drops a dependency published eight days ago onto a recycled npm
name, and lets the 7-day supply-chain gate go back on for the whole tree.
Keeps everything the migration was actually worth: Tailwind v4, and a single
class-name path now that apps/sim's direct clsx imports are gone. The 23 golden
cases pass unchanged against tailwind-merge, so the merge semantics are
identical; the built stylesheet is byte-for-byte the same.1 parent 18bcb2b commit 2c345bd
12 files changed
Lines changed: 30 additions & 253 deletions
File tree
- apps
- docs/app
- sim/app/_styles
- packages/emcn
- src/lib
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | 8 | | |
16 | 9 | | |
17 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | 26 | | |
35 | 27 | | |
36 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | 10 | | |
22 | 11 | | |
23 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
62 | 61 | | |
63 | 62 | | |
64 | 63 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
| |||
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
40 | | - | |
| 39 | + | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
0 commit comments