Skip to content

Conversation

hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Sep 16, 2025

Description

Currently client-only error shows up as rsc:virtual-client-package:

[rsc:virtual-client-package] 'client-only' cannot be imported in server build (importer: '/home/hiroshi/code/others/vite-plugin-react/packages/plugin-rsc/examples/starter/src/root.tsx', environment: rsc)

We can hard-code server-only/client-only here to skip this step, so the error gets surfaced as:

[rsc:validate-imports] 'client-only' cannot be imported in server build (importer: '/home/hiroshi/code/others/vite-plugin-react/packages/plugin-rsc/examples/starter/src/root.tsx', environment: rsc)

This isn't fool proof though since other plugins might use this.resolve too. Eventually we should look into to surfacing errors later stage so we have a knowledge of module graph. Tracked in #863.

@hi-ogawa hi-ogawa changed the title fix(rsc): improve client-only error message fix(rsc): improve server-only and client-only error message Sep 16, 2025
@hi-ogawa hi-ogawa changed the title fix(rsc): improve server-only and client-only error message fix(rsc): tweak server-only and client-only error message Sep 16, 2025
@hi-ogawa hi-ogawa marked this pull request as ready for review September 16, 2025 05:36
@hi-ogawa hi-ogawa changed the title fix(rsc): tweak server-only and client-only error message fix(rsc): show plugin name in server-only and client-only error message Sep 16, 2025
@hi-ogawa hi-ogawa changed the title fix(rsc): show plugin name in server-only and client-only error message fix(rsc): fix plugin name in client-only error message Sep 16, 2025
@hi-ogawa hi-ogawa changed the title fix(rsc): fix plugin name in client-only error message fix(rsc): fix plugin name in client-only error message Sep 16, 2025
@hi-ogawa hi-ogawa merged commit 0f2fbc7 into main Sep 16, 2025
22 of 23 checks passed
@hi-ogawa hi-ogawa deleted the 09-16-fix_rsc_tweak_client-only_error_message branch September 16, 2025 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant