vitejs / vitejs/vite-plugin-react

react 3rd party lib crawling for automatic `noExternal` should take custom `root` into account

Open
#1,126 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

plugin: rsc
Dominant language
TypeScript
Stars
1.2k
Forks
269
Avg merge
1d 3h
Merged PRs (30d)
19

Description

Related plugins
Describe the bug

The plugin resolves framework dependencies from the process.cwd() instead of checking the config.root: https://vite.dev/config/shared-options#root

The potential fix would be to change the following line to config.root ?? process.cwd()

https://github.com/vitejs/vite-plugin-react/blob/db9221fcec0708466329e52c2b6a187b28f78421/packages/plugin-rsc/src/plugin.ts#L471

Reproduction

https://github.com/vixalien/repro-react-router-rsc-runner

Steps to reproduce
  1. Create an RSC app with the command: npx create-react-router@latest --template remix-run/react-router-templates/unstable_rsc-framework-mode
  2. In another folder/package create a simple JS file that uses the Vite JS API to run the RSC app by pointing vite to the previous directory
import { createServer } from "vite";                                                                                                                                                                          
                                                                                                                                                                                                              
const server = await createServer({                                                                                                                                                                           
  root: "../app",                                                                                                                                                                                             
});                                                                                                                                                                                                           
await server.listen();                                                                                                                                                                                        
                                                                                                                                                                                                              
server.printUrls();                                                                                                                                                                                           
server.bindCLIShortcuts({ print: true });                                                                                                                                                                     
System Info
System:
    OS: Linux 6.18 GNOME OS Nightly
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 19.50 GB / 30.64 GB
    Container: Yes
    Shell: 5.3.9 - /bin/bash
  Binaries:
    Node: 25.6.1 - /home/alien/.local/share/mise/installs/node/25.6.1/bin/node
    Yarn: 4.12.0 - /home/alien/.local/share/mise/installs/yarn/4.12.0/bin/yarn
    npm: 11.9.0 - /home/alien/.local/share/mise/installs/node/25.6.1/bin/npm
    pnpm: 10.30.1 - /home/alien/.local/share/mise/installs/pnpm/10.30.1/pnpm
    Deno: 2.6.10 - /home/alien/.local/share/mise/installs/deno/2.6.10/bin/deno
Used Package Manager

pnpm

Logs

No response

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at packages/plugin-rsc/src/plugin.ts around line 471, where framework dependencies are crawled, and compare the configured root with process.cwd(). Reproduce the issue using the linked react-router RSC example and a Vite server configured with root: "../app". Done means dependency resolution uses the configured root while preserving behavior when no custom root is provided.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript, vite
Domain
frontend, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.