Skip to content
Discussion options

You must be logged in to vote

That's expected with import.meta.viteRsc.import(). During the production build the plugin finds these calls and emits each specifier as an entry of the target environment, so it has to be a string it can read from the source. Anything computed at runtime, like process.cwd(), can't be discovered (see the import.meta.viteRsc.import section of the plugin-rsc README).

The usual way around this in a framework is to let your Vite plugin do the resolving, since that's where you know the project root. Two options:

  1. A virtual module. Your RSC entry imports a fixed name, and your plugin maps it to the user's file:
// in your framework's Vite plugin
let root: string
export function myFramework(): P…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nickw1
Comment options

Answer selected by nickw1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants