Skip to content

[babel-plugin] Sort compiler output by UTF-16 code units - #2066

Merged
mellyeliu merged 1 commit into
meta:mainfrom
hurrymaplelad:stylex-utf16-sort
Nov 24, 2026
Merged

mellyeliu merged 1 commit into
meta:mainfrom
hurrymaplelad:stylex-utf16-sort

Conversation

@hurrymaplelad

@hurrymaplelad hurrymaplelad commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What changed / motivation?

Replace locale-aware sorting with UTF-16 code-unit order in the JavaScript compiler. CSS assembly uses it for the legacy class name, declared property name, width-query context, declaration text, and full rule text. Pseudo/attribute conditions and theme override at-rule groups use it too, preserving pseudo-element boundaries and default-first behavior. Numeric priorities and breakpoint direction are unchanged.

Linked PR/Issues

Resolves #2065.

Additional context

Assembly can reorder CSS but does not compute class names. Reordered pseudo/attribute conditions and theme override groups can change hashes, compiled class names, metadata keys, and CSS selectors. Rebuild JS and CSS together; the output can invalidate caches. Order still matters if same-priority rules overlap in the cascade. The icu_collator comparisons in #2008's Rust pseudo and stylesheet paths are a follow-up.

Test plan: yarn build, yarn test:packages (2,288 passed), yarn prettier:report, yarn lint:report on Node 22, and Flow 0.314.0 on Ubuntu 24.04. The eight regression cases and expected hashes cover all seven sites, surrogate-pair ordering, reversed input, and both class hash paths. Seven fail against the base compiler; no existing snapshots changed.

Fork Actions have not run (approval required: tests, benchmarks). The Vercel preview requires authorization.

Pre-flight checklist

  • Read the contributing guidelines.
  • Reviewed the diff and tests.

@vercel

vercel Bot commented Nov 23, 2026

Copy link
Copy Markdown

@hurrymaplelad is attempting to deploy a commit to the Meta Open Source Team on Vercel.

A member of the Team first needs to authorize it.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 23, 2026
@hurrymaplelad
hurrymaplelad marked this pull request as ready for review November 23, 2026 23:00
@MarcelOlsen MarcelOlsen mentioned this pull request Nov 24, 2026
@mellyeliu
mellyeliu merged commit 31be027 into meta:main Nov 24, 2026
6 of 9 checks passed
mellyeliu added a commit that referenced this pull request Dec 3, 2026
Port #2066. Rule ordering, pseudo keys, at-rule keys and createTheme at-rules now compare UTF-16 code units instead of ICU collation, so the icu_collator dependency is gone.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch to UTF-16 sorts

2 participants