You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[plugin rsc:validate-imports] .../react-aria-components/dist/exports/Calendar.mjs
Error: 'client-only' cannot be imported in server build ('rsc' environment):
imported by .../react-aria-components/dist/exports/Calendar.mjs
imported by .../@heroui/react/dist/components/calendar-year-picker/use-calendar-state.js
imported by .../@heroui/react/dist/components/calendar-year-picker/index.js
imported by .../@heroui/react/dist/index.js
imported by app/page.tsx
Note the failing leaf (Calendar) is never used by the page — the barrel
drags it in. Same failure via other leaves (e.g. toast/index.js -> toast-queue.js, which no subpath import can break).
Why false positive: both libraries ship sideEffects: false, so the
bundler drops every unused branch including the client-only marker —
Next.js builds this exact graph fine and serves it correctly in
production. The validator walks re-exports pre-shake, so any barrel ending
in a client-only-marked module fails even though the marker can never
evaluate at runtime.
Workarounds (verified): official subpaths for pure-barrel chains
(@heroui/react/skeleton); explicit "use client" boundary for chains
ending in real directive-less modules. Client bundles identical either way.
Suggested fix: teach the validator about sideEffects (skip subtrees
the bundler will drop), or validate post-tree-shake.
The build failure is because the RSC plugin does its checks before tree-shaking, which is where the import is removed. I've opened a PR there to propose moving the check to after tree-shaking - vitejs/vite-plugin-react#1511
Activity
james-elicx commentedon Oct 15, 2026
The build failure is because the RSC plugin does its checks before tree-shaking, which is where the import is removed. I've opened a PR there to propose moving the check to after tree-shaking - vitejs/vite-plugin-react#1511
fix(optimize-imports): support @heroui/react in Server Components (#4099