Repository navigation
build(css): a package stylesheet inlines the constants it reads from its provider - #8339
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
The automated review found no blocking issues: the provider-constant step and the shared StyleX resolution leave Core, Lab, Charts and Rich Text output byte-identical today, and the new graph case fails without the change and passes with it. The diff includes #8324, so landing #8324 first keeps this pull request to its build-css commit. One small fix: the comment above the provider-constants loop in scripts/build-css.mjs uses core's touch keys read as a media key as its example, which is the pattern the description says stays unsupported. A value read, such as layerViewportInset.gutterBlockStart, would make a clearer example.
[Automated review]
| // A constant read from a provider's module (lab reading core's touch keys as | ||
| // a media key) compiles to a placeholder that only the constant's own rule | ||
| // resolves, and a constant is inlined where it is read. So the constants of | ||
| // every provided module this package imports join its rules (they emit no | ||
| // CSS); the module's variables stay in the provider's stylesheet. |
There was a problem hiding this comment.
This example (core's touch keys read as a media key) is the case the description and the test comment at scripts/build-css.graph.test.mjs:130-131 say stays unsupported: an imported constant at-rule key compiles one priority step above the same literal key (.x8481of.x8481of:not(#\#) against .x1lpi7hw.x1lpi7hw). Consider a value read as the example, such as a layer gutter or a motion duration, and a note that at-rule keys stay literal.
…its provider A satellite stylesheet (lab, charts, rich text) leaves every core .stylex module to astryx.css. But a defineConsts value is not a variable any stylesheet declares: StyleX compiles a read to a placeholder that only the constant's own rule resolves, and inlines it where it is read. So a lab transition timed by a core motion constant compiled to `transition-duration:var(--x…)`, and build-css failed with "reads StyleX variables nothing declares". build-css now records which provider modules a package imports and adds their constant rules to its own (constant rules emit no CSS); their variable groups stay in the provider's stylesheet. At-rule keys stay literal: StyleX gives an imported constant key a different priority than the literal at-rule.
b5fa026 to
11982ef
Compare
There was a problem hiding this comment.
No blocking issues: the provider-constant step leaves astryx.css, lab.css, charts.css and richtext.css byte-identical today, and the new graph case fails without the change and passes with it. One small fix from the last round is still open: the comment above the provider-constants loop in scripts/build-css.mjs uses core's touch keys read as a media key as its example, which is the pattern the description and the test comment say stays unsupported, and which now compiles one priority step above the literal key instead of failing the build. Using a value read such as layerViewportInset.gutterBlockStart, plus a note that at-rule keys stay literal, would fix it.
[Automated review]
The example said lab reads core's touch keys as a media key, which is the pattern this change keeps unsupported (an imported constant key compiles to a different StyleX priority than the literal at-rule). It now names a constant read as a value, the case the graph test covers, and says at-rule keys stay literal.
There was a problem hiding this comment.
No blocking issues: a Lab, Charts or Rich Text style can now read a Core defineConsts value and get it inlined in its package stylesheet, every package stylesheet builds byte-identical today, and the new graph case fails without the change and passes with it. The comment fix from the last round is in. Nothing else is needed; at-rule keys staying literal is still a convention no check enforces, so satellite styles should keep spelling them out.
[Automated review]
Maintainer impact
A lab (or charts, or rich text) style that reads a core
defineConstsvalue fails the package CSS build:lab.css reads StyleX variables nothing declares: --xzatj5h. A satellite stylesheet leaves every core.stylexmodule that core's own components import toastryx.css. A constant, though, isn't a variable any stylesheet declares. StyleX compiles a read to a placeholder that only the constant's own rule resolves, and inlines it where it's read, so the placeholder stays inlab.css.Intended invariant
A package stylesheet resolves every constant it reads, whichever package defines it. Variable groups stay in the stylesheet of the package that owns them.
Change
scripts/build-css.mjs: the reachable-file walk records the provider modules a package imports. TheirdefineConstsrules (rules carryingconstKey/constVal) join the package's rule set. Constant rules emit no CSS.Evidence
layerViewportInset.gutterBlockStart(from@astryxdesign/core/Layer/layerViewportInset.stylex, a module core's layers import) failsbuild:csswith the error above.lab.csscarries the resolvedcalc(max(var(--spacing-4), env(safe-area-inset-top, 0px)) + …)with novar(--x…)left.astryx.cssand every package'sdistare unchanged onmain, since no package reads a provider constant there yet.Scope
Testing
scripts/build-css.graph.test.mjs, new case: a provider package with a constant and a variable group, and a satellite reading the constant as atransition-durationvalue.transition-duration:var(--x…)(fails).200ms, no undeclared variables, the provider's variable group absent.build:cssexits 1 without this change, 0 with it.var(--x…)left.