Skip to content

fix(rsc): pass root importer explicitly instead of undefined for this.resolve in rsc:virtual-client-package #1295

Merged
hi-ogawa merged 5 commits into
vitejs:mainfrom
nihgwu:neo/fix-rsc-client-packages-outside-root
Jul 23, 2026
Merged

fix(rsc): pass root importer explicitly instead of undefined for this.resolve in rsc:virtual-client-package #1295
hi-ogawa merged 5 commits into
vitejs:mainfrom
nihgwu:neo/fix-rsc-client-packages-outside-root

Conversation

@nihgwu

@nihgwu nihgwu commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Description

@vitejs/plugin-rsc 0.5.28 added a project-root resolution check for client packages in #1277. In Rolldown builds, passing an undefined importer does not reliably represent the project root and can send importer-sensitive resolvers through a framework-owned dependency graph instead. In our case this caused runaway resolution and module-graph growth, ending in an OOM during the first RSC transform.

Resolve the package from the conventional /index.html importer explicitly. This preserves the #1277 behaviour: packages unavailable at the application root, or resolving to a different copy there, still fall back to the fully resolved module id.

Add a regression guard to the existing transitive client package fixture so build coverage fails if the root probe reaches another resolver without a concrete importer.

Reproduced with identical documentation content:

  • @vitejs/plugin-rsc 0.5.27: build succeeds
  • 0.5.28: build OOMs
  • patched 0.5.28: build succeeds

Related to #1247 and #1277.

@nihgwu

nihgwu commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@hi-ogawa can you have a look, latest version blocks our builds 🙏

@hi-ogawa

Copy link
Copy Markdown
Contributor

Doing this explicitly does make sense (I remember just seeing this on Vitest https://github.com/vitest-dev/vitest/blob/86c700ed8b77b7afb0ee9ec677ef8379f34a4bed/packages/vitest/src/node/plugins/vitestResolver.ts#L55) and fine to land nonetheless, but I'd appreciate more content on your setup.

Vite’s built-in resolver already resolves bare packages from the project root when the importer is undefined, so undefined and <root>/index.html should behave the same there. The reported difference therefore seems to come from another plugin handling this.resolve() first. Could you provide the full Vite config and plugin list from the failing setup so we can understand that interaction?

@hi-ogawa hi-ogawa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

for above

hi-ogawa and others added 4 commits July 23, 2026 09:06
@hi-ogawa hi-ogawa changed the title fix(rsc): handle client packages outside root fix(rsc): pass root importer explicitly instead of undefined for this.resolve in rsc:virtual-client-package Jul 23, 2026
@hi-ogawa
hi-ogawa merged commit 372a0e7 into vitejs:main Jul 23, 2026
20 checks passed
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