File tree Expand file tree Collapse file tree 16 files changed +37
-21
lines changed Expand file tree Collapse file tree 16 files changed +37
-21
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ This package provides [React Server Components](https://react.dev/reference/rsc/
1111
1212## Getting Started  
1313
14- You can start  a project by copying an example locally  by:
14+ You can create  a starter project  by:
1515
1616``` sh 
1717npx degit vitejs/vite-plugin-react/packages/plugin-rsc/examples/starter my-app
Original file line number Diff line number Diff line change 2525    "@vitejs/test-dep-client-in-server2" : " file:./test-dep/client-in-server2" 
2626    "@vitejs/test-dep-server-in-client" : " file:./test-dep/server-in-client" 
2727    "@vitejs/test-dep-server-in-server" : " file:./test-dep/server-in-server" 
28+     "rsc-html-stream" : " ^0.0.7" 
2829    "tailwindcss" : " ^4.1.11" 
2930    "vite" : " ^7.0.4" 
3031    "vite-plugin-inspect" : " ^11.3.0" 
Original file line number Diff line number Diff line change 11import  *  as  ReactClient  from  '@vitejs/plugin-rsc/browser' 
2- import  {  getRscStreamFromHtml  }  from  '@vitejs/plugin-rsc/rsc-html-stream/browser' 
32import  React  from  'react' 
43import  *  as  ReactDOMClient  from  'react-dom/client' 
4+ import  {  rscStream  }  from  'rsc-html-stream/client' 
55import  type  {  RscPayload  }  from  './entry.rsc' 
66
77async  function  main ( )  { 
@@ -12,7 +12,7 @@ async function main() {
1212  // deserialize RSC stream back to React VDOM for CSR 
1313  const  initialPayload  =  await  ReactClient . createFromReadableStream < RscPayload > ( 
1414    // initial RSC stream is injected in SSR stream as <script>...FLIGHT_DATA...</script> 
15-     getRscStreamFromHtml ( ) , 
15+     rscStream , 
1616  ) 
1717
1818  // browser root component to (re-)render RSC payload as state 
Original file line number Diff line number Diff line change 1- import  {  injectRscStreamToHtml  }  from  '@vitejs/plugin-rsc/rsc-html-stream/ssr'  // helper API 
21import  *  as  ReactClient  from  '@vitejs/plugin-rsc/ssr'  // RSC API 
32import  React  from  'react' 
43import  type  {  ReactFormState  }  from  'react-dom/client' 
54import  *  as  ReactDOMServer  from  'react-dom/server.edge' 
5+ import  {  injectRSCPayload  }  from  'rsc-html-stream/server' 
66import  type  {  RscPayload  }  from  './entry.rsc' 
77
88export  async  function  renderHTML ( 
@@ -42,8 +42,9 @@ export async function renderHTML(
4242  let  responseStream : ReadableStream < Uint8Array >  =  htmlStream 
4343  if  ( ! options ?. debugNojs )  { 
4444    // initial RSC stream is injected in HTML stream as <script>...FLIGHT_DATA...</script> 
45+     // using utility made by devongovett https://github.com/devongovett/rsc-html-stream 
4546    responseStream  =  responseStream . pipeThrough ( 
46-       injectRscStreamToHtml ( rscStream2 ,  { 
47+       injectRSCPayload ( rscStream2 ,  { 
4748        nonce : options ?. nonce , 
4849      } ) , 
4950    ) 
Original file line number Diff line number Diff line change 11import  *  as  ReactClient  from  '@vitejs/plugin-rsc/browser' 
2- import  {  getRscStreamFromHtml  }  from  '@vitejs/plugin-rsc/rsc-html-stream/browser' 
32import  React  from  'react' 
43import  ReactDomClient  from  'react-dom/client' 
4+ import  {  rscStream  }  from  'rsc-html-stream/client' 
55import  {  RSC_POSTFIX ,  type  RscPayload  }  from  './shared' 
66
77async  function  hydrate ( ) : Promise < void >  { 
@@ -12,9 +12,8 @@ async function hydrate(): Promise<void> {
1212    setPayload ( payload ) 
1313  } 
1414
15-   const  initialPayload  =  await  ReactClient . createFromReadableStream < RscPayload > ( 
16-     getRscStreamFromHtml ( ) , 
17-   ) 
15+   const  initialPayload  = 
16+     await  ReactClient . createFromReadableStream < RscPayload > ( rscStream ) 
1817
1918  let  setPayload : ( v : RscPayload )  =>  void 
2019
Original file line number Diff line number Diff line change 1- import  {  injectRscStreamToHtml  }  from  '@vitejs/plugin-rsc/rsc-html-stream/ssr' 
21import  *  as  ReactClient  from  '@vitejs/plugin-rsc/ssr' 
32import  React  from  'react' 
43import  *  as  ReactDomServer  from  'react-dom/server.edge' 
4+ import  {  injectRSCPayload  }  from  'rsc-html-stream/server' 
55import  type  {  RscPayload  }  from  './shared' 
66
77export  async  function  renderHtml ( rscStream : ReadableStream < Uint8Array > )  { 
@@ -24,6 +24,6 @@ export async function renderHtml(rscStream: ReadableStream<Uint8Array>) {
2424  await  htmlStream . allReady 
2525
2626  let  responseStream : ReadableStream < Uint8Array >  =  htmlStream 
27-   responseStream  =  responseStream . pipeThrough ( injectRscStreamToHtml ( rscStream2 ) ) 
27+   responseStream  =  responseStream . pipeThrough ( injectRSCPayload ( rscStream2 ) ) 
2828  return  responseStream 
2929} 
Original file line number Diff line number Diff line change 11import  *  as  ReactClient  from  '@vitejs/plugin-rsc/browser' 
2- import  {  getRscStreamFromHtml  }  from  '@vitejs/plugin-rsc/rsc-html-stream/browser' 
32import  React  from  'react' 
43import  *  as  ReactDOMClient  from  'react-dom/client' 
4+ import  {  rscStream  }  from  'rsc-html-stream/client' 
55import  type  {  RscPayload  }  from  './entry.rsc' 
66
77async  function  main ( )  { 
@@ -12,7 +12,7 @@ async function main() {
1212  // deserialize RSC stream back to React VDOM for CSR 
1313  const  initialPayload  =  await  ReactClient . createFromReadableStream < RscPayload > ( 
1414    // initial RSC stream is injected in SSR stream as <script>...FLIGHT_DATA...</script> 
15-     getRscStreamFromHtml ( ) , 
15+     rscStream , 
1616  ) 
1717
1818  // browser root component to (re-)render RSC payload as state 
Original file line number Diff line number Diff line change 1- import  {  injectRscStreamToHtml  }  from  '@vitejs/plugin-rsc/rsc-html-stream/ssr'  // helper API 
21import  *  as  ReactClient  from  '@vitejs/plugin-rsc/ssr'  // RSC API 
32import  React  from  'react' 
43import  type  {  ReactFormState  }  from  'react-dom/client' 
54import  *  as  ReactDOMServer  from  'react-dom/server.edge' 
5+ import  {  injectRSCPayload  }  from  'rsc-html-stream/server' 
66import  type  {  RscPayload  }  from  './entry.rsc' 
77
88export  type  RenderHTML  =  typeof  renderHTML 
@@ -45,7 +45,7 @@ export async function renderHTML(
4545  if  ( ! options ?. debugNojs )  { 
4646    // initial RSC stream is injected in HTML stream as <script>...FLIGHT_DATA...</script> 
4747    responseStream  =  responseStream . pipeThrough ( 
48-       injectRscStreamToHtml ( rscStream2 ,  { 
48+       injectRSCPayload ( rscStream2 ,  { 
4949        nonce : options ?. nonce , 
5050      } ) , 
5151    ) 
Original file line number Diff line number Diff line change @@ -35,6 +35,9 @@ export default defineConfig({
3535          platform : 'neutral' , 
3636        } , 
3737      } , 
38+       optimizeDeps : { 
39+         include : [ 'turbo-stream' ] , 
40+       } , 
3841    } , 
3942    ssr : { 
4043      keepProcessEnv : false , 
@@ -43,6 +46,9 @@ export default defineConfig({
4346        // wrangler can deploy self-contained `dist/rsc` 
4447        outDir : './dist/rsc/ssr' , 
4548      } , 
49+       resolve : { 
50+         noExternal : true , 
51+       } , 
4652    } , 
4753  } , 
4854} ) 
Original file line number Diff line number Diff line change @@ -24,11 +24,11 @@ See [`@vitejs/plugin-rsc`](https://github.com/vitejs/vite-plugin-react/tree/main
2424  -  ` import.meta.viteRsc.loadModule ` 
2525-  [ ` ./src/framework/entry.ssr.tsx ` ] ( ./src/framework/entry.ssr.tsx ) 
2626  -  ` @vitejs/plugin-rsc/ssr ` 
27-   -  ` @vitejs/plugin-rsc/rsc-html-stream/ssr ` 
2827  -  ` import.meta.viteRsc.loadBootstrapScriptContent ` 
28+   -  ` rsc-html-stream/server ` 
2929-  [ ` ./src/framework/entry.browser.tsx ` ] ( ./src/framework/entry.browser.tsx ) 
3030  -  ` @vitejs/plugin-rsc/browser ` 
31-   -  ` @vitejs/plugin- rsc/rsc -html-stream/browser ` 
31+   -  ` rsc-html-stream/client  ` 
3232
3333## Notes  
3434
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments