@@ -135,10 +135,12 @@ export type RscPluginOptions = {
135135 /**
136136 * Custom environment configuration
137137 * @experimental
138- * @default { serverEnvironmentName : 'rsc' }
138+ * @default { browser: 'client', ssr: 'ssr', rsc : 'rsc' }
139139 */
140140 environment ?: {
141- serverEnvironmentName ?: string
141+ browser ?: string
142+ ssr ?: string
143+ rsc ?: string
142144 }
143145}
144146
@@ -974,8 +976,7 @@ export function vitePluginUseClient(
974976 // https://github.com/vitejs/vite/blob/4bcf45863b5f46aa2b41f261283d08f12d3e8675/packages/vite/src/node/utils.ts#L175
975977 const bareImportRE = / ^ (? ! [ a - z A - Z ] : ) [ \w @ ] (? ! .* : \/ \/ ) /
976978
977- const serverEnvironmentName =
978- useClientPluginOptions . environment ?. serverEnvironmentName ?? 'rsc'
979+ const serverEnvironmentName = useClientPluginOptions . environment ?. rsc ?? 'rsc'
979980
980981 return [
981982 {
@@ -1183,8 +1184,7 @@ export function vitePluginDefineEncryptionKey(
11831184 const KEY_PLACEHOLDER = '__vite_rsc_define_encryption_key'
11841185 const KEY_FILE = '__vite_rsc_encryption_key.js'
11851186
1186- const serverEnvironmentName =
1187- useServerPluginOptions . environment ?. serverEnvironmentName ?? 'rsc'
1187+ const serverEnvironmentName = useServerPluginOptions . environment ?. rsc ?? 'rsc'
11881188
11891189 return [
11901190 {
@@ -1244,8 +1244,9 @@ export function vitePluginUseServer(
12441244 'ignoredPackageWarnings' | 'enableActionEncryption' | 'environment'
12451245 > ,
12461246) : Plugin [ ] {
1247- const serverEnvironmentName =
1248- useServerPluginOptions . environment ?. serverEnvironmentName ?? 'rsc'
1247+ const serverEnvironmentName = useServerPluginOptions . environment ?. rsc ?? 'rsc'
1248+ const browserEnvironmentName =
1249+ useServerPluginOptions . environment ?. browser ?? 'browser'
12491250
12501251 return [
12511252 {
@@ -1341,8 +1342,8 @@ export function vitePluginUseServer(
13411342 const output = result ?. output
13421343 if ( ! output ?. hasChanged ( ) ) return
13431344 serverReferences [ getNormalizedId ( ) ] = id
1344- // TODO
1345- const name = this . environment . name === 'ssr' ? 'ssr ' : 'browser '
1345+ const name =
1346+ this . environment . name === browserEnvironmentName ? 'browser ' : 'ssr '
13461347 const importSource = resolvePackage ( `${ PKG_NAME } /react/${ name } ` )
13471348 output . prepend ( `import * as $$ReactClient from "${ importSource } ";\n` )
13481349 return {
0 commit comments