Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 8, 2025

Implement dynamic switching to user-installed react-server-dom-webpack (Issue #913)

Progress

  • Create a utility function to check if react-server-dom-webpack is installed in user's project
  • Add resolve logic to dynamically choose between user's package and vendored version
  • Update import paths in source files to use the dynamic resolution
  • Update plugin configuration to handle both scenarios
  • Update tsdown.config.ts to still vendor the package as fallback
  • Test builds work with vendored version (backward compatibility)
  • Test with user-installed react-server-dom-webpack
  • Document the new behavior

Implementation Details

The solution uses a Vite plugin-based approach:

  1. Source files import from @vitejs/plugin-rsc/vendor/react-server-dom/*
  2. The rsc:resolve-react-server-dom plugin intercepts these imports
  3. If user has react-server-dom-webpack installed, it redirects to react-server-dom-webpack/*
  4. Otherwise, it uses the vendored version as fallback
  5. The getReactServerDomImportPath() helper checks user's project for the package

This approach:

  • Maintains backward compatibility
  • Only runs resolution logic in Node.js (plugin context)
  • Doesn't affect browser builds
  • Uses standard Vite resolution mechanisms
Original prompt

implement @vitejs/vite-plugin-react/issues/913


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits October 8, 2025 06:21
Co-authored-by: hi-ogawa <4232207+hi-ogawa@users.noreply.github.com>
Co-authored-by: hi-ogawa <4232207+hi-ogawa@users.noreply.github.com>
@hi-ogawa
Copy link
Contributor

hi-ogawa commented Oct 8, 2025

Closing as #915 seems better

@hi-ogawa hi-ogawa closed this Oct 8, 2025
@hi-ogawa hi-ogawa deleted the copilot/implement-vite-plugin-react-fix branch October 8, 2025 06:32
Copilot AI requested a review from hi-ogawa October 8, 2025 06:32
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.

2 participants