Skip to content

fix(rsc): respect vite config root (fix #1126)#1133

Draft
vixalien wants to merge 2 commits intovitejs:mainfrom
vixalien:fix/rsc-root
Draft

fix(rsc): respect vite config root (fix #1126)#1133
vixalien wants to merge 2 commits intovitejs:mainfrom
vixalien:fix/rsc-root

Conversation

@vixalien
Copy link

@vixalien vixalien commented Mar 2, 2026

Description

cc @hi-ogawa I couldn't figure out how to add a test for this

Fix #1126

@vixalien
Copy link
Author

vixalien commented Mar 2, 2026

FYI, build still fails after this patch:

node ../runner/index.js
vite v7.1.6 building for production...
🧪 Using React Router's RSC Framework Mode (experimental)
✓ 47 modules transformed.
✗ Build failed in 1.33s
node:internal/modules/run_main:107
    triggerUncaughtException(
    ^

[rsc:virtual:vite-rsc/assets-manifest] Cannot convert undefined or null to object
    at Object.values (<anonymous>)
    at Object.generateBundle (file:///home/alien/sites/repro-react-router-rsc-runner/node_modules/.pnpm/@vitejs+plugin-rsc@0.5.21_react-dom@19.2.4_react@19.2.4__react@19.2.4_vite@7.1.6_@types_4b5722990c6258b73efc205a6ffdd2ee/node_modules/@vitejs/plugin-rsc/dist/plugin.js:558:36)
    at Object.handler (file:///home/alien/sites/repro-react-router-rsc-runner/node_modules/.pnpm/vite@7.1.6_@types+node@24.5.2_jiti@2.6.1_lightningcss@1.30.1/node_modules/vite/dist/node/chunks/dep-D5b0Zz6C.js:34064:13)
    at file:///home/alien/sites/repro-react-router-rsc-runner/node_modules/.pnpm/rollup@4.59.0/node_modules/rollup/dist/es/shared/node-entry.js:22571:40
    at processTicksAndRejections (node:internal/process/task_queues:104:5) {
  code: 'PLUGIN_ERROR',
  plugin: 'rsc:virtual:vite-rsc/assets-manifest',
  hook: 'generateBundle'
}

Node.js v25.7.0

@hi-ogawa hi-ogawa added the trigger: preview Trigger pkg.pr.new label Mar 2, 2026
@hi-ogawa hi-ogawa self-assigned this Mar 3, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 3, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@vitejs/plugin-react@1133
npm i https://pkg.pr.new/@vitejs/plugin-react-oxc@1133
npm i https://pkg.pr.new/@vitejs/plugin-rsc@1133
npm i https://pkg.pr.new/@vitejs/plugin-react-swc@1133

commit: 32104dd

@hi-ogawa hi-ogawa removed their assignment Mar 3, 2026
@hi-ogawa
Copy link
Contributor

hi-ogawa commented Mar 3, 2026

It looks like there are more moving parts related to root than I expected. We should aim for making examples/starter work by vite dev examples/starter from elsewhere probably.

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Mar 3, 2026

It turned out we already have related test case.

test.describe(() => {
const root = 'examples/e2e/temp/root'
test.beforeAll(async () => {
await setupInlineFixture({
src: 'examples/starter',
dest: root,
files: {
'vite.config.base.ts': { cp: 'vite.config.ts' },
'vite.config.ts': /* js */ `
import baseConfig from './vite.config.base.ts'
import path from "node:path";
baseConfig.root = "./custom-root";
for (const e of Object.values(baseConfig.environments)) {
e.build.rollupOptions.input.index = path.resolve(
'custom-root',
e.build.rollupOptions.input.index,
);
}
export default baseConfig;
`,
},
})
fs.mkdirSync(`${root}/custom-root`, { recursive: true })
fs.renameSync(`${root}/src`, `${root}/custom-root/src`)
fs.renameSync(`${root}/public`, `${root}/custom-root/public`)
})

Switching from process.cwd() to config.root would technically break this use case where config file lives in process.cwd() and the only app code is under config.root. We probably need to crawl both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

trigger: preview Trigger pkg.pr.new

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants