Skip to content

fix(build): keep the app's Babel config out of the PostCSS plugin's library pass - #7774

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:build-library-babel-config
Oct 21, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:build-library-babel-config

Conversation

@vjeux

@vjeux vjeux commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

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 fix(core): build Unicode property regexes at runtime #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

  • 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 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).

…ibrary pass

The PostCSS plugin compiled Astryx source with `babelrc: false` but not
`configFile: false`, so Babel also loaded the app's root babel.config.js
(in the documented setup, next/babel plus Astryx's StyleX plugin) and ran
it over every installed Astryx module just to read StyleX metadata. On the
documented example that roughly doubled the CSS pass for identical CSS.

The library pass now sets `configFile: false`; the app's own files still
compile with its config.
@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 11:41pm 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 21, 2026, 12:10 AM 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

No new or modified components detected.

Bundle Size Summary

No component packages changed.

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.

This looks ready: keeping the app's Babel config out of the PostCSS plugin's library pass leaves the documented Next.js setup's CSS byte-identical while roughly halving the pass, and the new test fails without the fix.

One optional follow-up: the changeset says the emitted CSS is unchanged, which holds when babel.config.js and the PostCSS plugin carry the same StyleX settings; an app that set libraryPrefix only in its Babel config (or through postcss(__dirname, {libraryPrefix}), which never reaches the plugin) will now get astryx-prefixed library rules, so a sentence pointing such apps at the PostCSS plugin's own libraryPrefix would help.

[Automated review]

@cixzhang
cixzhang merged commit 1c29a4b into meta:main Oct 21, 2026
50 checks passed
@vjeux
vjeux deleted the build-library-babel-config branch October 21, 2026 14:30
cixzhang added a commit that referenced this pull request Oct 21, 2026
)

<!-- template: maintenance.md -->

## Maintainer impact

`main` is red: `test-node` fails in `packages/build/src/postcss.test.mjs` ("compiles Astryx source without the app's Babel config"). Every pull request based on current `main`, and any release that gates on a green `main`, is blocked.

## Intended invariant

The test keeps proving what #7774 added: the PostCSS plugin's library pass compiles Astryx source without the app's Babel config, while the app's own files still get it. It should run against an Astryx package installed the way a real one is.

## Change

#7775 and #7774 each passed on their own but conflict once both are on `main`:

- #7775 makes the plugin scan what each installed `@astryxdesign/*` package publishes, read from that package's `package.json`; a directory without one is not treated as an Astryx package.
- #7774 added this test with a fixture that installs `node_modules/@astryxdesign/core/src/Box/Box.tsx` but no `package.json`.

So, on `main`, the fixture's Astryx module is compiled as app code (`@layer product`) and the assertion on `@layer astryx-base` fails. The fix gives the fixture's package a minimal manifest (`{"name": "@astryxdesign/core"}`, no `files`, so the whole package is scanned). Test-only; no plugin change.

## Evidence

- Failure before the change: on current `main`, `pnpm exec vitest run --project node packages/build/src/postcss.test.mjs` fails with `expected '@layer product {…' to match /@layer astryx-base \{[^]*color:\s*red/`, the same failure as `main`'s `test-node` job.
- Success after the change: the same file passes, and so does the whole `packages/build` suite.
- Product/runtime behavior verified unchanged: only the test fixture changes.

## Scope

- [x] No intended public API, product behavior, visual direction, or policy change.
- [x] Product changes discovered during the work were removed or split.
- [x] Public text and artifacts contain no internal Meta context.

## Testing

- `pnpm exec vitest run --project node packages/build`: 7 files, 85 tests pass (the target test fails without this change).
- Prettier and `pnpm check:changesets`: pass. No Changeset: test-only.

This branch was successfully deployed

1 active deployment
Preview — e321eb06 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