You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This allows importing `ssr` environment module specified by `environments.ssr.build.rollupOptions.input[entryName]` inside `rsc` environment and vice versa.
229
+
This allows importing `ssr` environment module specified by `environments.ssr.build.rollupOptions.input[entryName]` inside `rsc` environment and vice versa. When `entryName` is omitted, the function automatically uses the single entry from the target environment's `rollupOptions.input`.
230
230
231
231
During development, by default, this API assumes both `rsc` and `ssr` environments execute under the main Vite process as `RunnableDevEnvironment`. Internally, `loadModule` uses the global `__VITE_ENVIRONMENT_RUNNER_IMPORT__` function to import modules in the target environment (see [`__VITE_ENVIRONMENT_RUNNER_IMPORT__`](#__vite_environment_runner_import__) below).
232
232
@@ -550,7 +550,7 @@ Types for global API are defined in `@vitejs/plugin-rsc/types`. For example, you
Copy file name to clipboardExpand all lines: packages/plugin-rsc/src/plugins/utils.ts
+49-7Lines changed: 49 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
-
importassertfrom'node:assert'
2
1
import{createHash}from'node:crypto'
2
+
importpathfrom'node:path'
3
3
import{
4
4
normalizePath,
5
5
typePlugin,
@@ -62,17 +62,59 @@ export function normalizeRelativePath(s: string): string {
62
62
63
63
exportfunctiongetEntrySource(
64
64
config: Pick<ResolvedConfig,'build'>,
65
-
name: string='index',
65
+
name?: string,
66
66
): string{
67
67
constinput=config.build.rollupOptions.input
68
-
assert(
68
+
if(!name){
69
+
returngetFallbackRollupEntry(input).source
70
+
}
71
+
if(
69
72
typeofinput==='object'&&
70
-
!Array.isArray(input)&&
71
-
nameininput&&
72
-
typeofinput[name]==='string',
73
+
!Array.isArray(input)&&
74
+
nameininput&&
75
+
typeofinput[name]==='string'
76
+
){
77
+
returninput[name]
78
+
}
79
+
thrownewError(
73
80
`[vite-rsc:getEntrySource] expected 'build.rollupOptions.input' to be an object with a '${name}' property that is a string, but got ${JSON.stringify(input)}`,
0 commit comments