Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(build): fail closed on missing StyleX output (#6693)

Cindy Zhangca8f5292b8d1
diff --git a/.changeset/stylex-build-integrity.md b/.changeset/stylex-build-integrity.md
new file mode 100644
index 0000000000..fe182aa855
--- /dev/null
+++ b/.changeset/stylex-build-integrity.md
@@ -0,0 +1,9 @@
+---
+'@astryxdesign/build': patch
+---
+
+[fix] Make source builds fail on unsupported StyleX declarations and load shared StyleX output from every Vite HTML entry.
+
+Nested pseudo-elements and `stylex.keyframes()` now have production-build regression coverage, and the maintained capability registry tracks the installed StyleX version.
+
+@cixzhang
diff --git a/AGENTS.md b/AGENTS.md
index 07f94e56d2..3c04f5add7 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -165,7 +165,7 @@ Documentation lives in two places:
<!-- STYLEX-CAPS:START -->
-[StyleX v0.17.5 CSS Support]|Use CSS-native solutions. Don't build JS workarounds for supported features.
+[StyleX v0.19.0 CSS Support]|Use CSS-native solutions. Don't build JS workarounds for supported features.
|AT-RULES: @media, @supports, @container (+named), @starting-style, @scope — YES
|AT-RULES: @layer, @property (explicit) — NO (compiles but invalid CSS output)
|PSEUDO-CLS: :hover, :focus, :focus-visible, :focus-within, :active, :disabled — YES
@@ -174,10 +174,11 @@ Documentation lives in two places:
|PSEUDO-EL: ::before, ::after, ::placeholder, ::selection, ::backdrop, ::marker, ::view-transition-_ — YES
|COMPOUND: ::backdrop+condition, RTL :is([dir="rtl"] _), nested @media+pseudo — YES
|VALUES: var(), calc(), clamp(), light-dark(), color-mix(), container-type/name — YES
-|ANIM: transition (shorthand+individual), transitionBehavior:allow-discrete, animation, stylex.keyframes — YES
+|ANIM: transition (shorthand+individual), transitionBehavior:allow-discrete, animation longhands, stylex.keyframes — YES
+|ANIM: animation shorthand — NO (use animationName/duration/timingFunction/etc.)
|WHEN: stylex.when.ancestor(':hover'/':focus-within'/':active'/':disabled') — YES
|WHEN: stylex.when.descendant(':hover'), siblingBefore(':checked'), siblingAfter(':checked'), anySibling(':hover') — YES
-|WHEN: stylex.when.ancestor('[data-attr]') — NO (pseudo selectors only, must start with ":")
+|WHEN: stylex.when.ancestor('[data-attr]') — YES
|NESTING: CSS nesting with & — NO (use stylex.when.ancestor/descendant/sibling for parent-child state)
|API: stylex.firstThatWorks() for CSS fallbacks (e.g. display: grid with flex fallback) — YES
|API: stylex.positionTry() for anchor positioning @position-try — YES
diff --git a/apps/sandbox/src/app/(sandbox)/pages/doc-preview/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/doc-preview/page.tsx
index ecc10f700a..5b79d8676a 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/doc-preview/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/doc-preview/page.tsx
@@ -25,7 +25,9 @@ const styles = stylex.create({
top: 0,
zIndex: 10,
backgroundColor: 'var(--color-background-body)',
- borderBottom: '1px solid var(--color-border)',
+ borderBottomWidth: '1px',
+ borderBottomStyle: 'solid',
+ borderBottomColor: 'var(--color-border)',
padding: '12px 32px',
},
loading: {
diff --git a/apps/sandbox/src/app/(sandbox)/pages/doc-preview/token-tables/ColorTokenTable.tsx b/apps/sandbox/src/app/(sandbox)/pages/doc-preview/token-tables/ColorTokenTable.tsx
index 853efdd197..0fc5c3d2cc 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/doc-preview/token-tables/ColorTokenTable.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/doc-preview/token-tables/ColorTokenTable.tsx
@@ -15,7 +15,9 @@ const styles = stylex.create({
height: 28,
borderRadius: 'var(--radius-element)',
flexShrink: 0,
- border: '1px solid var(--color-border)',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: 'var(--color-border)',
},
contextLight: {
width: 28,
@@ -26,7 +28,9 @@ const styles = stylex.create({
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
- border: '1px solid var(--color-border)',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: 'var(--color-border)',
},
contextDark: {
width: 28,
@@ -37,7 +41,9 @@ const styles = stylex.create({
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
- border: '1px solid var(--color-border)',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: 'var(--color-border)',
},
swatchInner: {
width: 20,
diff --git a/apps/sandbox/src/app/(sandbox)/pages/doc-preview/token-tables/ShapeTokenTable.tsx b/apps/sandbox/src/app/(sandbox)/pages/doc-preview/token-tables/ShapeTokenTable.tsx
index b93f646766..50e4458031 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/doc-preview/token-tables/ShapeTokenTable.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/doc-preview/token-tables/ShapeTokenTable.tsx
@@ -14,7 +14,9 @@ const styles = stylex.create({
width: 96,
height: 96,
backgroundColor: 'var(--color-accent-muted)',
- border: '2px solid var(--color-accent)',
+ borderWidth: '2px',
+ borderStyle: 'solid',
+ borderColor: 'var(--color-accent)',
flexShrink: 0,
},
borderLine: {
diff --git a/apps/sandbox/src/app/(sandbox)/pages/layout-dsl/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/layout-dsl/page.tsx
index a9cc54883d..6be8931849 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/layout-dsl/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/layout-dsl/page.tsx
@@ -194,7 +194,8 @@ const s = stylex.create({
textAlign: 'start',
paddingBlock: 'var(--spacing-1)',
paddingInline: 'var(--spacing-2)',
- border: 'none',
+ borderWidth: 0,
+ borderStyle: 'none',
backgroundColor: {
default: 'transparent',
':hover': 'var(--color-background-hover, var(--color-background-muted))',
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/LabDemos.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/LabDemos.tsx
index b678800252..8738bab87e 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/LabDemos.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/LabDemos.tsx
@@ -56,10 +56,11 @@ const sx = stylex.create({
display: 'flex',
gap: '2px',
position: 'relative',
- borderBlockEnd: '1px solid var(--color-border)',
+ borderBlockEndWidth: '1px',
+ borderBlockEndStyle: 'solid',
+ borderBlockEndColor: 'var(--color-border)',
},
tab: {
- all: 'unset',
boxSizing: 'border-box',
cursor: 'pointer',
padding: '7px 13px',
@@ -104,7 +105,9 @@ const sx = stylex.create({
flexShrink: 0,
},
frame: {
- border: '1px solid var(--color-border)',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: 'var(--color-border)',
borderRadius: 'var(--radius-md, 9px)',
overflow: 'hidden',
height: '190px',
@@ -117,7 +120,9 @@ const sx = stylex.create({
width: '20px',
height: '20px',
borderRadius: 'var(--radius-sm, 5px)',
- border: '1.5px solid var(--color-border)',
+ borderWidth: '1.5px',
+ borderStyle: 'solid',
+ borderColor: 'var(--color-border)',
display: 'grid',
placeItems: 'center',
cursor: 'pointer',
@@ -138,7 +143,9 @@ const sx = stylex.create({
width: '26px',
height: '26px',
borderRadius: '50%',
- border: '2px solid var(--color-background-surface)',
+ borderWidth: '2px',
+ borderStyle: 'solid',
+ borderColor: 'var(--color-background-surface)',
marginInlineStart: '-7px',
backgroundColor: 'var(--color-brand)',
},
@@ -148,7 +155,9 @@ const sx = stylex.create({
gap: '8px',
padding: '6px 10px',
borderRadius: 'var(--radius-sm, 7px)',
- border: '1px solid var(--color-border)',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: 'var(--color-border)',
backgroundColor: 'var(--color-background-surface)',
},
swatch: {
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/LabPrimitives.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/LabPrimitives.tsx
index acc78ea4e8..343c558967 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/LabPrimitives.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/LabPrimitives.tsx
@@ -66,7 +66,9 @@ const sx = stylex.create({
padding: '14px',
},
splitBorder: {
- borderInlineStart: '1px solid var(--color-border)',
+ borderInlineStartWidth: '1px',
+ borderInlineStartStyle: 'solid',
+ borderInlineStartColor: 'var(--color-border)',
},
meterTrack: {
height: '5px',
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/MotionControlRail.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/MotionControlRail.tsx
index 08b1f76ba8..c633dcfb0b 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/MotionControlRail.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/MotionControlRail.tsx
@@ -42,7 +42,9 @@ const sx = stylex.create({
width: '100%',
boxSizing: 'border-box',
padding: '8px 16px',
- borderBlockEnd: '1px solid var(--color-border)',
+ borderBlockEndWidth: '1px',
+ borderBlockEndStyle: 'solid',
+ borderBlockEndColor: 'var(--color-border)',
backgroundColor: 'var(--color-background-surface)',
},
speed: {width: '132px'},
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/exit-gap/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/exit-gap/page.tsx
index 5c808b3822..fb55dc4c07 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/exit-gap/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/exit-gap/page.tsx
@@ -38,7 +38,9 @@ import {CORRECTED_EXIT_RULE, GUIDANCE_CONFLICTS} from '../publishedGuidance';
const sx = stylex.create({
full: {width: '100%'},
quote: {
- borderInlineStart: '2px solid var(--color-border)',
+ borderInlineStartWidth: '2px',
+ borderInlineStartStyle: 'solid',
+ borderInlineStartColor: 'var(--color-border)',
paddingInlineStart: '12px',
maxWidth: '62ch',
},
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/published/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/published/page.tsx
index e937ba585f..221450217f 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/published/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/published/page.tsx
@@ -46,7 +46,9 @@ import {
const sx = stylex.create({
quote: {
- borderInlineStart: '2px solid var(--color-border)',
+ borderInlineStartWidth: '2px',
+ borderInlineStartStyle: 'solid',
+ borderInlineStartColor: 'var(--color-border)',
paddingInlineStart: '12px',
maxWidth: '62ch',
},
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/reduced-motion/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/reduced-motion/page.tsx
index 87adceca9f..321ce0a5a4 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/reduced-motion/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/reduced-motion/page.tsx
@@ -46,7 +46,9 @@ const sx = stylex.create({
full: {width: '100%'},
mono: {fontFamily: 'var(--font-family-code)', fontSize: '12px'},
quote: {
- borderInlineStart: '2px solid var(--color-border)',
+ borderInlineStartWidth: '2px',
+ borderInlineStartStyle: 'solid',
+ borderInlineStartColor: 'var(--color-border)',
paddingInlineStart: '12px',
maxWidth: '64ch',
},
diff --git a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/rubric/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/rubric/page.tsx
index 29908e2f8c..054d66a862 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/motion-lab/rubric/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/motion-lab/rubric/page.tsx
@@ -80,13 +80,17 @@ const sx = stylex.create({
full: {width: '100%'},
mono: {fontFamily: 'var(--font-family-code)', fontSize: '12px'},
verdict: {
- borderInlineStart: '2px solid var(--color-border)',
+ borderInlineStartWidth: '2px',
+ borderInlineStartStyle: 'solid',
+ borderInlineStartColor: 'var(--color-border)',
paddingInlineStart: '10px',
},
pass: {borderInlineStartColor: 'var(--color-background-success, #3f9a6b)'},
fail: {borderInlineStartColor: 'var(--color-background-error, #d3543f)'},
quote: {
- borderInlineStart: '2px solid var(--color-border)',
+ borderInlineStartWidth: '2px',
+ borderInlineStartStyle: 'solid',
+ borderInlineStartColor: 'var(--color-border)',
paddingInlineStart: '12px',
maxWidth: '64ch',
},
diff --git a/apps/sandbox/src/app/(sandbox)/pages/navigation/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/navigation/page.tsx
index 7c706ea5d6..eebd9b8393 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/navigation/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/navigation/page.tsx
@@ -16,7 +16,9 @@ const styles = stylex.create({
maxWidth: 960,
},
navWrapper: {
- border: '1px solid #e0e0e0',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: '#e0e0e0',
borderRadius: 8,
overflow: 'hidden',
},
diff --git a/apps/sandbox/src/app/(sandbox)/pages/polymorphic-link/page.tsx b/apps/sandbox/src/app/(sandbox)/pages/polymorphic-link/page.tsx
index 62e9adba1b..935bf4e218 100644
--- a/apps/sandbox/src/app/(sandbox)/pages/polymorphic-link/page.tsx
+++ b/apps/sandbox/src/app/(sandbox)/pages/polymorphic-link/page.tsx
@@ -28,7 +28,9 @@ const styles = stylex.create({
maxWidth: 960,
},
navWrapper: {
- border: '1px solid #e0e0e0',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: '#e0e0e0',
borderRadius: 8,
overflow: 'hidden',
},
@@ -48,7 +50,9 @@ const styles = stylex.create({
},
sidenavWrapper: {
width: 240,
- border: '1px solid #e0e0e0',
+ borderWidth: '1px',
+ borderStyle: 'solid',
+ borderColor: '#e0e0e0',
borderRadius: 8,
overflow: 'hidden',
},
@@ -173,9 +177,7 @@ export default function PolymorphicLinkPage() {
</Text>
<Breadcrumbs label="Provider breadcrumbs">
<BreadcrumbItem href="/">Home</BreadcrumbItem>
- <BreadcrumbItem href="/products">
- Products
- </BreadcrumbItem>
+ <BreadcrumbItem href="/products">Products</BreadcrumbItem>
<BreadcrumbItem isCurrent>Widget</BreadcrumbItem>
</Breadcrumbs>
</VStack>
@@ -215,9 +217,7 @@ export default function PolymorphicLinkPage() {
<Text type="supporting" weight="bold">
Link
</Text>
- <Link href="/docs">
- Go to documentation
- </Link>
+ <Link href="/docs">Go to documentation</Link>
</VStack>
</VStack>
</LinkProvider>
diff --git a/internal/stylex-capabilities/CAPABILITIES.md b/internal/stylex-capabilities/CAPABILITIES.md
index 39f7a39046..dc39e8cb8e 100644
--- a/internal/stylex-capabilities/CAPABILITIES.md
+++ b/internal/stylex-capabilities/CAPABILITIES.md
@@ -1,10 +1,10 @@
# StyleX CSS Capability Reference
> Auto-generated by `internal/stylex-capabilities/scan.mjs`
-> StyleX version: **0.17.5**
-> Generated: 2026-03-17
+> StyleX version: **0.19.0**
+> Generated: 2026-09-28
-**82/92** features supported
+**88/92** features supported
## At-Rules
@@ -89,19 +89,18 @@
| Feature | Status | CSS Output |
| ------------------------------------------------------- | ------ | ---------------------------------------------- |
| Pseudo-class on pseudo-element (::backdrop + condition) | ✅ | `ltr: ".xph5o2a::backdrop{opacity:0}", |
-| ltr: ".x1pgog5j.x1pgog5j::backdrop:where([` |
-| RTL context (:is([dir="rtl"] \*)) | ✅ | `ltr: ".x5i6ehr{transform:translateX(-100%)}", |
-| ltr: ".xttggg:is([dir=\"rtl\"] \*){` |
+| ltr: ".x1pgog5j.x1pgog5j:where([data-open]` |
+| RTL context (:is([dir="rtl"] *)) | ✅ | `ltr: ".x5i6ehr{transform:translateX(-100%)}", |
+| ltr: ".xttggg:is([dir=\"rtl\"] *){` |
| Nested @media + pseudo | ✅ | `ltr: ".x1e2nbdu{color:red}", |
-
-ltr: ".x17z2mba:hover{color:blue}",
-ltr: "@media (h` |
+| ltr: ".x17z2mba:hover{color:blue}", |
+| ltr: "@media (h` |
## CSS Values
| Feature | Status | CSS Output |
| --------------------------------- | ------ | ---------------------------------------------------------- |
-| CSS variables (custom properties) | ✅ | `ltr: ".x14qql8p{color:var(--color-accent)}",` |
+| CSS variables (custom properties) | ✅ | `ltr: ".xqwr325{color:var(--color-accent)}",` |
| calc() | ✅ | `ltr: ".xkxa9zd{width:calc(100% - 32px)}",` |
| clamp() | ✅ | `ltr: ".xdq3cbq{font-size:clamp(14px,2vw,18px)}",` |
| light-dark() | ✅ | `ltr: ".xarbrzd{color:light-dark(black,white)}",` |
@@ -117,58 +116,61 @@ ltr: "@media (h` |
| transition (individual properties) | ✅ | `ltr: ".x19991ni{transition-property:opacity}", |
| ltr: ".x1d8287x{transition-durati` |
| transitionBehavior: allow-discrete | ✅ | `ltr: ".xd00j3c{transition-behavior:allow-discrete}",` |
-| animation (shorthand) | ✅ | (processed) |
+| animation (shorthand) | ❌ | <repo>/test.tsx: animation is not supported |
| stylex.keyframes | ✅ | `ltr: "@keyframes x1wc8ddo-B{from{transform:rotate(0deg);}to{transform:rotate(360` |
## Dynamic Styles
-| Feature | Status | CSS Output |
-| ------------------------------------------- | ------ | --------------------------------------- |
-| Dynamic values (function in stylex.create) | ✅ | `ltr: ".x5lhr3w{width:var(--x-width)}", |
-| ltr: "@property --x-width { syntax: \"\*\"` |
+| Feature | Status | CSS Output |
+| ------------------------------------------ | ------ | --------------------------------------- |
+| Dynamic values (function in stylex.create) | ✅ | `ltr: ".x5lhr3w{width:var(--x-width)}", |
+| ltr: "@property --x-width { syntax: \"*\"` |
## Variables
-| Feature | Status | CSS Output |
-| ------------------ | ------ | ------------------------------------------------------------ |
-| stylex.defineVars | ❌ | /vercel/sandbox/repos/xds-worktrees/stylex-caps/test.tsx: Un |
-| stylex.createTheme | ❌ | /vercel/sandbox/repos/xds-worktrees/stylex-caps/test.tsx: Un |
+| Feature | Status | CSS Output |
+| -------------------------------------- | ------ | ------------------------------------------------------------- |
+| stylex.defineVars | ✅ | `ltr: ":root, .x1cptbry{--x15ffsfu:blue;--x1gusifi:green;}",` |
+| stylex.createTheme | ✅ | `ltr: ":root, .x1cptbry{--x15ffsfu:blue;}", |
+| ltr: ".x1il70uh, .x1il70uh:root{--x15` |
## Ancestor/Sibling Selectors
-| Feature | Status | CSS Output |
-| ---------------------------------------------------- | ------ | ------------------------------------------------------------ |
-| stylex.when.ancestor(:hover) | ✅ | `ltr: ".x1e2nbdu{color:red}", |
+| Feature | Status | CSS Output |
+| ---------------------------------------------------- | ------ | ------------------------------------ |
+| stylex.when.ancestor(:hover) | ✅ | `ltr: ".x1e2nbdu{color:red}", |
| ltr: ".xobp4yc.xobp4yc:where(.x-default-marker:hove` |
-| stylex.when.ancestor(:hover) + @media | ✅ | `ltr: ".x1e2nbdu{color:red}", |
+| stylex.when.ancestor(:hover) + @media | ✅ | `ltr: ".x1e2nbdu{color:red}", |
| ltr: "@media (hover: hover){.x1mm45h8.x1mm45h8.x1mm` |
-| stylex.when.ancestor(:focus-within) | ✅ | `ltr: ".xzppbbw{border-color:gray}", |
+| stylex.when.ancestor(:focus-within) | ✅ | `ltr: ".xzppbbw{border-color:gray}", |
| ltr: ".x1y7zxk6.x1y7zxk6:where(.x-default-ma` |
-| stylex.when.ancestor(:active) | ✅ | `ltr: ".x1c071of{transform:none}", |
+| stylex.when.ancestor(:active) | ✅ | `ltr: ".x1c071of{transform:none}", |
| ltr: ".x1nyz7lo.x1nyz7lo:where(.x-default-mark` |
-| stylex.when.ancestor(:disabled) | ✅ | `ltr: ".x1hc1fzr{opacity:1}", |
+| stylex.when.ancestor(:disabled) | ✅ | `ltr: ".x1hc1fzr{opacity:1}", |
| ltr: ".x1ymx0df.x1ymx0df:where(.x-default-marker:di` |
-| stylex.when.ancestor([data-attr]) | ❌ | /vercel/sandbox/repos/xds-worktrees/stylex-caps/test.tsx: Ps |
-| stylex.when.descendant(:hover) | ✅ | `ltr: ".x1e2nbdu{color:red}", |
+| stylex.when.ancestor([data-attr]) | ✅ | `ltr: ".x1e2nbdu{color:red}", |
+| ltr: ".x1vt6d5i.x1vt6d5i:where(.x-default-marker[da` |
+| stylex.when.descendant(:hover) | ✅ | `ltr: ".x1e2nbdu{color:red}", |
| ltr: ".xepvv76.xepvv76:where(:has(.x-default-marker` |
-| stylex.when.siblingBefore(:checked) | ✅ | `ltr: ".x1e2nbdu{color:red}", |
+| stylex.when.siblingBefore(:checked) | ✅ | `ltr: ".x1e2nbdu{color:red}", |
| ltr: ".x72zv5i.x72zv5i:where(.x-default-marker:chec` |
-| stylex.when.siblingAfter(:checked) | ✅ | `ltr: ".x1e2nbdu{color:red}", |
+| stylex.when.siblingAfter(:checked) | ✅ | `ltr: ".x1e2nbdu{color:red}", |
| ltr: ".x1e2z1t3.x1e2z1t3:where(:has(~ .x-default-ma` |
-| stylex.when.anySibling(:hover) | ✅ | `ltr: ".x1hc1fzr{opacity:1}", |
+| stylex.when.anySibling(:hover) | ✅ | `ltr: ".x1hc1fzr{opacity:1}", |
| ltr: ".x1tq5f2g.x1tq5f2g:where(.x-default-marker:ho` |
## StyleX APIs
-| Feature | Status | CSS Output |
-| ---------------------------- | ------ | ------------------------------------------------------------ |
-| stylex.firstThatWorks() | ✅ | `ltr: ".x1fb8ovd{display:flex;display:grid}",` |
-| stylex.positionTry() | ✅ | `ltr: "@position-try --x19yd6gm {top:top;top:anchor(end);}", |
+| Feature | Status | CSS Output |
+| ---------------------------- | ------ | ---------------------------------------------------------------------------------- |
+| stylex.firstThatWorks() | ✅ | `ltr: ".x1fb8ovd{display:flex;display:grid}",` |
+| stylex.positionTry() | ✅ | `ltr: "@position-try --x19yd6gm {top:top;top:anchor(end);}", |
| ltr: ".xvc0jx8{posit` |
-| stylex.viewTransitionClass() | ❌ | /vercel/sandbox/repos/xds-worktrees/stylex-caps/test.tsx: vi |
-| stylex.defineConsts() | ❌ | /vercel/sandbox/repos/xds-worktrees/stylex-caps/test.stylex. |
-| stylex.types.color() | ❌ | /vercel/sandbox/repos/xds-worktrees/stylex-caps/test.stylex. |
-| stylex.types.length() | ❌ | /vercel/sandbox/repos/xds-worktrees/stylex-caps/test.stylex. |
+| stylex.viewTransitionClass() | ✅ | `ltr: "::view-transition-old(*.x8n7qjs){opacity:0;}::view-transition-new(*.x8n7qj` |
+| stylex.defineConsts() | ✅ | `ltr: "", |
+| ltr: "",` |
+| stylex.types.color() | ✅ | `ltr: "@property --x15ffsfu { syntax: \"<color>\"; inherits: true; initial-value:` |
+| stylex.types.length() | ✅ | `ltr: "@property --xdwkrp { syntax: \"<length>\"; inherits: true; initial-value: ` |
## Bleeding Edge
@@ -183,7 +185,7 @@ ltr: "@media (h` |
| ltr: ".x1mt27nc:modal{background-color` |
| anchor() positioning | ✅ | `ltr: ".xnj0yav{top:anchor(--my-anchor bottom)}", |
| ltr: ".x1os70c6{position-anchor` |
-| CSS nesting (&) | ❌ | /vercel/sandbox/repos/xds-worktrees/stylex-caps/test.tsx: In |
+| CSS nesting (&) | ❌ | <repo>/test.tsx: Invalid pseudo or at-rule. |
| @media (scripting: none) | ✅ | `ltr: ".x1lliihq{display:block}", |
| ltr: "@media (scripting: none){.x1cfwndu.x1cfwn` |
| :user-valid / :user-invalid | ✅ | `ltr: ".xzppbbw{border-color:gray}", |
@@ -211,22 +213,21 @@ ltr: "@media (h` |
## Layout
-| Feature | Status | CSS Output |
-| ------------- | ------ | ------------------------------- |
-| display: grid | ✅ | `ltr: ".xrvj5dj{display:grid}", |
-
-ltr: ".x1o61qjw{grid-template-columns:1fr 1fr}",
-`|
-| display: flex + gap | ✅ |`ltr: ".x78zum5{display:flex}",
-ltr: ".xou54vl{gap:16px}",`|
-| aspect-ratio | ✅ |`ltr: ".x186iv6y{aspect-ratio:16 / 9}",`|
-| overscrollBehavior | ✅ |`ltr: ".xish69e{overscroll-behavior:contain}",` |
+| Feature | Status | CSS Output |
+| ------------------------------------------------ | ------ | ----------------------------------------------- |
+| display: grid | ✅ | `ltr: ".xrvj5dj{display:grid}", |
+| ltr: ".x1o61qjw{grid-template-columns:1fr 1fr}", |
+| ` |
+| display: flex + gap | ✅ | `ltr: ".x78zum5{display:flex}", |
+| ltr: ".xou54vl{gap:16px}",` |
+| aspect-ratio | ✅ | `ltr: ".x186iv6y{aspect-ratio:16 / 9}",` |
+| overscrollBehavior | ✅ | `ltr: ".xish69e{overscroll-behavior:contain}",` |
---
## Compact Reference (for LLM context)
-StyleX v0.17.5 supports these CSS features in `stylex.create()`:
+StyleX v0.19.0 supports these CSS features in `stylex.create()`:
**At-Rules:** @media ✅, @media (hover: hover) ✅, @media (prefers-reduced-motion) ✅, @media (prefers-color-scheme) ✅, @supports ✅, @container ✅, @container (named) ✅, @layer ❌, @starting-style ✅, @starting-style (transform) ✅
@@ -234,19 +235,19 @@ StyleX v0.17.5 supports these CSS features in `stylex.create()`:
**Pseudo-Elements:** ::before ✅, ::after ✅, ::placeholder ✅, ::selection ✅, ::backdrop ✅, ::marker ✅, ::file-selector-button ✅
-**Compound Selectors:** Pseudo-class on pseudo-element (::backdrop + condition) ✅, RTL context (:is([dir="rtl"] \*)) ✅, Nested @media + pseudo ✅
+**Compound Selectors:** Pseudo-class on pseudo-element (::backdrop + condition) ✅, RTL context (:is([dir="rtl"] *)) ✅, Nested @media + pseudo ✅
**CSS Values:** CSS variables (custom properties) ✅, calc() ✅, clamp() ✅, light-dark() ✅, color-mix() ✅, container-type ✅, container-name ✅
-**Transitions & Animations:** transition (shorthand) ✅, transition (individual properties) ✅, transitionBehavior: allow-discrete ✅, animation (shorthand) ✅, stylex.keyframes ✅
+**Transitions & Animations:** transition (shorthand) ✅, transition (individual properties) ✅, transitionBehavior: allow-discrete ✅, animation (shorthand) ❌, stylex.keyframes ✅
**Dynamic Styles:** Dynamic values (function in stylex.create) ✅
-**Variables:** stylex.defineVars ❌, stylex.createTheme ❌
+**Variables:** stylex.defineVars ✅, stylex.createTheme ✅
-**Ancestor/Sibling Selectors:** stylex.when.ancestor(:hover) ✅, stylex.when.ancestor(:hover) + @media ✅, stylex.when.ancestor(:focus-within) ✅, stylex.when.ancestor(:active) ✅, stylex.when.ancestor(:disabled) ✅, stylex.when.ancestor([data-attr]) ❌, stylex.when.descendant(:hover) ✅, stylex.when.siblingBefore(:checked) ✅, stylex.when.siblingAfter(:checked) ✅, stylex.when.anySibling(:hover) ✅
+**Ancestor/Sibling Selectors:** stylex.when.ancestor(:hover) ✅, stylex.when.ancestor(:hover) + @media ✅, stylex.when.ancestor(:focus-within) ✅, stylex.when.ancestor(:active) ✅, stylex.when.ancestor(:disabled) ✅, stylex.when.ancestor([data-attr]) ✅, stylex.when.descendant(:hover) ✅, stylex.when.siblingBefore(:checked) ✅, stylex.when.siblingAfter(:checked) ✅, stylex.when.anySibling(:hover) ✅
-**StyleX APIs:** stylex.firstThatWorks() ✅, stylex.positionTry() ✅, stylex.viewTransitionClass() ❌, stylex.defineConsts() ❌, stylex.types.color() ❌, stylex.types.length() ❌
+**StyleX APIs:** stylex.firstThatWorks() ✅, stylex.positionTry() ✅, stylex.viewTransitionClass() ✅, stylex.defineConsts() ✅, stylex.types.color() ✅, stylex.types.length() ✅
**Bleeding Edge:** @scope ✅, @property (explicit) ❌, ::view-transition-old ✅, ::view-transition-new ✅, :modal ✅, anchor() positioning ✅, CSS nesting (&) ❌, @media (scripting: none) ✅, :user-valid / :user-invalid ✅, color-scheme property ✅, text-wrap: balance ✅, text-wrap: pretty ✅, field-sizing: content ✅, interpolate-size: allow-keywords ✅, scrollbar-gutter ✅, scrollbar-width ✅, accent-color ✅
diff --git a/internal/stylex-capabilities/capabilities.json b/internal/stylex-capabilities/capabilities.json
index b49a2d8535..775f333a51 100644
--- a/internal/stylex-capabilities/capabilities.json
+++ b/internal/stylex-capabilities/capabilities.json
@@ -1,8 +1,8 @@
{
- "version": "0.17.5",
- "generatedAt": "2026-03-17T11:34:45.797Z",
+ "version": "0.19.0",
+ "generatedAt": "2026-09-28T15:06:32.081Z",
"total": 92,
- "supported": 82,
+ "supported": 88,
"results": [
{
"category": "At-Rules",
@@ -241,7 +241,7 @@
"name": "Pseudo-class on pseudo-element (::backdrop + condition)",
"supported": true,
"hasInject": true,
- "output": "ltr: \".xph5o2a::backdrop{opacity:0}\",\nltr: \".x1pgog5j.x1pgog5j::backdrop:where([data-open])::backdrop{opacity:1}\","
+ "output": "ltr: \".xph5o2a::backdrop{opacity:0}\",\nltr: \".x1pgog5j.x1pgog5j:where([data-open])::backdrop::backdrop{opacity:1}\","
},
{
"category": "Compound Selectors",
@@ -262,7 +262,7 @@
"name": "CSS variables (custom properties)",
"supported": true,
"hasInject": true,
- "output": "ltr: \".x14qql8p{color:var(--color-primary)}\","
+ "output": "ltr: \".xqwr325{color:var(--color-accent)}\","
},
{
"category": "CSS Values",
@@ -330,9 +330,8 @@
{
"category": "Transitions & Animations",
"name": "animation (shorthand)",
- "supported": true,
- "hasInject": false,
- "output": ""
+ "supported": false,
+ "error": "<repo>/test.tsx: animation is not supported"
},
{
"category": "Transitions & Animations",
@@ -351,14 +350,18 @@
{
"category": "Variables",
"name": "stylex.defineVars",
- "supported": false,
- "error": "/vercel/sandbox/repos/xds-worktrees/stylex-caps/test.tsx: Unable to generate hash for defineVars(). Check that the file has a valid extension and that unstable_moduleResolution is configured."
+ "filename": "test.stylex.ts",
+ "supported": true,
+ "hasInject": true,
+ "output": "ltr: \":root, .x1cptbry{--x15ffsfu:blue;--x1gusifi:green;}\","
},
{
"category": "Variables",
"name": "stylex.createTheme",
- "supported": false,
- "error": "/vercel/sandbox/repos/xds-worktrees/stylex-caps/test.tsx: Unable to generate hash for defineVars(). Check that the file has a valid extension and that unstable_moduleResolution is configured."
+ "filename": "test.stylex.ts",
+ "supported": true,
+ "hasInject": true,
+ "output": "ltr: \":root, .x1cptbry{--x15ffsfu:blue;}\",\nltr: \".x1il70uh, .x1il70uh:root{--x15ffsfu:red;}\","
},
{
"category": "Ancestor/Sibling Selectors",
@@ -398,8 +401,9 @@
{
"category": "Ancestor/Sibling Selectors",
"name": "stylex.when.ancestor([data-attr])",
- "supported": false,
- "error": "/vercel/sandbox/repos/xds-worktrees/stylex-caps/test.tsx: Pseudo selector must start with \":\""
+ "supported": true,
+ "hasInject": true,
+ "output": "ltr: \".x1e2nbdu{color:red}\",\nltr: \".x1vt6d5i.x1vt6d5i:where(.x-default-marker[data-selected] *){color:blue}\","
},
{
"category": "Ancestor/Sibling Selectors",
@@ -446,29 +450,33 @@
{
"category": "StyleX APIs",
"name": "stylex.viewTransitionClass()",
- "supported": false,
- "error": "/vercel/sandbox/repos/xds-worktrees/stylex-caps/test.tsx: viewTransitionClass() should have 1 argument."
+ "supported": true,
+ "hasInject": true,
+ "output": "ltr: \"::view-transition-old(*.x8n7qjs){opacity:0;}::view-transition-new(*.x8n7qjs){opacity:1;}\",\nltr: \".x18eo8ei{view-transition-name:x8n7qjs}\","
},
{
"category": "StyleX APIs",
"name": "stylex.defineConsts()",
"filename": "test.stylex.ts",
- "supported": false,
- "error": "/vercel/sandbox/repos/xds-worktrees/stylex-caps/test.stylex.ts: Unable to generate hash for defineConsts(). Check that the file has a valid extension and that unstable_moduleResolution is configured."
+ "supported": true,
+ "hasInject": true,
+ "output": "ltr: \"\",\nltr: \"\","
},
{
"category": "StyleX APIs",
"name": "stylex.types.color()",
"filename": "test.stylex.ts",
- "supported": false,
- "error": "/vercel/sandbox/repos/xds-worktrees/stylex-caps/test.stylex.ts: Unable to generate hash for defineVars(). Check that the file has a valid extension and that unstable_moduleResolution is configured."
+ "supported": true,
+ "hasInject": true,
+ "output": "ltr: \"@property --x15ffsfu { syntax: \\\"<color>\\\"; inherits: true; initial-value: blue }\",\nltr: \":root, .x1cptbry{--x15ffsfu:blue;}\","
},
{
"category": "StyleX APIs",
"name": "stylex.types.length()",
"filename": "test.stylex.ts",
- "supported": false,
- "error": "/vercel/sandbox/repos/xds-worktrees/stylex-caps/test.stylex.ts: Unable to generate hash for defineVars(). Check that the file has a valid extension and that unstable_moduleResolution is configured."
+ "supported": true,
+ "hasInject": true,
+ "output": "ltr: \"@property --xdwkrp { syntax: \\\"<length>\\\"; inherits: true; initial-value: 16px }\",\nltr: \":root, .x1cptbry{--xdwkrp:16px;}\","
},
{
"category": "Bleeding Edge",
@@ -517,7 +525,7 @@
"category": "Bleeding Edge",
"name": "CSS nesting (&)",
"supported": false,
- "error": "/vercel/sandbox/repos/xds-worktrees/stylex-caps/test.tsx: Invalid pseudo or at-rule."
+ "error": "<repo>/test.tsx: Invalid pseudo or at-rule."
},
{
"category": "Bleeding Edge",
@@ -646,4 +654,4 @@
"output": "ltr: \".xish69e{overscroll-behavior:contain}\","
}
]
-}
\ No newline at end of file
+}
diff --git a/internal/stylex-capabilities/scan.mjs b/internal/stylex-capabilities/scan.mjs
index 8112412531..3347791dc1 100644
--- a/internal/stylex-capabilities/scan.mjs
+++ b/internal/stylex-capabilities/scan.mjs
@@ -15,8 +15,17 @@ import stylexPlugin from '@stylexjs/babel-plugin';
import fs from 'node:fs';
import path from 'node:path';
import {fileURLToPath} from 'node:url';
+import {createRequire} from 'node:module';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
+const repoRoot = path.resolve(__dirname, '../..');
+const requireFromCore = createRequire(
+ path.join(repoRoot, 'packages/core/package.json'),
+);
+const typescriptPreset = requireFromCore.resolve('@babel/preset-typescript');
+const stylexPackagePath = requireFromCore.resolve(
+ '@stylexjs/stylex/package.json',
+);
// ============================================================================
// Test cases — each is a minimal StyleX snippet testing one CSS feature
@@ -336,19 +345,19 @@ const s = stylex.create({ w: (w) => ({ width: w + 'px' }) });`,
{
category: 'Variables',
name: 'stylex.defineVars',
+ filename: 'test.stylex.ts',
code: `import * as stylex from '@stylexjs/stylex';
export const vars = stylex.defineVars({ primary: 'blue', secondary: 'green' });`,
},
{
category: 'Variables',
name: 'stylex.createTheme',
+ filename: 'test.stylex.ts',
code: `import * as stylex from '@stylexjs/stylex';
export const vars = stylex.defineVars({ primary: 'blue' });
export const theme = stylex.createTheme(vars, { primary: 'red' });`,
},
-
-
// stylex.when — ancestor/sibling state selectors
{
category: 'Ancestor/Sibling Selectors',
@@ -387,7 +396,7 @@ const s = stylex.create({ t: { opacity: { default: 1, [stylex.when.ancestor(':di
const s = stylex.create({ t: { color: { default: 'red', [stylex.when.ancestor('[data-selected]')]: 'blue' } } });`,
},
- // stylex.when — descendant and sibling selectors
+ // stylex.when — descendant and sibling selectors
{
category: 'Ancestor/Sibling Selectors',
name: 'stylex.when.descendant(:hover)',
@@ -431,7 +440,7 @@ const s = stylex.create({ t: { positionTryOptions: pt } });`,
category: 'StyleX APIs',
name: 'stylex.viewTransitionClass()',
code: `import * as stylex from '@stylexjs/stylex';
-const vtc = stylex.viewTransitionClass();
+const vtc = stylex.viewTransitionClass({ old: { opacity: 0 }, new: { opacity: 1 } });
const s = stylex.create({ t: { viewTransitionName: vtc } });`,
},
{
@@ -456,7 +465,7 @@ export const vars = stylex.defineVars({ primary: stylex.types.color('blue') });`
export const vars = stylex.defineVars({ spacing: stylex.types.length('16px') });`,
},
- // Bleeding-edge CSS features
+ // Bleeding-edge CSS features
{
category: 'Bleeding Edge',
name: '@scope',
@@ -619,18 +628,35 @@ const s = stylex.create({ t: { overscrollBehavior: 'contain' } });`,
function testFeature(test) {
if (test.skipTest) {
- return { ...test };
+ return {...test};
}
try {
const result = babel.transformSync(test.code, {
filename: test.filename || 'test.tsx',
- presets: ['@babel/preset-typescript'],
- plugins: [[stylexPlugin, {dev: true, runtimeInjection: true}]],
+ presets: [typescriptPreset],
+ plugins: [
+ [
+ stylexPlugin,
+ {
+ dev: true,
+ runtimeInjection: true,
+ propertyValidationMode: 'throw',
+ unstable_moduleResolution: {
+ type: 'commonJS',
+ rootDir: repoRoot,
+ },
+ },
+ ],
+ ],
});
// Check if StyleX actually processed it (look for inject calls)
const hasInject = result.code.includes('_inject');
const hasStylex = result.code.includes('stylex');
- const output = result.code.split('\n').filter(l => l.includes('ltr:')).map(l => l.trim()).join('\n');
+ const output = result.code
+ .split('\n')
+ .filter(l => l.includes('ltr:'))
+ .map(l => l.trim())
+ .join('\n');
// Validate output — some features compile but produce invalid CSS
const invalidPatterns = [
@@ -646,13 +672,18 @@ function testFeature(test) {
supported: !hasInvalidOutput,
hasInject,
output,
- ...(hasInvalidOutput ? {invalidReason: 'Compiles but produces invalid CSS output'} : {}),
+ ...(hasInvalidOutput
+ ? {invalidReason: 'Compiles but produces invalid CSS output'}
+ : {}),
};
} catch (e) {
+ const message = String(e.message)
+ .replaceAll(repoRoot, '<repo>')
+ .split('\n')[0];
return {
...test,
supported: false,
- error: e.message.split('\n')[0],
+ error: message,
};
}
}
@@ -664,12 +695,7 @@ function testFeature(test) {
const results = tests.map(testFeature);
// Get StyleX version
-const stylexPkg = JSON.parse(
- fs.readFileSync(
- path.resolve(__dirname, '../../node_modules/@stylexjs/stylex/package.json'),
- 'utf8',
- ),
-);
+const stylexPkg = JSON.parse(fs.readFileSync(stylexPackagePath, 'utf8'));
// Group by category
const categories = {};
@@ -695,7 +721,9 @@ for (const [cat, items] of Object.entries(categories)) {
for (const item of items) {
const status = item.supported ? '✅' : '❌';
const output = item.supported
- ? item.output ? `\`${item.output.slice(0, 80)}\`` : '(processed)'
+ ? item.output
+ ? `\`${item.output.slice(0, 80)}\``
+ : '(processed)'
: item.error?.slice(0, 60) || 'Error';
md += `| ${item.name} | ${status} | ${output} |\n`;
}
@@ -715,7 +743,9 @@ for (const [cat, items] of Object.entries(categories)) {
const outPath = path.resolve(__dirname, 'CAPABILITIES.md');
fs.writeFileSync(outPath, md);
console.log(`Written to ${outPath}`);
-console.log(`\n${supported}/${total} features supported (StyleX v${stylexPkg.version})`);
+console.log(
+ `\n${supported}/${total} features supported (StyleX v${stylexPkg.version})`,
+);
// Also write JSON for programmatic use
const jsonPath = path.resolve(__dirname, 'capabilities.json');
diff --git a/internal/stylex-capabilities/scan.test.mjs b/internal/stylex-capabilities/scan.test.mjs
new file mode 100644
index 0000000000..614bbb3a28
--- /dev/null
+++ b/internal/stylex-capabilities/scan.test.mjs
@@ -0,0 +1,28 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+import {describe, expect, it} from 'vitest';
+import fs from 'node:fs';
+import path from 'node:path';
+import {createRequire} from 'node:module';
+import {fileURLToPath} from 'node:url';
+
+const __dirname = path.dirname(fileURLToPath(import.meta.url));
+const requireFromCore = createRequire(
+ path.resolve(__dirname, '../../packages/core/package.json'),
+);
+
+const registry = JSON.parse(
+ fs.readFileSync(path.join(__dirname, 'capabilities.json'), 'utf8'),
+);
+const installedStylex = JSON.parse(
+ fs.readFileSync(
+ requireFromCore.resolve('@stylexjs/stylex/package.json'),
+ 'utf8',
+ ),
+);
+
+describe('StyleX capability registry', () => {
+ it('describes the installed StyleX version', () => {
+ expect(registry.version).toBe(installedStylex.version);
+ });
+});
diff --git a/packages/build/README.md b/packages/build/README.md
index 5e71308093..0bc69e79c6 100644
--- a/packages/build/README.md
+++ b/packages/build/README.md
@@ -15,6 +15,7 @@ StyleX generates atomic CSS: same declaration = same class name. Without separat
1. Compiling Astryx library code with `astryx` prefix (`.astryx78zum5`)
2. Compiling product code with default `x` prefix (`.x78zum5`)
3. Placing each group in its own CSS `@layer`
+4. Rejecting unsupported StyleX declarations instead of silently omitting them
## Packages
@@ -74,6 +75,7 @@ module.exports = {
{
dev: process.env.NODE_ENV !== 'production',
runtimeInjection: false,
+ propertyValidationMode: 'throw',
treeshakeCompensation: true,
enableInlinedConditionalMerge: true,
aliases: {
@@ -186,6 +188,7 @@ export default defineConfig({
stylexOptions: {
dev: process.env.NODE_ENV === 'development',
runtimeInjection: false,
+ propertyValidationMode: 'throw',
treeshakeCompensation: true,
unstable_moduleResolution: {
type: 'commonJS',
@@ -232,7 +235,9 @@ Compiles StyleX from both library and product source files in two separate passe
### Vite plugin (`@astryxdesign/build/vite`)
-Wraps `@stylexjs/unplugin` and intercepts the dev CSS endpoint (`/virtual:stylex.css`). Partitions the collected rules by file path and serves split-layer CSS.
+Wraps `@stylexjs/unplugin` and intercepts the dev CSS endpoint (`/virtual:stylex.css`). Partitions the collected rules by file path and serves split-layer CSS. Production builds write those rules to one cache-safe shared stylesheet and link it from every emitted HTML entry, without cross-loading entry-owned CSS.
+
+Unsupported declarations fail the build by default with StyleX's replacement guidance. Set `propertyValidationMode` explicitly in `stylexOverrides` (modern API) or `stylexOptions` (legacy API) only when a migration needs the upstream `warn` or `silent` behavior.
---
diff --git a/packages/build/__fixtures__/invalid-border/index.html b/packages/build/__fixtures__/invalid-border/index.html
new file mode 100644
index 0000000000..25d639387e
--- /dev/null
+++ b/packages/build/__fixtures__/invalid-border/index.html
@@ -0,0 +1,11 @@
+<!-- Copyright (c) Meta Platforms, Inc. and affiliates. -->
+
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ </head>
+ <body>
+ <script type="module" src="/main.ts"></script>
+ </body>
+</html>
diff --git a/packages/build/__fixtures__/invalid-border/main.ts b/packages/build/__fixtures__/invalid-border/main.ts
new file mode 100644
index 0000000000..38aa168b4d
--- /dev/null
+++ b/packages/build/__fixtures__/invalid-border/main.ts
@@ -0,0 +1,9 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+import * as stylex from '@stylexjs/stylex';
+
+const styles = stylex.create({
+ divider: {
+ borderTop: '1px solid var(--color-border)',
+ },
+});
diff --git a/packages/build/__fixtures__/layer-split-multipage/index.html b/packages/build/__fixtures__/layer-split-multipage/index.html
new file mode 100644
index 0000000000..c16dbe6be8
--- /dev/null
+++ b/packages/build/__fixtures__/layer-split-multipage/index.html
@@ -0,0 +1,12 @@
+<!-- Copyright (c) Meta Platforms, Inc. and affiliates. -->
+
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ </head>
+ <body>
+ <div id="root"></div>
+ <script type="module" src="/main.tsx"></script>
+ </body>
+</html>
diff --git a/packages/build/__fixtures__/layer-split-multipage/main.css b/packages/build/__fixtures__/layer-split-multipage/main.css
new file mode 100644
index 0000000000..a4ca005ce9
--- /dev/null
+++ b/packages/build/__fixtures__/layer-split-multipage/main.css
@@ -0,0 +1,5 @@
+/* Copyright (c) Meta Platforms, Inc. and affiliates. */
+
+:root {
+ --multipage-main-only: #123456;
+}
diff --git a/packages/build/__fixtures__/layer-split-multipage/main.tsx b/packages/build/__fixtures__/layer-split-multipage/main.tsx
new file mode 100644
index 0000000000..71d426f2dc
--- /dev/null
+++ b/packages/build/__fixtures__/layer-split-multipage/main.tsx
@@ -0,0 +1,13 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+import {createRoot} from 'react-dom/client';
+import './main.css';
+import {Theme} from '@astryxdesign/core/theme';
+import {App} from '../layer-split/App';
+import {fixtureTheme} from '../layer-split/theme';
+
+createRoot(document.getElementById('root')!).render(
+ <Theme theme={fixtureTheme} mode="light">
+ <App />
+ </Theme>,
+);
diff --git a/packages/build/__fixtures__/layer-split-multipage/setup.css b/packages/build/__fixtures__/layer-split-multipage/setup.css
new file mode 100644
index 0000000000..b578c5a69c
--- /dev/null
+++ b/packages/build/__fixtures__/layer-split-multipage/setup.css
@@ -0,0 +1,5 @@
+/* Copyright (c) Meta Platforms, Inc. and affiliates. */
+
+:root {
+ --multipage-setup-only: #654321;
+}
diff --git a/packages/build/__fixtures__/layer-split-multipage/setup.html b/packages/build/__fixtures__/layer-split-multipage/setup.html
new file mode 100644
index 0000000000..fbdf6383bd
--- /dev/null
+++ b/packages/build/__fixtures__/layer-split-multipage/setup.html
@@ -0,0 +1,12 @@
+<!-- Copyright (c) Meta Platforms, Inc. and affiliates. -->
+
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ </head>
+ <body>
+ <div id="root"></div>
+ <script type="module" src="/setup.tsx"></script>
+ </body>
+</html>
diff --git a/packages/build/__fixtures__/layer-split-multipage/setup.tsx b/packages/build/__fixtures__/layer-split-multipage/setup.tsx
new file mode 100644
index 0000000000..62e600e04e
--- /dev/null
+++ b/packages/build/__fixtures__/layer-split-multipage/setup.tsx
@@ -0,0 +1,13 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+import {createRoot} from 'react-dom/client';
+import './setup.css';
+import {Theme} from '@astryxdesign/core/theme';
+import {App} from '../layer-split/App';
+import {fixtureTheme} from '../layer-split/theme';
+
+createRoot(document.getElementById('root')!).render(
+ <Theme theme={fixtureTheme} mode="light">
+ <App />
+ </Theme>,
+);
diff --git a/packages/build/__fixtures__/layer-split/App.tsx b/packages/build/__fixtures__/layer-split/App.tsx
index 9d6191552d..27300c0d17 100644
--- a/packages/build/__fixtures__/layer-split/App.tsx
+++ b/packages/build/__fixtures__/layer-split/App.tsx
@@ -20,10 +20,23 @@ import {Button} from '@astryxdesign/core/Button';
import {Theme} from '@astryxdesign/core/theme';
import {nestedTheme, nestedDarkTheme} from './theme';
+const integrityPulse = stylex.keyframes({
+ from: {opacity: 0.271},
+ to: {opacity: 0.913},
+});
+
const styles = stylex.create({
productBox: {
backgroundColor: 'rgb(238, 238, 238)',
padding: '11px',
+ animationName: integrityPulse,
+ animationDuration: '717ms',
+ '::after': {
+ content: '""',
+ borderTopColor: 'rgb(1, 2, 3)',
+ borderTopStyle: 'solid',
+ borderTopWidth: '7px',
+ },
},
themedButton: {
backgroundColor: 'rgb(255, 140, 0)',
diff --git a/packages/build/src/babel.js b/packages/build/src/babel.js
index 56da256cf4..acf49ae9b8 100644
--- a/packages/build/src/babel.js
+++ b/packages/build/src/babel.js
@@ -1,6 +1,6 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
-"use strict";
+'use strict';
/**
* @astryxdesign/build/babel
@@ -28,9 +28,20 @@ module.exports = function astryxBabelPlugin(api, options) {
...stylexOptions
} = options;
+ // StyleX's upstream default is `silent`, which turns unsupported declarations
+ // into missing CSS. Astryx fails closed by default so consumer builds point at
+ // the declaration and the supported replacement instead.
+ const validatedStylexOptions = {
+ propertyValidationMode: 'throw',
+ ...stylexOptions,
+ };
+
// Build the two sets of options — only classNamePrefix differs
- const libraryOpts = {...stylexOptions, classNamePrefix: libraryPrefix};
- const productOpts = {...stylexOptions, classNamePrefix};
+ const libraryOpts = {
+ ...validatedStylexOptions,
+ classNamePrefix: libraryPrefix,
+ };
+ const productOpts = {...validatedStylexOptions, classNamePrefix};
// Create two plugin instances
const libraryPlugin = stylexPlugin(api, libraryOpts);
@@ -82,18 +93,18 @@ module.exports = function astryxBabelPlugin(api, options) {
// enter/exit form (Program uses this)
visitor[key] = {};
if (sample.enter) {
- visitor[key].enter = function(path, state) {
+ visitor[key].enter = function (path, state) {
callVisitor.call(this, 'enter', key, path, state);
};
}
if (sample.exit) {
- visitor[key].exit = function(path, state) {
+ visitor[key].exit = function (path, state) {
callVisitor.call(this, 'exit', key, path, state);
};
}
} else {
// Simple function visitor
- visitor[key] = function(path, state) {
+ visitor[key] = function (path, state) {
callVisitor.call(this, 'enter', key, path, state);
};
}
diff --git a/packages/build/src/babel.test.mjs b/packages/build/src/babel.test.mjs
index 5dd18fb49b..e8dc177853 100644
--- a/packages/build/src/babel.test.mjs
+++ b/packages/build/src/babel.test.mjs
@@ -13,6 +13,7 @@ import {createRequire} from 'node:module';
const require = createRequire(import.meta.url);
const babel = require('@babel/core');
const astryxBabelPlugin = require('./babel.js');
+const {stylexOptions: buildStylexOptions} = require('./config.js');
const SOURCE = `
import * as stylex from '@stylexjs/stylex';
@@ -21,13 +22,24 @@ export const styles = stylex.create({
});
`;
+const INVALID_BORDER_SOURCE = `
+import * as stylex from '@stylexjs/stylex';
+export const styles = stylex.create({
+ box: {borderTop: '1px solid var(--color-border)'},
+});
+`;
+
/**
* Transform a StyleX source through the Astryx babel wrapper as if it were an
* Astryx library file, returning the emitted code. `libraryPrefix` controls the
* atomic class-name prefix for library files.
*/
-function transformLibraryFile(libraryPrefix) {
- const result = babel.transformSync(SOURCE, {
+function transformLibraryFile(
+ libraryPrefix,
+ source = SOURCE,
+ stylexOptions = {},
+) {
+ const result = babel.transformSync(source, {
// A path matching one of the library patterns so the wrapper routes it
// through the library plugin instance.
filename: 'node_modules/@astryxdesign/core/src/Box/AstryxBox.tsx',
@@ -39,6 +51,7 @@ function transformLibraryFile(libraryPrefix) {
{
...(libraryPrefix ? {libraryPrefix} : {}),
unstable_moduleResolution: {type: 'commonJS', rootDir: process.cwd()},
+ ...stylexOptions,
},
],
],
@@ -69,4 +82,30 @@ describe('Astryx babel wrapper -- library StyleX prefix', () => {
expect(atoms.length).toBeGreaterThan(0);
expect(atoms.every(c => c.startsWith('lib'))).toBe(true);
});
+
+ it('rejects declarations that StyleX would otherwise drop silently', () => {
+ expect(() =>
+ transformLibraryFile(undefined, INVALID_BORDER_SOURCE),
+ ).toThrow(
+ /borderTop is not supported.*borderTopWidth.*borderTopStyle.*borderTopColor/s,
+ );
+ });
+
+ it('keeps the upstream validation mode override available', () => {
+ expect(() =>
+ transformLibraryFile(undefined, INVALID_BORDER_SOURCE, {
+ propertyValidationMode: 'silent',
+ }),
+ ).not.toThrow();
+ });
+
+ it('uses the same strict default in generated Babel and PostCSS configs', () => {
+ expect(buildStylexOptions(process.cwd()).propertyValidationMode).toBe(
+ 'throw',
+ );
+ expect(
+ buildStylexOptions(process.cwd(), {propertyValidationMode: 'warn'})
+ .propertyValidationMode,
+ ).toBe('warn');
+ });
});
diff --git a/packages/build/src/config.js b/packages/build/src/config.js
index 71e4d3af41..69196ae504 100644
--- a/packages/build/src/config.js
+++ b/packages/build/src/config.js
@@ -41,6 +41,7 @@ function stylexOptions(rootDir, overrides = {}) {
return {
dev: process.env.NODE_ENV !== 'production',
runtimeInjection: false,
+ propertyValidationMode: 'throw',
enableInlinedConditionalMerge: true,
treeshakeCompensation: true,
aliases: resolveAliases(rootDir),
diff --git a/packages/build/src/vite.build.test.ts b/packages/build/src/vite.build.test.ts
index 887b1cfd4e..1ca1878e64 100644
--- a/packages/build/src/vite.build.test.ts
+++ b/packages/build/src/vite.build.test.ts
@@ -11,15 +11,20 @@
* `astryx-base` they lose to one. Only the built artifact shows it, so this
* builds one.
*
- * Two shapes, because StyleX emits through two different paths:
+ * Three shapes, because StyleX emits through two different paths and merges
+ * all entries into one stylesheet:
*
- * `layer-split` the app imports a stylesheet, so the bundle has a CSS
- * asset and StyleX appends to it in `generateBundle`
- * `layer-split-nocss` the app imports none, so StyleX writes its own file in
- * `writeBundle`, outside Rollup's graph
+ * `layer-split` the app imports a stylesheet, so the bundle has a
+ * CSS asset and StyleX appends in `generateBundle`
+ * `layer-split-nocss` the app imports none, so StyleX writes its own file
+ * in `writeBundle`, outside Rollup's graph
+ * `layer-split-multipage` two entries own distinct authored CSS, while both
+ * must load the one shared StyleX result
*
- * The second is the one that was missing, and it hid two defects: the split did
- * not run there at all, and the file StyleX writes is not linked by any page.
+ * The no-CSS shape was originally missing, which hid two defects: the split did
+ * not run there at all, and the file StyleX writes was not linked by any page.
+ * The multi-page shape protects against linking StyleX from only one entry or
+ * cross-loading that entry's authored CSS into every page.
*
* What none of this can prove is which declaration actually paints — that is a
* cascade fact, and it lives in .github/scripts/theme-layer-cascade.js.
@@ -43,39 +48,83 @@ const CORE_SRC = path.join(REPO_ROOT, 'packages/core/src');
const LIBRARY_CLASS = /\.astryx[a-z0-9]{5,}/g;
const PRODUCT_CLASS = /\.x[a-z0-9]{5,}/g;
-type Built = {css: string; cssName: string; html: string; outDir: string};
+type Built = {
+ css: string;
+ cssName: string;
+ cssByName: Record<string, string>;
+ html: string;
+ htmlByName: Record<string, string>;
+ outDir: string;
+};
-async function buildFixture(name: string): Promise<Built> {
+async function buildFixture(
+ name: string,
+ htmlNames: string[] = ['index.html'],
+): Promise<Built> {
const root = path.join(FIXTURES, name);
const outDir = mkdtempSync(path.join(tmpdir(), `astryx-${name}-`));
- await build({
- root,
- logLevel: 'error',
- build: {outDir, emptyOutDir: true},
- resolve: {alias: {'@astryxdesign/core': CORE_SRC}},
- plugins: [
- react(),
- ...astryxStylex({
- stylexOptions: {
- dev: false,
- unstable_moduleResolution: {type: 'commonJS', rootDir: REPO_ROOT},
- aliases: {
- '@astryxdesign/core/*': [path.join(CORE_SRC, '*')],
- '@astryxdesign/core': [CORE_SRC],
+ try {
+ await build({
+ root,
+ logLevel: 'error',
+ build: {
+ outDir,
+ emptyOutDir: true,
+ ...(htmlNames.length > 1 && {
+ rollupOptions: {
+ input: Object.fromEntries(
+ htmlNames.map(file => [
+ path.basename(file, '.html'),
+ path.join(root, file),
+ ]),
+ ),
},
- },
- libraryPattern: 'packages/core/',
- }),
- ],
- });
+ }),
+ },
+ resolve: {alias: {'@astryxdesign/core': CORE_SRC}},
+ plugins: [
+ react(),
+ ...astryxStylex({
+ stylexOptions: {
+ dev: false,
+ unstable_moduleResolution: {type: 'commonJS', rootDir: REPO_ROOT},
+ aliases: {
+ '@astryxdesign/core/*': [path.join(CORE_SRC, '*')],
+ '@astryxdesign/core': [CORE_SRC],
+ },
+ },
+ libraryPattern: 'packages/core/',
+ }),
+ ],
+ });
+ } catch (error) {
+ rmSync(outDir, {recursive: true, force: true});
+ throw error;
+ }
const assets = path.join(outDir, 'assets');
- const cssName = readdirSync(assets).find(f => f.endsWith('.css'));
- if (!cssName) throw new Error(`no stylesheet emitted into ${assets}`);
+ const cssNames = readdirSync(assets).filter(f => f.endsWith('.css'));
+ const cssByName = Object.fromEntries(
+ cssNames.map(file => [
+ file,
+ readFileSync(path.join(assets, file), 'utf-8'),
+ ]),
+ );
+ const cssName = cssNames.find(f => f.startsWith('astryx-stylex-'));
+ if (!cssName)
+ throw new Error(`no shared StyleX stylesheet emitted into ${assets}`);
+ const htmlByName = Object.fromEntries(
+ htmlNames.map(file => [
+ file,
+ readFileSync(path.join(outDir, file), 'utf-8'),
+ ]),
+ );
return {
- css: readFileSync(path.join(assets, cssName), 'utf-8'),
+ css: cssByName[cssName],
cssName,
- html: readFileSync(path.join(outDir, 'index.html'), 'utf-8'),
+ cssByName,
+ html: htmlByName['index.html'],
+ htmlByName,
outDir,
};
}
@@ -126,6 +175,14 @@ function itSplitsCorrectly(get: () => Built) {
expect(library.match(PRODUCT_CLASS)).toBeNull();
});
+ it('keeps nested pseudo-elements and keyframes in the product layer', () => {
+ const product = layerBlock(get().css, 'product');
+ expect(product).toContain(':after');
+ expect(product).toContain('#010203');
+ expect(product).toContain('@keyframes');
+ expect(product).toContain('.717s');
+ });
+
it('leaves no StyleX rule outside the two layers', () => {
const {css} = get();
const outside = css
@@ -176,4 +233,55 @@ describe('a production build separates Astryx and product styles by layer', () =
itSplitsCorrectly(() => built);
});
+
+ describe('when the app has multiple HTML entries', () => {
+ let built: Built;
+ beforeAll(async () => {
+ built = await buildFixture('layer-split-multipage', [
+ 'index.html',
+ 'setup.html',
+ ]);
+ }, 180_000);
+ afterAll(
+ () => built && rmSync(built.outDir, {recursive: true, force: true}),
+ );
+
+ it('links the shared StyleX stylesheet from every page exactly once', () => {
+ for (const html of Object.values(built.htmlByName)) {
+ expect(html).toContain(built.cssName);
+ expect(
+ html.split(built.cssName).length - 1,
+ 'stylesheet is not linked exactly once',
+ ).toBe(1);
+ }
+ });
+
+ it('keeps entry-owned CSS on its own page', () => {
+ const mainCss = Object.entries(built.cssByName).find(([, css]) =>
+ css.includes('--multipage-main-only'),
+ );
+ const setupCss = Object.entries(built.cssByName).find(([, css]) =>
+ css.includes('--multipage-setup-only'),
+ );
+ expect(mainCss).toBeDefined();
+ expect(setupCss).toBeDefined();
+
+ const [mainCssName] = mainCss!;
+ const [setupCssName] = setupCss!;
+ expect(built.htmlByName['index.html']).toContain(mainCssName);
+ expect(built.htmlByName['index.html']).not.toContain(setupCssName);
+ expect(built.htmlByName['setup.html']).toContain(setupCssName);
+ expect(built.htmlByName['setup.html']).not.toContain(mainCssName);
+ expect(built.css).not.toContain('--multipage-main-only');
+ expect(built.css).not.toContain('--multipage-setup-only');
+ });
+ });
+});
+
+describe('a production build validates StyleX declarations', () => {
+ it('fails with longhand guidance instead of dropping a border shorthand', async () => {
+ await expect(buildFixture('invalid-border')).rejects.toThrow(
+ /borderTop is not supported.*borderTopWidth.*borderTopStyle.*borderTopColor/s,
+ );
+ }, 180_000);
});
diff --git a/packages/build/src/vite.ts b/packages/build/src/vite.ts
index e5c44c507d..f1b819d319 100644
--- a/packages/build/src/vite.ts
+++ b/packages/build/src/vite.ts
@@ -7,6 +7,7 @@ import fs from 'node:fs';
import path from 'node:path';
import {fileURLToPath} from 'node:url';
import {createRequire} from 'node:module';
+import {createHash} from 'node:crypto';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -136,6 +137,7 @@ export function astryxStylex(
const stylexOptions: Record<string, unknown> = {
dev,
runtimeInjection: false,
+ propertyValidationMode: 'throw',
treeshakeCompensation: true,
unstable_moduleResolution: {
type: 'commonJS',
@@ -282,6 +284,10 @@ export function astryxStylex(
* layer (below `astryx-theme`, so a theme can override them), product styles
* into the product layer (above it, so an app always wins).
*
+ * The split output is written to one dedicated shared stylesheet. Keeping the
+ * collected rules out of an entry-owned CSS asset lets every HTML entry load
+ * the same StyleX output without also importing another page's authored CSS.
+ *
* This is the one implementation. The dev middleware and the build hook differ
* only in when they run and what they do with the string — the partition itself
* must not diverge, because it did: the build shipped a version that wrapped
@@ -333,11 +339,12 @@ function renderSplitLayers(
* component overrides were silently dropped in the built app while working in
* dev.
*
- * This replaces that merged block with the partitioned pair. It runs in
- * `writeBundle` because StyleX emits through two different paths depending on
- * whether the bundle already has a stylesheet to append to (`generateBundle`)
- * or has to write its own file (`writeBundle`) — on disk, after both, there is
- * one case instead of two.
+ * This removes that merged block from the entry-owned stylesheet, writes the
+ * partitioned pair to a dedicated shared stylesheet, and links it from every
+ * built HTML page. It runs in `writeBundle` because StyleX emits through two
+ * different paths depending on whether the bundle already has a stylesheet to
+ * append to (`generateBundle`) or has to write its own file (`writeBundle`) —
+ * on disk, after both, there is one case instead of two.
*
* The block is located by an exact match against StyleX's own collector rather
* than by looking for `@layer priority1`: a wrong guess about where the block
@@ -388,19 +395,16 @@ function buildLayerSplitPlugin(
// patch and nothing was shipped, so this is not a failure.
if (!outDir || !fs.existsSync(outDir)) return;
- const patched: string[] = [];
+ const containingFiles: Array<{file: string; css: string; at: number}> =
+ [];
for (const file of listCssFiles(outDir)) {
const css = fs.readFileSync(file, 'utf-8');
const at = css.lastIndexOf(merged);
if (at === -1) continue;
- fs.writeFileSync(
- file,
- css.slice(0, at) + split + css.slice(at + merged.length),
- );
- patched.push(file);
+ containingFiles.push({file, css, at});
}
- if (patched.length === 0) {
+ if (containingFiles.length === 0) {
this.error(
'astryx-build-layer-split: StyleX emitted rules but its CSS block ' +
`was not found in any stylesheet under ${outDir}, so Astryx and ` +
@@ -412,7 +416,30 @@ function buildLayerSplitPlugin(
return;
}
- linkOrphanStylesheets(outDir, patched, base);
+ if (listHtmlFiles(outDir).length === 0) {
+ for (const {file, css, at} of containingFiles) {
+ fs.writeFileSync(
+ file,
+ css.slice(0, at) + split + css.slice(at + merged.length),
+ );
+ }
+ return;
+ }
+
+ for (const {file, css, at} of containingFiles) {
+ fs.writeFileSync(
+ file,
+ css.slice(0, at) + css.slice(at + merged.length),
+ );
+ }
+
+ const hash = createHash('sha256').update(split).digest('hex').slice(0, 8);
+ const sharedStylesheet = path.join(
+ path.dirname(containingFiles[0].file),
+ `astryx-stylex-${hash}.css`,
+ );
+ fs.writeFileSync(sharedStylesheet, split);
+ linkStylesheetsForEveryPage(outDir, [sharedStylesheet], base);
},
};
}
@@ -440,20 +467,21 @@ function listHtmlFiles(dir: string): string[] {
}
/**
- * Link a stylesheet the build wrote but no page loads.
+ * Ensure every built page loads the stylesheet containing StyleX's rules.
*
* When an app imports no CSS of its own, StyleX has no bundle asset to append
* to, so it writes `assets/stylex.css` itself — outside Rollup's graph, which
- * means Vite's HTML plugin never learns about it and emits no `<link>`. The app
- * ships every Astryx style correctly split into layers, and a completely
- * unstyled page. Importing any stylesheet hides it, which is why it survives:
- * the moment a project has one line of its own CSS the symptom disappears.
+ * means Vite's HTML plugin never learns about it and emits no `<link>`. In a
+ * multi-page build, Vite can also attach the one merged StyleX stylesheet to
+ * only one entry. The other pages then ship valid compiled classes but load no
+ * rules for them.
*
- * Only orphans are linked. A stylesheet already referenced by a page is Vite's,
- * and touching it would duplicate the load. A build with no HTML at all —
- * library mode — is left alone: its consumer imports the CSS themselves.
+ * Check each page independently. A stylesheet already referenced by that page
+ * is left alone; a missing reference is inserted exactly once. A build with no
+ * HTML at all — library mode — is left alone because its consumer imports the
+ * CSS themselves.
*/
-function linkOrphanStylesheets(
+function linkStylesheetsForEveryPage(
outDir: string,
cssFiles: string[],
base: string,
@@ -461,25 +489,23 @@ function linkOrphanStylesheets(
const pages = listHtmlFiles(outDir);
if (pages.length === 0) return;
- const orphans = cssFiles.filter(css => {
- const name = path.basename(css);
- return !pages.some(page => fs.readFileSync(page, 'utf-8').includes(name));
- });
- if (orphans.length === 0) return;
-
- const links = orphans
- .map(css => {
- const href =
- base.replace(/\/$/, '') +
- '/' +
- path.relative(outDir, css).split(path.sep).join('/');
- return `<link rel="stylesheet" crossorigin href="${href}">`;
- })
- .join('\n ');
-
for (const page of pages) {
const html = fs.readFileSync(page, 'utf-8');
if (!html.includes('</head>')) continue;
+
+ const missing = cssFiles.filter(css => !html.includes(path.basename(css)));
+ if (missing.length === 0) continue;
+
+ const links = missing
+ .map(css => {
+ const href =
+ base.replace(/\/$/, '') +
+ '/' +
+ path.relative(outDir, css).split(path.sep).join('/');
+ return `<link rel="stylesheet" crossorigin href="${href}">`;
+ })
+ .join('\n ');
+
fs.writeFileSync(page, html.replace('</head>', ` ${links}\n </head>`));
}
}
@@ -527,19 +553,23 @@ function astryxStylexLegacy(options: AstryxVitePluginLegacyOptions): Plugin[] {
const libraryLayer = layers.library ?? 'astryx-base';
const productLayer = layers.product ?? 'product';
+ const validatedStylexOptions = {
+ propertyValidationMode: 'throw',
+ ...(stylexOptions as any),
+ };
const astryxBabelPlugin = path.resolve(__dirname, 'babel.js');
- const existingPlugins = (stylexOptions as any).babelConfig?.plugins ?? [];
+ const existingPlugins = validatedStylexOptions.babelConfig?.plugins ?? [];
const basePlugin = stylex.vite({
- ...(stylexOptions as any),
+ ...validatedStylexOptions,
useCSSLayers: true,
babelConfig: {
- ...(stylexOptions as any).babelConfig,
+ ...validatedStylexOptions.babelConfig,
plugins: [
[
astryxBabelPlugin,
{
- ...(stylexOptions as any),
+ ...validatedStylexOptions,
libraryPrefix: stylexPrefix,
babelConfig: undefined,
},
diff --git a/packages/core/src/Chat/ChatComposer.tsx b/packages/core/src/Chat/ChatComposer.tsx
index ab612737c8..fc5122d763 100644
--- a/packages/core/src/Chat/ChatComposer.tsx
+++ b/packages/core/src/Chat/ChatComposer.tsx
@@ -190,7 +190,6 @@ const styles = stylex.create({
flexDirection: 'column',
},
textarea: {
- all: 'unset',
width: '100%',
resize: 'none' as const,
fontSize: typeScaleVars['--text-body-size'],
diff --git a/packages/core/src/Collapsible/Collapsible.tsx b/packages/core/src/Collapsible/Collapsible.tsx
index 15dfa04b82..9f59a8a9ac 100644
--- a/packages/core/src/Collapsible/Collapsible.tsx
+++ b/packages/core/src/Collapsible/Collapsible.tsx
@@ -61,7 +61,6 @@ const styles = stylex.create({
// content via the `astryx-collapsible-trigger` target — e.g. a heading font
// on the trigger while the content stays on the body font.
trigger: {
- all: 'unset',
boxSizing: 'border-box',
display: 'flex',
alignItems: 'center',
@@ -77,8 +76,8 @@ const styles = stylex.create({
color: colorVars['--color-text-primary'],
textAlign: 'start',
paddingBlock: 0,
- // `all: unset` above wipes the UA focus outline; restore a keyboard-only
- // focus ring using the standard token/offset (WCAG 2.4.7).
+ // Restore a keyboard-only focus ring using the standard token/offset
+ // (WCAG 2.4.7).
},
// Capsize: trim leading from text triggers
triggerLabel: {
@@ -96,8 +95,7 @@ const styles = stylex.create({
flexGrow: 1,
},
// Disabled trigger — non-interactive, dimmed. Native `disabled` on the
- // button blocks click + keyboard activation; these styles restore the
- // visual affordance that `all: unset` wipes.
+ // button blocks click + keyboard activation.
triggerDisabled: {
cursor: 'default',
opacity: 0.5,
diff --git a/packages/core/src/Item/Item.tsx b/packages/core/src/Item/Item.tsx
index 5b035f708f..99d9de31c2 100644
--- a/packages/core/src/Item/Item.tsx
+++ b/packages/core/src/Item/Item.tsx
@@ -247,12 +247,10 @@ const styles = stylex.create({
opacity: 0.5,
},
invisibleButton: {
- all: 'unset',
cursor: {
default: 'inherit',
':is(:disabled,[aria-disabled="true"])': 'default',
},
- font: 'inherit',
color: 'inherit',
display: 'flex',
flexDirection: 'column',
@@ -262,12 +260,10 @@ const styles = stylex.create({
outline: 'none',
},
invisibleAnchor: {
- all: 'unset',
cursor: {
default: 'inherit',
':is(:disabled,[aria-disabled="true"])': 'default',
},
- font: 'inherit',
color: 'inherit',
display: 'flex',
flexDirection: 'column',
diff --git a/packages/core/src/Stepper/Step.tsx b/packages/core/src/Stepper/Step.tsx
index f9f093462c..23075a55a5 100644
--- a/packages/core/src/Stepper/Step.tsx
+++ b/packages/core/src/Stepper/Step.tsx
@@ -693,7 +693,6 @@ const styles = stylex.create({
// Button reset for clickable steps
buttonReset: {
- all: 'unset',
textAlign: 'start',
alignItems: 'stretch',
display: 'flex',
@@ -734,10 +733,8 @@ const styles = stylex.create({
// Interactive wrapper (indicator + label act as one click target).
otInteractive: {
- all: 'unset',
boxSizing: 'border-box',
- // `all: unset` leaves the <button> UA default of centered text; force
- // start so vertical labels/descriptions read left-aligned. Horizontal
+ // Force start alignment so vertical labels/descriptions read left-aligned. Horizontal
// labels re-center via otLabelWrapH (a deeper element).
textAlign: 'start',
cursor: {
diff --git a/packages/core/src/Thumbnail/Thumbnail.tsx b/packages/core/src/Thumbnail/Thumbnail.tsx
index 163943ba17..0366fde553 100644
--- a/packages/core/src/Thumbnail/Thumbnail.tsx
+++ b/packages/core/src/Thumbnail/Thumbnail.tsx
@@ -192,7 +192,6 @@ const styles = stylex.create({
},
},
interactiveButton: {
- all: 'unset',
cursor: {
default: 'pointer',
':is(:disabled,[aria-disabled="true"])': 'default',
diff --git a/packages/core/src/Token/Token.tsx b/packages/core/src/Token/Token.tsx
index 56b7bbcb21..9ceecf1663 100644
--- a/packages/core/src/Token/Token.tsx
+++ b/packages/core/src/Token/Token.tsx
@@ -162,19 +162,16 @@ const styles = stylex.create({
borderWidth: 0,
},
invisibleButton: {
- all: 'unset',
cursor: {
default: 'inherit',
':is(:disabled,[aria-disabled="true"])': 'default',
},
- font: 'inherit',
color: 'inherit',
outline: 'none',
overflow: 'hidden',
minWidth: 0,
},
removeButton: {
- all: 'unset',
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
diff --git a/packages/core/src/TreeList/TreeListItem.tsx b/packages/core/src/TreeList/TreeListItem.tsx
index 157d868169..09309ccb78 100644
--- a/packages/core/src/TreeList/TreeListItem.tsx
+++ b/packages/core/src/TreeList/TreeListItem.tsx
@@ -113,7 +113,6 @@ const styles = stylex.create({
backgroundColor: colorVars['--color-accent-muted'],
},
invisibleButton: {
- all: 'unset',
cursor: {
default: 'inherit',
':is(:disabled,[aria-disabled="true"])': 'default',
@@ -129,7 +128,6 @@ const styles = stylex.create({
outline: 'none',
},
invisibleAnchor: {
- all: 'unset',
cursor: {
default: 'inherit',
':is(:disabled,[aria-disabled="true"])': 'default',
@@ -191,7 +189,6 @@ const styles = stylex.create({
marginInlineEnd: `calc(${spacingVars['--spacing-1']} * -1)`,
},
chevronButton: {
- all: 'unset',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',