Skip to content

fix: comprehensive 'use client' directives + dist check - #815

Merged
cixzhang merged 3 commits into
mainfrom
navi/fix/use-client-complete
Mar 22, 2026
Merged

cixzhang merged 3 commits into
mainfrom
navi/fix/use-client-complete

Conversation

@cixzhang

@cixzhang cixzhang commented Mar 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds 'use client' to all 95 source files using React client APIs. This ensures tsup shared chunks preserve the directive (tsup only propagates it when ALL files in a chunk have it).

Also adds scripts/check-use-client.mjs — a source-level check that verifies all source files using client APIs have the directive. Run with node scripts/check-use-client.mjs.

Why not tsup banner?

banner: { js: '"use client";' } would force ALL output files to be client-only, including pure server-compatible modules like theme tokens. The correct fix is ensuring source files have the directive so tsup can propagate it naturally.

Root cause

PR #812 added the directive to 10 files but missed the rest. When a shared chunk contained a mix of files with and without the directive, tsup dropped it — causing Next.js to error on createContext.

What changed

  • 85 files from the original audit list needed the directive (2 already had it from fix: add missing 'use client' directives #812)
  • 10 additional files discovered during validation: SegmentedControl (3), TreeList (2), SideNav (2), Selector/hooks, AppShell/MobileContext, hooks/useOverflow
  • New script: scripts/check-use-client.mjs checks all source files
  • CI integration: Deferred (requires workflow scope token) — add node scripts/check-use-client.mjs step after build

Tests

All 1850 tests pass. Check script validates clean: ✅ 247 source files checked.

Fixes sandbox build failure in #806.


Add 'use client' to all 95 source files using React client APIs.
This ensures tsup shared chunks can preserve the directive (tsup
only propagates it when ALL files in a chunk have it).

Also adds scripts/check-use-client.mjs — a CI check that verifies
all source files using client APIs have the directive.

Files from original list (87): 85 needed the directive, 2 already
had it from PR #812. Found 10 additional files that were also
missing it (SegmentedControl, TreeList, SideNav, Selector/hooks,
AppShell/MobileContext, hooks/useOverflow).

Note: CI workflow integration deferred — requires workflow scope
token. Run 'node scripts/check-use-client.mjs' after build.
@cixzhang cixzhang added the bug Something isn't working label Mar 22, 2026
@cixzhang
cixzhang requested a review from josephfarina as a code owner March 22, 2026 04:45
@cixzhang cixzhang added the bug Something isn't working label Mar 22, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 22, 2026
@github-actions

github-actions Bot commented Mar 22, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

AppShell · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 68.6KB N/A
Lines of Code N/A 551 -
Complexity N/A Very High (88) -
AspectRatio · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 9.3KB N/A
Lines of Code N/A 53 -
Complexity N/A Low (1) -
Avatar · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 16.4KB N/A
Lines of Code N/A 330 -
Complexity N/A High (29) -
Badge · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 9.9KB N/A
Lines of Code N/A 143 -
Complexity N/A Low (3) -
Banner · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 50.8KB N/A
Lines of Code N/A 287 -
Complexity N/A High (21) -
Breadcrumbs · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 13.2KB N/A
Lines of Code N/A 283 -
Complexity N/A Medium (13) -
Button · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 32.2KB N/A
Lines of Code N/A 300 -
Complexity N/A High (22) -
Calendar · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 70.3KB N/A
Lines of Code N/A 937 -
Complexity N/A Very High (128) -
Card · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 21.1KB N/A
Lines of Code N/A 114 -
Complexity N/A Medium (10) -
Center · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 9.9KB N/A
Lines of Code N/A 72 -
Complexity N/A Medium (8) -
CheckboxInput · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 46.0KB N/A
Lines of Code N/A 368 -
Complexity N/A Very High (34) -
Collapsible · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 17.5KB N/A
Lines of Code N/A 244 -
Complexity N/A High (18) -
DateInput · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 92.1KB N/A
Lines of Code N/A 388 -
Complexity N/A Very High (47) -
Dialog · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 63.2KB N/A
Lines of Code N/A 323 -
Complexity N/A Very High (38) -
Divider · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 10.6KB N/A
Lines of Code N/A 147 -
Complexity N/A Medium (9) -
DropdownMenu · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 61.6KB N/A
Lines of Code N/A 511 -
Complexity N/A Very High (63) -
Field · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 35.8KB N/A
Lines of Code N/A 510 -
Complexity N/A High (19) -
FormLayout · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 10.0KB N/A
Lines of Code N/A 88 -
Complexity N/A Low (3) -
Grid · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 13.5KB N/A
Lines of Code N/A 316 -
Complexity N/A High (22) -
HoverCard · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 21.9KB N/A
Lines of Code N/A 440 -
Complexity N/A Very High (44) -
Icon · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 16.1KB N/A
Lines of Code N/A 304 -
Complexity N/A Low (4) -
Layer · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 42.4KB N/A
Lines of Code N/A 273 -
Complexity N/A High (30) -
Layout · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 42.0KB N/A
Lines of Code N/A 901 -
Complexity N/A Very High (66) -
Link · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 41.0KB N/A
Lines of Code N/A 228 -
Complexity N/A Medium (11) -
List · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 15.2KB N/A
Lines of Code N/A 391 -
Complexity N/A Very High (35) -
MobileNav · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 55.1KB N/A
Lines of Code N/A 322 -
Complexity N/A Very High (32) -
MoreMenu · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 60.1KB N/A
Lines of Code N/A 374 -
Complexity N/A Very High (49) -
NumberInput · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 41.8KB N/A
Lines of Code N/A 357 -
Complexity N/A Very High (52) -
OverflowList · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 15.0KB N/A
Lines of Code N/A 163 -
Complexity N/A High (19) -
Pagination · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 85.8KB N/A
Lines of Code N/A 392 -
Complexity N/A Very High (50) -
Popover · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 25.1KB N/A
Lines of Code N/A 473 -
Complexity N/A Very High (42) -
PowerSearch · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 250.8KB N/A
Lines of Code N/A 3045 -
Complexity N/A Very High (296) -
ProgressBar · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 12.4KB N/A
Lines of Code N/A 224 -
Complexity N/A Medium (13) -
RadioList · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 41.4KB N/A
Lines of Code N/A 418 -
Complexity N/A High (30) -
Section · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 21.7KB N/A
Lines of Code N/A 163 -
Complexity N/A High (16) -
SegmentedControl · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 14.6KB N/A
Lines of Code N/A 303 -
Complexity N/A High (27) -
Selector · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 72.2KB N/A
Lines of Code N/A 928 -
Complexity N/A Very High (47) -
SideNav · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 99.8KB N/A
Lines of Code N/A 1491 -
Complexity N/A Very High (146) -
Skeleton · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 10.7KB N/A
Lines of Code N/A 105 -
Complexity N/A Low (3) -
Slider · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 48.4KB N/A
Lines of Code N/A 626 -
Complexity N/A Very High (75) -
Spinner · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 15.1KB N/A
Lines of Code N/A 110 -
Complexity N/A Medium (8) -
Switch · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 46.4KB N/A
Lines of Code N/A 328 -
Complexity N/A Very High (33) -
TabList · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 35.4KB N/A
Lines of Code N/A 559 -
Complexity N/A High (26) -
Table · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 61.6KB N/A
Lines of Code N/A 819 -
Complexity N/A Very High (54) -
Text · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 33.1KB N/A
Lines of Code N/A 487 -
Complexity N/A Very High (44) -
TextArea · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 45.9KB N/A
Lines of Code N/A 235 -
Complexity N/A High (27) -
TextInput · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 45.7KB N/A
Lines of Code N/A 222 -
Complexity N/A High (25) -
TimeInput · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 54.7KB N/A
Lines of Code N/A 384 -
Complexity N/A Very High (54) -
Tokenizer · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 59.2KB N/A
Lines of Code N/A 372 -
Complexity N/A Very High (50) -
Tooltip · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 20.9KB N/A
Lines of Code N/A 415 -
Complexity N/A Very High (47) -
TopNav · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 99.1KB N/A
Lines of Code N/A 1512 -
Complexity N/A Very High (92) -
TreeList · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 25.7KB N/A
Lines of Code N/A 685 -
Complexity N/A Very High (62) -
Typeahead · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A 58.5KB N/A
Lines of Code N/A 888 -
Complexity N/A Very High (121) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 602.8KB 636.1KB 117.7KB

Accessibility Audit

Status: 11 accessibility violation(s) found — 1 critical, 8 serious, 2 moderate.

XDSBanner - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/15 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
XDSCalendar - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 10/11 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
XDSCheckboxInput - 1 issue(s)
  • 🟠 serious: Ensure ARIA attributes are used as described in the specification of the element's role
    • Rule: aria-conditional-attr · Affects 2/16 stories · Learn more
    • WCAG: 4.1.2 (Level A)
XDSIcon - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/16 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
XDSLayout - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 4/10 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
XDSList - 1 issue(s)
  • 🔴 critical: Ensure an element's role supports its ARIA attributes
    • Rule: aria-allowed-attr · Affects 1/10 stories · Learn more
    • WCAG: 4.1.2 (Level A)
XDSPagination - 1 issue(s)
  • 🟡 moderate: Ensure landmarks are unique
    • Rule: landmark-unique · Affects 1/14 stories · Learn more
XDSSideNav - 1 issue(s)
  • 🟠 serious: Ensure links have discernible text
    • Rule: link-name · Affects 1/8 stories · Learn more
    • WCAG: 2.4.4, 4.1.2 (Level A)
XDSTabList - 1 issue(s)
  • 🟡 moderate: Ensure landmarks are unique
    • Rule: landmark-unique · Affects 1/5 stories · Learn more
Selection - 1 issue(s)
  • 🟠 serious: Ensure ARIA attributes are used as described in the specification of the element's role
    • Rule: aria-conditional-attr · Affects 1/7 stories · Learn more
    • WCAG: 4.1.2 (Level A)
XDSText - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/22 stories · Learn more
    • WCAG: 1.4.3 (Level AA)

Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@cixzhang
cixzhang merged commit b4e1fa6 into main Mar 22, 2026
13 checks passed
@cixzhang
cixzhang deleted the navi/fix/use-client-complete branch April 9, 2026 14:33
cixzhang added a commit that referenced this pull request Apr 26, 2026
* fix: comprehensive 'use client' directives + source check

Add 'use client' to all 95 source files using React client APIs.
This ensures tsup shared chunks can preserve the directive (tsup
only propagates it when ALL files in a chunk have it).

Also adds scripts/check-use-client.mjs — a CI check that verifies
all source files using client APIs have the directive.

Files from original list (87): 85 needed the directive, 2 already
had it from PR #812. Found 10 additional files that were also
missing it (SegmentedControl, TreeList, SideNav, Selector/hooks,
AppShell/MobileContext, hooks/useOverflow).

Note: CI workflow integration deferred — requires workflow scope
token. Run 'node scripts/check-use-client.mjs' after build.

* fix: splitting: false + clean up duplicate use client directives

* fix: restore XDSAppShell.tsx (accidentally emptied during cleanup)

---------

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Jun 21, 2026
* fix: comprehensive 'use client' directives + source check

Add 'use client' to all 95 source files using React client APIs.
This ensures tsup shared chunks can preserve the directive (tsup
only propagates it when ALL files in a chunk have it).

Also adds scripts/check-use-client.mjs — a CI check that verifies
all source files using client APIs have the directive.

Files from original list (87): 85 needed the directive, 2 already
had it from PR #812. Found 10 additional files that were also
missing it (SegmentedControl, TreeList, SideNav, Selector/hooks,
AppShell/MobileContext, hooks/useOverflow).

Note: CI workflow integration deferred — requires workflow scope
token. Run 'node scripts/check-use-client.mjs' after build.

* fix: splitting: false + clean up duplicate use client directives

* fix: restore XDSAppShell.tsx (accidentally emptied during cleanup)

---------

Co-authored-by: Navi <[email protected]>
cixzhang added a commit that referenced this pull request Jun 21, 2026
* fix: comprehensive 'use client' directives + source check

Add 'use client' to all 95 source files using React client APIs.
This ensures tsup shared chunks can preserve the directive (tsup
only propagates it when ALL files in a chunk have it).

Also adds scripts/check-use-client.mjs — a CI check that verifies
all source files using client APIs have the directive.

Files from original list (87): 85 needed the directive, 2 already
had it from PR #812. Found 10 additional files that were also
missing it (SegmentedControl, TreeList, SideNav, Selector/hooks,
AppShell/MobileContext, hooks/useOverflow).

Note: CI workflow integration deferred — requires workflow scope
token. Run 'node scripts/check-use-client.mjs' after build.

* fix: splitting: false + clean up duplicate use client directives

* fix: restore XDSAppShell.tsx (accidentally emptied during cleanup)

---------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant