Repository navigation
fix(build): keep the app's Babel config out of the PostCSS plugin's library pass - #7774
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Visual Regression40 of 486 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 20 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
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]
) <!-- 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.
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 withbabelrc: falsebut notconfigFile: false, so Babel also loads the app's rootbabel.config.js: in the documented setup,next/babelplus 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
babelrc: falseonly disables.babelrcfiles; Babel still loads a root config file unless toldconfigFile: false.Expected behavior and authority
No record governs the plugin's build cost.
spec:AST-080FR7 (current) governs its output, which stays byte-identical. The pass already opts out of the app's Babel configuration withbabelrc: false(since #1421);configFile: falseextends that to the root config file Babel also loads. #5464 shows the same leak failing a consumer's StyleX pass.Smallest restoration
configFile: false; it already passes its own parser options and plugins.Evidence
postcss.test.mjsruns the documented config from an app whosebabel.config.jsrecords each file it is applied to. On main it records the Astryx module; here only the app's.Scope
Testing
pnpm exec vitest run --project node packages/build: 6 files, 79 tests pass;postcss.test.mjsfails on main.pnpm -F @astryxdesign/core typecheck, Prettier,pnpm check:repo, changeset coverage: pass (ESLint ignorespackages/build/src).