File tree Expand file tree Collapse file tree 2 files changed +15
-13
lines changed
examples/browser-mode/src/framework Expand file tree Collapse file tree 2 files changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -9,8 +9,10 @@ export type RscPayload = {
99 formState ?: ReactFormState
1010}
1111
12+ declare let __vite_rsc_raw_import__ : ( id : string ) => Promise < unknown >
13+
1214export function initialize ( ) {
13- ReactServer . setRequireModule ( { load : ( id ) => import ( /* @vite -ignore */ id ) } )
15+ ReactServer . setRequireModule ( { load : ( id ) => __vite_rsc_raw_import__ ( id ) } )
1416}
1517
1618export async function fetchServer ( request : Request ) : Promise < Response > {
Original file line number Diff line number Diff line change @@ -157,6 +157,18 @@ export function vitePluginRscMinimal(): Plugin[] {
157157 server = server_
158158 } ,
159159 } ,
160+ {
161+ name : 'rsc:patch-browser-raw-import' ,
162+ transform : {
163+ order : 'post' ,
164+ handler ( code ) {
165+ if ( code . includes ( '__vite_rsc_raw_import__' ) ) {
166+ // inject dynamic import last to avoid Vite adding `?import` query to client references
167+ return code . replace ( '__vite_rsc_raw_import__' , 'import' )
168+ }
169+ } ,
170+ } ,
171+ } ,
160172 ...vitePluginRscCore ( ) ,
161173 ]
162174}
@@ -465,18 +477,6 @@ export default function vitePluginRsc(
465477 }
466478 } ,
467479 } ,
468- {
469- name : 'rsc:patch-browser-raw-import' ,
470- transform : {
471- order : 'post' ,
472- handler ( code ) {
473- if ( code . includes ( '__vite_rsc_raw_import__' ) ) {
474- // inject dynamic import last to avoid Vite adding `?import` query to client references
475- return code . replace ( '__vite_rsc_raw_import__' , 'import' )
476- }
477- } ,
478- } ,
479- } ,
480480 {
481481 // backward compat: `loadSsrModule(name)` implemented as `loadModule("ssr", name)`
482482 name : 'rsc:load-ssr-module' ,
You can’t perform that action at this time.
0 commit comments