Skip to content

Conversation

@hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Jan 13, 2026

Summary

  • Add vitePluginResolvedIdProxy() to handle virtual modules with \0 prefix in import specifiers
  • Add toResolvedIdProxy() / fromResolvedIdProxy() / withResolvedIdProxy() helpers
  • Add e2e tests for virtual modules (use client, CSS)

How it works

Virtual modules in Vite use \0 prefix internally, but this cannot be used as an import specifier. The resolved-id proxy wraps these IDs:

toResolvedIdProxy("\0virtual:test.css")
  => "virtual:vite-rsc/resolved-id/__x00__virtual:test.css"

fromResolvedIdProxy("virtual:vite-rsc/resolved-id/__x00__virtual:test.css")
  => "\0virtual:test.css"

Known limitation

Virtual CSS modules don't work in dev mode - Vite adds ?direct query for CSS requests, but the query is lost during proxy resolution, causing JS wrapper to be returned instead of raw CSS. This is marked as TODO in tests.

🤖 Generated with Claude Code

hi-ogawa and others added 6 commits January 13, 2026 17:47
- Add tests for virtual module with 'use client' directive
- Add tests for virtual CSS modules in server components
- Add tests for virtual CSS modules imported in client components
- Add virtual module with 'use client' directive
- Add virtual CSS modules (server and client)
- Add @nojs test to verify no FOUC
…t references

Virtual modules use \0 prefix internally in Vite, but this cannot be used
as an import specifier when generating client reference code. Strip the
prefix to allow virtual modules with 'use client' directive to work correctly.
Introduce vitePluginResolvedIdProxy() to handle virtual modules with \0 prefix
in import specifiers and CSS hrefs. This provides a cleaner alternative to
stripping the \0 prefix directly.

Input/Output:
- toResolvedIdProxy("\0virtual:test.css")
  => "virtual:vite-rsc/resolved-id/__x00__virtual:test.css"
- fromResolvedIdProxy("virtual:vite-rsc/resolved-id/__x00__virtual:test.css")
  => "\0virtual:test.css"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Virtual CSS modules return JS wrapper instead of raw CSS in dev mode.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@hi-ogawa hi-ogawa changed the title test(plugin-rsc): add e2e tests for virtual modules feat(plugin-rsc): add resolved-id proxy for virtual modules Jan 13, 2026
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@hi-ogawa hi-ogawa changed the title feat(plugin-rsc): add resolved-id proxy for virtual modules fix(rsc): add resolved-id proxy for virtual modules Jan 13, 2026
@hi-ogawa hi-ogawa changed the title fix(rsc): add resolved-id proxy for virtual modules fix(rsc): fix virtual "use client" moudle (add resolved-id proxy for virtual modules) Jan 14, 2026
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