[codemods] Convert static css props to StyleX (Emotion→StyleX, 2/6) - #1769
Open
ahmedsadid wants to merge 9 commits into
Open
[codemods] Convert static css props to StyleX (Emotion→StyleX, 2/6)#1769ahmedsadid wants to merge 9 commits into
ahmedsadid wants to merge 9 commits into
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…te proven to fail on a broken pair Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…-written IR Source-neutral: emit is fed hand-written IR (no Emotion) so the engine is provably library-agnostic. Emits alphabetically-sorted keys (satisfies stylex/sort-keys with zero autofixes) and refuses conditions/duplicates/ non-static values rather than mis-emitting. styleToObjectAst added to the rewriter wrapper is emit's AST-rendering bridge, keeping core/emit AST-free. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…orts, orchestrator
Reads static css={{...}} / css({...}) on host elements into neutral
declarations; rewrites each site to {...stylex.props(styles.key)}; inserts a
single per-file registry above the first converted component; cleans up the
@emotion/react import and @jsxImportSource pragma. Whole-file-or-nothing
(M1 policy): any blocker (pseudo/media, template literal, shorthand overlap,
component css prop, pre-existing stylex) skips the file untouched with reasons.
core/ never imported here — the seam holds.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
CSS treats 'rgb(10, 20, 30)' and 'rgb(10,20,30)' as identical and the StyleX compiler emits the latter; without this the gate flagged every rgb()/multi-arg value as a false diff. Comma-whitespace is now canonicalized on both sides. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…add 8 fixtures
The two M0-skipped checks (byte-exact match, per-fixture semantic-diff) now run
for real against transformEmotionFile. Skip-fixtures assert the transform
refused loudly and left the file byte-identical. New fixtures: css-call-form,
static-values, two-sites (convert) + skip-{pseudo,template-literal,
shorthand-conflict,component-css,existing-stylex} (refuse).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…red coverage Replaces the M0 throwing stub with a real StyleX-object -> IR reader (flat static values + fallback arrays). The harness now round-trips each covered corpus entry (read -> emit -> compile -> semantic-diff vs original, empty allowlist) and reports measured coverage; condition/keyframe entries remain typed, SAFE coverage gaps (2/5 covered at M1). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
@ahmedsadid is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
Open
2 tasks
ahmedsadid
force-pushed
the
codemod/emotion-m1-static
branch
from
July 23, 2026 23:47
91f1146 to
595e33e
Compare
ahmedsadid
marked this pull request as ready for review
July 24, 2026 00:35
ahmedsadid
force-pushed
the
codemod/emotion-m1-static
branch
from
July 25, 2026 02:34
595e33e to
9af4a55
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed / motivation ?
Part of adding a tool that migrates Emotion styles to StyleX (#1766). This PR
does its first real conversion: a static Emotion
cssprop becomes astylex.createblock plus astylex.props(...)reference.css={{ … }}andcss({ … }).file has anything it can't confidently handle yet —
:hover/media conditions,a value like
'8px 16px', a template literal,csson a custom component, ora file that already uses StyleX — it leaves the file unchanged and reports why.
(Converting just the safe parts of a mixed file comes in a later PR.)
src/core/) andEmotion-specific code that reads the styles and edits the JSX
(
src/adapters/emotion/). The general layer knows nothing about Emotion, so itcan be reused for other source libraries later.
Testing
render the same CSS as the Emotion original.
css(...)call form, two components in onefile) and refusals (pseudo-selectors, shorthand conflict, template literal,
custom component, file already using StyleX).
confirming it's self-contained.
Linked PR/Issues
Part of #1766 · builds on #1768
Additional Context
Stacked on #1768 (the package scaffold), but this change stands on its own to
review.
Pre-flight checklist