Make createCompatConfig theme mappings safe to spread when a namespace returns a string - #20399
Make createCompatConfig theme mappings safe to spread when a namespace returns a string#20399ibnlanre wants to merge 1 commit into
createCompatConfig theme mappings safe to spread when a namespace returns a string#20399Conversation
…ace returns a string
Confidence Score: 5/5The PR appears safe to merge, with no actionable changed-code defects identified. The helper preserves existing object mappings, correctly converts string-valued namespaces into Reviews (1): Last reviewed commit: "Make `createCompatConfig` theme mappings..." | Re-trigger Greptile |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
WalkthroughThe change adds the exported 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
What's a situation/use case where you ran into this kind of issue? |
I ran into this while working on Jumi, a Tailwind CSS v4 animation plugin I maintain. I was resolving a project's theme through the compat layer so Jumi could read the animation values, and for certain themes the output just looked… wrong. A value that should come back as What made me think this could've gone unnoticed for a while is that it's completely silent. The config still resolves, so one would only notice when something (typically, a plugin) actually reads those theme values. I also had several cases of arbitrary class values returning as just |
When building the legacy config compat layer, namespace mappings like
fontSize→text,boxShadow→shadow,animation→animate, etc. spread the result oftheme(namespace, {})directly:Some of these namespaces can return a string (e.g.
theme('text', {})→'1rem'). Spreading a string produces char-indexed keys ({ '0': '1', '1': 'r', ... }) instead of a{ DEFAULT: ... }entry, silently corrupting the compat config output.This PR adds a small
spreadThemehelper that normalizes the return value before spreading:string→{ DEFAULT: value }{ ...value }{}and updates all namespace mappings to use it. Includes unit tests for the helper plus integration tests for the affected namespaces and the string-return regression cases.