Skip to content

fix(rsc): resolve self package from project root#845

Merged
hi-ogawa merged 3 commits into
mainfrom
05-13-fix_rsc_use_virtual_to_inject_self_package_import
May 13, 2025
Merged

fix(rsc): resolve self package from project root#845
hi-ogawa merged 3 commits into
mainfrom
05-13-fix_rsc_use_virtual_to_inject_self_package_import

Conversation

@hi-ogawa

@hi-ogawa hi-ogawa commented May 13, 2025

Copy link
Copy Markdown
Owner

I noticed the issue when testing @hiogawa/vite-rsc on https://github.com/remix-run/react-router/tree/rsc. We get this error because "use client" transform injects import "@hiogawa/vite-rsc/rsc" to the files outside of playground/rsc-vite2, which in this case is linked dep packages/react-router/dist/development/index.mjs.

4:32:41 PM [vite] Internal server error: Cannot find module '@hiogawa/vite-rsc/rsc' imported from '/home/hiroshi/code/others/react-router/packages/react-router/dist/development/index.mjs'
      at fetchModule (file:///home/hiroshi/code/others/react-router/node_modules/.pnpm/vite@6.3.5_@types+node@22.14.0_jiti@2.4.2_lightningcss@1.29.3_terser@5.39.0_tsx@4.19.3_yaml@2.6.0/node_modules/vite/dist/node/chunks/dep-DBxKXgDP.js:46813:19)

By wrapping with virtual modules and redirect the resolution from root, it should be possible to support it.

hi-ogawa commented May 13, 2025

Copy link
Copy Markdown
Owner Author

@hi-ogawa hi-ogawa marked this pull request as ready for review May 13, 2025 08:00
Comment thread packages/rsc/src/plugin.ts Outdated
@hi-ogawa hi-ogawa changed the title fix(rsc): use virtual to inject self package import fix(rsc): resolve self package from project root May 13, 2025
@hi-ogawa hi-ogawa merged commit b24cecc into main May 13, 2025
@hi-ogawa hi-ogawa deleted the 05-13-fix_rsc_use_virtual_to_inject_self_package_import branch May 13, 2025 08:24
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.

1 participant