Skip to content

fix(core): build Unicode property regexes at runtime - #7767

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:core-runtime-property-regex
Oct 21, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:core-runtime-property-regex

Conversation

@vjeux

@vjeux vjeux commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

User impact

An app that builds Astryx from source with the documented Next.js setup, but sets no browserslist or targets a browser without Unicode property escapes (such as Safari 11), fails next build --webpack with Unknown property: L (also Zs, Letter). The errors point at Avatar.tsx, Markdown/parser.ts and Markdown/plugins/headingLinks.ts, package source the app cannot change, and come from both the PostCSS pass and the JavaScript compile. Any import from the package root reaches them.

Problem and solution fit

  • Why it fails: with no targets, or old ones, next/babel's preset-env rewrites every \p{…} regex literal with transform-unicode-property-regex. Next's bundled copy of that transform loads regenerate-unicode-properties at runtime, which Next does not ship, so it throws (Next 16.3.6 and 16.4.2 alike).
  • Why it harms the task: the throw stops the whole build.
  • Why that matters: the app cannot fix it in its own code, and the error names a Unicode property, not the missing target.

Expected behavior and authority

This is a regression of a settled case. #5450 hit this failure in NumberInput/numberParser.ts and builds those expressions with new RegExp(...); its comment records why, and notes that property escapes need no transform in any browser this package supports. #6698, #6911 and #7051 later added four new literals and reintroduced it.

Smallest restoration

  • The four literals become new RegExp(...) with the same pattern and flags, built once at module load as before.
  • Each site's comment names the cause and when a literal is safe again: once Next's bundled Babel ships the Unicode data.
  • A source-build test fails when a Core module writes a property escape as a regex literal.

Evidence

  • Reproduction before the change: a clean registry install of main's documented Next.js example (apps/example-nextjs-source, hoisted, browserslist removed). next build --webpack fails in the PostCSS pass (Avatar.tsx: Unknown property: L) and in the JavaScript compile (Unknown property: L, Zs, Letter from the three files).
  • Result after the change: the same install, with this change applied to Core's source, compiles and prerenders, and all 226 rendered class names have a rule in the emitted CSS.
  • Representative unchanged path: the Avatar and Markdown suites pass unchanged.
  • Regression test or other mutation-sensitive proof: unicodePropertyEscapes.source-build.test.mjs fails on main listing the four literals, and passes here.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm exec vitest run --project ui packages/core/src/Avatar packages/core/src/Markdown packages/core/src/unicodePropertyEscapes.source-build.test.mjs: 50 files, 1,158 tests pass (the new test alone fails on main).
  • next build --webpack on the clean install, no browserslist: fails on main in both passes; passes with this change (226 of 226 rendered classes have a rule).
  • pnpm -F @astryxdesign/core typecheck, ESLint and Prettier on the touched files, pnpm check:repo, changeset coverage: pass.

With no browserslist, or targets without Unicode property escapes,
next/babel's preset-env rewrites every `\p{…}` regex literal through the
transform bundled in Next.js, which lacks the Unicode data it loads, so a
source build of the documented Next.js setup failed with
"Unknown property: L" in Avatar, the Markdown parser and heading links.

Build those four expressions with `new RegExp(...)`, as numberParser.ts
already does, and add a source-build test that fails when a Core module
writes a property escape as a regex literal.
@vercel

vercel Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 20, 2026 10:33pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 20, 2026
@astracat-bot

astracat-bot Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 20, 2026, 10:54 PM UTC

@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Modified Components

Markdown (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 8628 -
Complexity N/A Very High (281) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.9KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

40 of 486 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 754,077
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,188
Chat Full AI Chat probe light 230,823
Chat Full AI Chat probe dark 229,805
RichTextEditor Markdown parity: side by side probe dark 94,866
RichTextEditor Markdown parity: side by side probe light 89,762
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
Chat Default neutral dark 36,304
Chat Default neutral light 35,767
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232
ProgressBar With Target Mark probe dark 7,895
ProgressBar With Target Mark probe light 7,895
Markdown Default neutral dark 7,573
Markdown Default neutral light 7,566

and 20 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommended for approval. The four Unicode property-escape expressions keep their exact source and flags, so initials, emphasis and heading IDs are unchanged, and compiling Core with Next 16.3.6's bundled Babel and no browserslist goes from three failing modules (Avatar.tsx, Markdown/parser.ts, Markdown/plugins/headingLinks.ts) to none. The new guard test fails on main at exactly those four literals and passes here, and the [fix] patch changeset is valid, so nothing further is needed from you.

[Automated review]

@cixzhang
cixzhang merged commit 5fb597d into meta:main Oct 21, 2026
50 checks passed
cixzhang pushed a commit that referenced this pull request Oct 21, 2026
…ibrary pass (#7774)

<!-- template: bug-fix.md -->

## User impact

Every documented Next.js source build pays for an unused Babel run over every installed Astryx module. `@astryxdesign/build`'s PostCSS plugin compiles Astryx source to collect its StyleX rules with `babelrc: false` but not `configFile: false`, so Babel also loads the app's root `babel.config.js`: in the documented setup, `next/babel` plus Astryx's StyleX plugin. The CSS pass then runs preset-env, Next's plugins and a second StyleX instance over package source, only to read StyleX metadata. On a clean install of the documented example that roughly doubles the pass, for byte-identical CSS.

## Problem and solution fit

- Why it happens: `babelrc: false` only disables `.babelrc` files; Babel still loads a root config file unless told `configFile: false`.
- Why it harms: the extra transforms produce nothing the pass uses, and they scale with the Astryx packages installed, not used.
- Why that matters: the app cannot keep its root config out of the plugin's pass without dropping it from its own compile.

## Expected behavior and authority

No record governs the plugin's build cost. `spec:AST-080` FR7 (current) governs its output, which stays byte-identical. The pass already opts out of the app's Babel configuration with `babelrc: false` (since #1421); `configFile: false` extends that to the root config file Babel also loads. #5464 shows the same leak failing a consumer's StyleX pass.

## Smallest restoration

- The library pass sets `configFile: false`; it already passes its own parser options and plugins.
- The app's own files still compile with its config, which may carry syntax plugins they need.

## Evidence

- Reproduction before the change: on a clean registry install of the documented example, the app's PostCSS config takes a median 37.4 s with the README's browserslist and 67.3 s with none (5 fresh-process runs each, alternating order; the no-browserslist case has #7767 applied, since main does not build without one).
- Result after the change: 20.3 s and 21.4 s, with byte-identical CSS across all 20 runs.
- Representative unchanged path: the app's own files still compile with its config, which the test asserts.
- Regression test or other mutation-sensitive proof: `postcss.test.mjs` runs the documented config from an app whose `babel.config.js` records each file it is applied to. On main it records the Astryx module; here only the app's.

## Scope

- [x] One defect is restored.
- [x] Separable contradictory or unsettled tagalongs were removed or split.
- [x] No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
- [x] Public text and artifacts contain no internal Meta context.

## Testing

- `pnpm exec vitest run --project node packages/build`: 6 files, 79 tests pass; `postcss.test.mjs` fails on main.
- CSS-pass runs, before and after: README browserslist 35.7/41.1/36.7/37.4/38.1 s and 19.9/24.8/20.3/20.0/22.8 s; none 67.3/75.8/67.8/65.9/52.9 s and 19.9/21.4/24.9/24.7/19.7 s.
- `pnpm -F @astryxdesign/core typecheck`, Prettier, `pnpm check:repo`, changeset coverage: pass (ESLint ignores `packages/build/src`).
@vjeux
vjeux deleted the core-runtime-property-regex branch October 21, 2026 14:31

This branch was successfully deployed

1 active deployment
Preview — f4a3d54f Deployed Oct 20, 2026 by vercel[bot]
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 Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants