-
-
Notifications
You must be signed in to change notification settings - Fork 184
Description
Related plugins
Describe the bug
In a pnpm monorepo workspace setup, when @vitejs/plugin-rsc
is installed as a dependency of a custom package (not directly in the application, this package has a vite plugin used by application, and this vite plugin use vitejs/plugin-rsc plugin with hard-code entry), Vite fails to resolve the plugin's vendor dependencies unless nodeLinker: hoisted is configured in pnpm-workspace.yaml.
This is actually a compatibility issues of pnpm, but I believe that this might not work as we expect, so I create the minimal reproduction and open this issue, feel free to close it if it is not fit.
Reproduction
https://github.com/bloodnighttw/website-v6/tree/vite-issue-minimal
Steps to reproduce
- Clone the repository with this branch(vite-issue-minimal)
- Install dependencies (Don't forget to
rm -rf **/node_modules
if there has any) - Start the development server
pnpm dev
, you can run this in root, the first try may fail since some internal package hasn't been built yet. - Open the application in your browser with any pathname (e.g. /ouo, /test, /wtf)
You can see README.md of this branch to see more information
Note: if we set nodeLinker: hoisted
in pnpm-workspace.yaml
, it will work as expect, but if we don't, the issue happen.
System Info
System:
OS: Linux 6.15 Fedora Linux 42 (Workstation Edition)
CPU: (12) x64 12th Gen Intel(R) Core(TM) i5-12400
Memory: 20.71 GB / 31.08 GB
Container: Yes
Shell: 4.0.2 - /usr/bin/fish
Binaries:
Node: 22.18.0 - /usr/bin/node
npm: 10.9.3 - /usr/bin/npm
pnpm: 10.11.0 - ~/.local/share/pnpm/pnpm
Browser: Mozilla Zen 1.14.11b
Used Package Manager
pnpm
Logs
vite (dev with vite):
see vite.log (log too large, use file instead)
if we don't use --debug
, this wil show:
click to expand
Failed to resolve dependency: @vitejs/plugin-rsc/vendor/react-server-dom/client.browser, present in client 'optimizeDeps.include'
Failed to resolve dependency: @vitejs/plugin-rsc/vendor/react-server-dom/client.edge, present in ssr 'optimizeDeps.include'
Failed to resolve dependency: @vitejs/plugin-rsc/vendor/react-server-dom/server.edge, present in rsc 'optimizeDeps.include'
Failed to resolve dependency: @vitejs/plugin-rsc/vendor/react-server-dom/client.edge, present in rsc 'optimizeDeps.include'
the browser:
click to expand!
[vite] ping successful abdbd444-af41-445f-8f55-cda81bb54fa5:70:12
This page is in Quirks Mode. Page layout may be impacted. For Standards Mode use “<!DOCTYPE html>”. ouo
[vite] connecting... client:733:9
[vite] connected. client:827:12
Uncaught (in promise) ReferenceError: module is not defined
<anonymous> client.browser.js:6
client.browser.js:5:3
client.browser.js
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-server-dom-webpack-client.browser.production.js');
} else {
module.exports = require('./cjs/react-server-dom-webpack-client.browser.development.js');
}
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.