Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 21, 2025

  • Understand issue Add example which runs react-server conditioned environment with module runner on browser #932 requirements
  • Analyze existing examples (no-ssr and browser-mode)
  • Build the project successfully
  • Create browser-mode2 directory structure
  • Copy and adapt source files from browser-mode
  • Create vite.config.ts that uses import rsc from '@vitejs/plugin-rsc'
  • Modify entry files to support module runner approach
  • Create package.json with proper dependencies
  • Dev server starts successfully
  • Simplified rscBrowserMode2Plugin per code review feedback
  • Run security check (no vulnerabilities found)

Changes Made

Simplified rscBrowserMode2Plugin to only include essential browser-mode specific configuration:

  • /@vite/invoke-react-client middleware for module runner communication
  • Virtual module resolution for load-client
  • Minimal react_client environment configuration
  • Hot reload handler for react_client environment

Removed redundant configuration that the full RSC plugin already handles:

  • Client environment conditions and optimizeDeps (handled by RSC plugin)
  • Builder configuration
  • Define statements
  • Most environment-specific settings

This aligns with the architecture where the full RSC plugin handles core RSC functionality, and the custom plugin only adds browser-mode specific features.

Original prompt

fix #932


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Comment on lines +95 to +110
configureServer(server) {
server.middlewares.use(async (req, res, next) => {
const url = new URL(req.url ?? '/', 'https://any.local')
if (url.pathname === '/@vite/invoke-react-client') {
const payload = JSON.parse(url.searchParams.get('data')!)
const result =
await server.environments['react_client']!.hot.handleInvoke(
payload,
)
res.setHeader('Content-Type', 'application/json')
res.end(JSON.stringify(result))
return
}
next()
})
},
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot rscBrowserMode2Plugin shouldn't be needed except /@vite/invoke-rsc middleware.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simplified rscBrowserMode2Plugin to only include the essential browser-mode specific parts:

  • /@vite/invoke-react-client middleware
  • Virtual module for load-client
  • Minimal react_client environment config
  • Hot reload handler

Removed redundant config that the full RSC plugin already handles. (commit: simplified)

Copilot AI changed the title [WIP] Fix issue with Vite plugin for React Add browser-mode2 example combining full RSC plugin with browser-mode execution Oct 21, 2025
Copilot AI requested a review from hi-ogawa October 21, 2025 13:22
Copilot finished work on behalf of hi-ogawa October 21, 2025 13:22
Copilot finished work on behalf of hi-ogawa October 21, 2025 13:30
@hi-ogawa
Copy link
Contributor

#933 got right eventually

@hi-ogawa hi-ogawa closed this Oct 21, 2025
@hi-ogawa hi-ogawa deleted the copilot/fix-issue-932 branch October 21, 2025 13:41
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.

Add example which runs react-server conditioned environment with module runner on browser

2 participants