Repository navigation
fix(build): resolve defineConsts read across files in astryxStylex - #8075
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 defineConsts restoration (the legacy form's treeshakeCompensation default and constants shared across layers) is well covered by the new build tests, but approval waits on a decision about the new public undefinedVariables: 'warn' | 'error' option and its default production-build warning, which no current spec covers. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, or by naming the spec that governs it; the author can do so as an engineering owner.
- Either way, keep
undefinedGeneratedVariablesinternal: exported from@astryxdesign/build/vite, it would ship as public API. - Either way, with the default
astryx/xprefixes a product reading an Astryx package's constants still getsvar(--x…), so re-key shared constants per prefix or narrow the changeset's claim. - If the option stays, the check must stop reporting a product's own
var(--xl)(declared in its app CSS) as a dropped declaration, which also fails that build under'error'. - If the option stays, honour
stylexOverrides.classNamePrefixin the zero-config check and declare the option in a[feat]changeset.
[Automated review]
| libraryLayer, | ||
| productLayer, | ||
| lightningcssOptions: stylexOptions.lightningcssOptions, | ||
| classNamePrefixes: [stylexPrefix, 'x'], |
There was a problem hiding this comment.
The zero-config form compiles product files with stylexOverrides.classNamePrefix when it is set, but this checks only 'x', so with classNamePrefix: 'app' an undeclared --app… read is never reported. stylexOverrides.classNamePrefix ?? 'x' would match what the legacy form does at lines 807-811.
| * SYNC: scripts/build-css.mjs `undefinedStyleXVariables` is the same check | ||
| * for the prebuilt package stylesheets. | ||
| */ | ||
| export function undefinedGeneratedVariables( |
There was a problem hiding this comment.
Exporting this from the ./vite entry ships it in dist/vite.mjs and dist/vite.d.ts as public API of @astryxdesign/build/vite. Since it exists for the unit tests, consider moving it to a module the entry does not re-export and testing it there.
| const read = new Set( | ||
| [ | ||
| ...css.matchAll( | ||
| new RegExp(`var\\(\\s*(--(?:${names})[a-z0-9]+)\\s*[,)]`, 'g'), |
There was a problem hiding this comment.
Every var(--x[a-z0-9]+) read counts as generated and only this stylesheet's declarations count as declared, so a product style reading its own var(--xl) (declared in its app CSS) is reported as a declaration every browser drops, and fails the build under 'error'. Counting declarations from every emitted stylesheet and reporting only hash-shaped names would avoid that.
| '@astryxdesign/build': patch | ||
| --- | ||
|
|
||
| [fix] `astryxStylex` resolves `defineConsts` values read from another file. With the `{stylexOptions}` form (the one Storybook uses), a file that read only constants from a `.stylex.ts` module lost that import once StyleX compiled it, so the constants never reached the CSS: a constant used as a media-query key failed the build ("Invalid empty selector") and one used as a value shipped as a custom property nothing declares. A constant defined on the library side of the layer split and read on the product side stayed unresolved in either form. A production build now also warns, naming the variable and the rule that reads it, when its stylesheet reads a StyleX-generated custom property that nothing declares; set `undefinedVariables: 'error'` to fail the build instead. |
There was a problem hiding this comment.
With the default prefixes (Astryx package files astryx, product files x), a product reading an Astryx package's constant still builds to var(--x…): StyleX keys the reader's placeholder with the reader's prefix, so sharing constants across layers only resolves same-prefix pairs. Either re-key shared constants per prefix or narrow this sentence; the new option also reads as a [feat] rather than part of this [fix].
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: The accessibility audit did not run on this pull request. It runs after merges to Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
|
Posted by Cindy's agent on her behalf. Parts of this PR re-implement behavior that already exists, or is being specified, as a shared part of core. Converging keeps one implementation per behavior:
This is about where the behavior lives, not about the PR's intent. |
|
Agreed: the fixture should not gate touch itself. In 0268a58, |
There was a problem hiding this comment.
The legacy form's treeshakeCompensation default and the constants shared across layers fix the reported defineConsts failures, but approval waits on a decision about the new public undefinedVariables: 'warn' | 'error' option and its default production-build warning, which no current spec covers. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, or by naming the spec that governs it; the author can do so as an engineering owner.
- Either way, keep
undefinedGeneratedVariablesinternal: exported from@astryxdesign/build/vite, it would ship as public API. - Either way, with the default
astryx/xprefixes a product reading an Astryx package's constants still getsvar(--x…), so re-key shared constants per prefix or narrow the changeset's claim. - If the option stays, the check must stop reporting a product's own
var(--xl)(declared in its app CSS) as a dropped declaration, which also fails that build under'error'. - If the option stays, honour
stylexOverrides.classNamePrefixin the zero-config check and declare the option in a[feat]changeset.
[Automated review]
…eset; current main) into the touch foundation
There was a problem hiding this comment.
The treeshakeCompensation default and the shared constant rules fix the reported defineConsts failures, but approval waits on a decision about the new public undefinedVariables: 'warn' | 'error' option and its default production-build warning, which no current spec covers. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, or by naming the spec that governs it; the author can do so as an engineering owner.
- Either way, keep
undefinedGeneratedVariablesinternal: exported from@astryxdesign/build/vite, it ships as public API. - Either way, with the default
astryx/xprefixes a product reading an Astryx package's constant still builds tovar(--x…), so narrow the[fix]changeset's library-side sentence or re-key shared constants for each prefix. - If the option stays, stop reporting a product's own
var(--xl)(declared in its app CSS) as a dropped declaration, and honourstylexOverrides.classNamePrefixin the zero-config check.
[Automated review]
…touch foundation
Source builds through astryxStylex (Storybook's too) lost defineConsts
values read from another file: a media-query key failed the build
("Invalid empty selector"), and a value shipped var(--x…) that nothing
declares, which browsers drop. The babel wrapper now defaults to
treeshakeCompensation, as @stylexjs/unplugin does, so the defining module
still loads, and every layer gets every constant under every class-name
prefix, with constant rules emitting no CSS. A production build warns,
naming the property and its rule, when its stylesheet reads a generated
property no emitted stylesheet declares (internal undefinedVariables.ts,
with no option); the prebuilt stylesheets' check reads the same
hash-shaped names.
d4e4c0b to
8f66f86
Compare
There was a problem hiding this comment.
No changes requested: the defineConsts restoration holds up, with sibling, library-side and package constants now resolving in both astryxStylex forms and Storybook's StyleX stylesheet unchanged byte for byte. The new build tests fail without the change and pass here. The always-on production-build warning has no spec record, and the engineering owners' choice of that behaviour, cited in the reply on this thread, settles it. Nothing further is needed from the author.
[Automated review]
…mator (#8076) Behavior-module PR: internal touch foundation, animator, press tracking Stacked on #8071, one commit on `main`, with no merge commits: review only this pull request's two commits, vjeux@0ddfa8937e and its test vjeux@91d49e1438. ## Why Touch components need Core's animator, press tracking and gesture host without making them public. ## What it absorbs, and why One solution, the internal touch foundation, so these close with a link here: - #8073 (closed): UIControl press tracking, its press profiles and the hooks. Everything else here rests on it. - #8340: the animator's start and hold. No frame shows where a motion is going, a call can wait for a presented frame, and in Safari a start from rest moves past a block of over two frames in the task that created it. It brings the held dip's load fixes from #8360 too. - #8641's rule (approved): a gesture that cancels itself while its finger moves keeps that finger until it lifts. ## Left out - Nothing here rests on the undecided mouse or pen drag selection (#8665), wheel ending (#8676) or an open owner ruling. - #8446's harness changes land with #8554. - The StyleX `defineConsts` build fix and the stylesheet's undefined-variable check stay in #8075. - `RotationGestureRecognizer` and `HoverGestureRecognizer` are not exported: nothing uses them, and rotation's threshold is not measured. - `paintPress` and its held state land with the action-group tracker, `useAnimator` with Lab's SearchField, and Core's internal entry points for Lab (#8562's change) with the first Lab component that uses them: each with its first user. ## What changes - Press tracking follows UIControl and is built by `createPressTracker`: the press clocks and profiles, `usePressTracker`, and release velocity on UIKit's filter (`spec:AST-100` FR1, FR2). - The animator holds the value on screen inline while a curve runs, starts a motion from rest when the browser commits it, offers `start: 'presented'` and `'commit'`, additive reversals and `handle.curve`. A browser proof counts no Layout or Paint while a spring plays, on the harness's rendering trace. - The motion modules and recognizers load in plain Node, with no StyleX module in their graph. ## How to check it 1. Run `pnpm exec vitest run scripts/motion-node-load.test.mjs`: the motion modules and recognizers load in a plain Node process. 2. In a component using `usePressTracker`, change `highlightDelay` while mounted: the next touch uses the new delay. 3. Run `pnpm test:interaction animator.interaction.browser.spec.ts` in Chromium and WebKit: a motion started right before a blocked main thread plays from its start after the block. ## Evidence - Local gates at 91d49e1: build, type check, `pnpm test:ui` (16,704), the node suites, lint, Storybook, and the motion and gesture interaction specs in Chromium (103) and WebKit (96); the held-dip, block and no-Layout-or-Paint proofs pass six times each at eight workers. ## Credit Co-authored-by: Cindy Zhang (her commits in #8073 and #8076). ## Scope - [x] Unrelated fixes, cleanup, and policy changes were removed or split. - [x] Public text and artifacts contain no internal Meta context. Behavior-module PR: LOC split waived per maintainer rule.
…eset; current main) into the touch foundation
…touch foundation
…eck reads the build's own CSS) into the touch foundation
… declares) into the touch foundation CI-Rerun: main's gate test (fixed in meta#8406) failed this head's test-node
…t as the build does) into the touch foundation
… constants) into the presented start
… declares) into the touch foundation
… into meta#8320 - Pan: meta#8060's FR14 removal of the scroll-edge handoff, with this line's opt-in early claim ('early', from the table) and its committed claim that survives a second finger; meta#8076's default-on copy of that test goes. - The UIKit table takes meta#8053's form (value and unit, sources in JSDoc) and keeps earlyClaimDistance in it, dated. - usePressTracker stays in its own module here. - The README's pan row keeps scrollVelocity() and loses scrollHandoff.
User impact
Source builds through
astryxStylex(Storybook's too) losedefineConstsvalues read from another file: a media-query key fails the build ("Invalid empty selector"); a value shipsvar(--x…)that nothing declares, which browsers drop. Plain@stylexjs/unpluginresolves both.Problem and solution fit
StyleX compiles a constant read to a placeholder,
var(--<prefix><hash>), that the final CSS pass replaces. Two defects break that:{stylexOptions}form, the babel wrapper's StyleX instance runs withouttreeshakeCompensation, so the TypeScript transform drops the now-unused import and the defining module never loads.Fix:
treeshakeCompensation: true, as the unplugin does.astryxStylexoption for it, so there is none.Expected behavior and authority
StyleX inlines
defineConstsvalues where used, media-query keys included, as@stylexjs/unplugindoes. The prebuilt stylesheets already fail on the condition the warning reports.Smallest restoration
packages/build/src/vite.ts, with the detector in internalundefinedVariables.ts(./viteexports onlyastryxStylexandLIGHTNINGCSS_TARGETS); an explicittreeshakeCompensationstill wins.Evidence
stylex-constsfixture (sibling, cross-layer and package constants as keys and values) fails the legacy form ("Invalid empty selector"); the zero-config form ships placeholders.min-height:52px,padding-top:13px,padding-bottom:17pxand both media rules.mainand with this change is byte-identical (astryx-stylex-9dbf4f45.css) and passes the check.classNamePrefix; an app's own--xl/--xlargeisn't reported. Open siblings perf(i18n): let a component carry only its own English strings #7357 and perf(i18n): every core component renders with its own English slice #7358 also changevite.ts; both merge with this change without a conflict there.Scope
[feat]changeset and adds no option.Testing
pnpm test:ui(16,446), the node suites, lint, Storybook,pnpm check:knowledgeand changeset coverage.pnpm exec vitest run packages/build scripts/build-css apps/storybook/.storybook/main.test.ts: 161 passed, 6 skipped (browser-only). This includes the new build tests (both forms, cross-layer, cross-prefix, the warning, a custom product prefix, an app's own properties) and the detector unit tests; each new test fails without the change.pnpm -F @astryxdesign/build build;tsc -p packages/build/tsconfig.build.json --noEmit.@astryxdesign/build, two changesets ([fix]for the correction,[feat]for the warning);pnpm check:changesetspasses.pnpm storybook:buildonmainand with this change: identical StyleX CSS (astryx-stylex-9dbf4f45.css), and the check reports nothing.pnpm -F @astryxdesign/sandbox build: no report either.