Skip to content

Conversation

@hi-ogawa
Copy link
Owner

@hi-ogawa hi-ogawa commented Jun 22, 2025

This virtual trick might be a bit of novelty. But I'm not sure if this is guaranteed to work, so let's show a warning for now. (Also we should say such package should be in optimizeDeps.exclude)

4:42:44 PM [vite] (rsc) warning: [vite-rsc] detected an internal client boundary created by a package imported on rsc environment
  Plugin: rsc:use-client
  File: /home/hiroshi/code/personal/vite-plugins/node_modules/.pnpm/@vitejs+test-dep-client-in-server@file+packages+rsc+examples+basic+test-dep+client-in-server_react@19.1.0/node_modules/@vitejs/test-dep-client-in-server/client.js?v=b7fff1c3

todo

Copy link
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@hi-ogawa hi-ogawa marked this pull request as ready for review June 22, 2025 07:27
@hi-ogawa hi-ogawa changed the title fix: tolerate internal client boundary of server package fix: support internal client boundary of server package Jun 22, 2025
@hi-ogawa hi-ogawa changed the title fix: support internal client boundary of server package fix: handle client boundary created by server package during dev Jun 22, 2025
@hi-ogawa hi-ogawa changed the title fix: handle client boundary created by server package during dev fix: correctly resolve client boundary created by server package during dev Jun 22, 2025
@hi-ogawa hi-ogawa requested a review from Copilot June 22, 2025 09:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a mechanism to detect and proxy “client boundary” imports created by server-only packages in development, emits a warning when they occur, and updates the basic example to exclude those packages and test the behavior.

  • Detects ?v= imports without a known package source in dev, warns, and creates a virtual proxy module
  • Introduces a new inline plugin rsc:virtual-client-in-server-package to load proxied client modules
  • Updates the basic example config, local test dependencies, routes, and adds an E2E test for the client-in-server scenario

Reviewed Changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/rsc/src/plugin.ts Add detection of unexpected client boundaries, emit warning, and register a virtual proxy plugin for ?v= imports in dev
packages/rsc/examples/basic/vite.config.ts Recommend excluding client-in-server test packages via optimizeDeps.exclude
packages/rsc/examples/basic/test-dep/client-in-server* Add local test packages (client-in-server and client-in-server2) simulating server-side imports of client modules
packages/rsc/examples/basic/src/routes/client-in-server/* Add server and client components to exercise the client-in-server proxy in the example app
packages/rsc/examples/basic/src/routes/root.tsx Render the new TestClientInServer component in the example app
packages/rsc/examples/basic/package.json Include the two local test-dep packages
packages/rsc/examples/basic/e2e/basic.test.ts Add an E2E test for verifying the client-in-server proxy behavior
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

@hi-ogawa hi-ogawa merged commit ff6958f into main Jun 22, 2025
12 checks passed
@hi-ogawa hi-ogawa deleted the 06-22-fix_tolerate_internal_client_boundary_of_server_package branch June 22, 2025 09:59
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.

support ai/rsc package

2 participants