From 645956290e519d3e37432741f047569824330d9b Mon Sep 17 00:00:00 2001 From: Daniel Choudhury Date: Mon, 27 Nov 2023 15:40:22 +0700 Subject: [PATCH] fix(streaming-ssr): Fixes running the streaming server using rw serve (#9558) --- .../vite/src/streaming/createReactStreamingHandler.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/streaming/createReactStreamingHandler.ts b/packages/vite/src/streaming/createReactStreamingHandler.ts index ebbf2cc4b1..2fd3356dc7 100644 --- a/packages/vite/src/streaming/createReactStreamingHandler.ts +++ b/packages/vite/src/streaming/createReactStreamingHandler.ts @@ -37,8 +37,10 @@ export const createReactStreamingHandler = async ( let fallbackDocumentImport: any if (isProd) { - entryServerImport = await import(rwPaths.web.distEntryServer) - fallbackDocumentImport = await import(rwPaths.web.distDocumentServer) + entryServerImport = await import(makeFilePath(rwPaths.web.distEntryServer)) + fallbackDocumentImport = await import( + makeFilePath(rwPaths.web.distDocumentServer) + ) } // @NOTE: we are returning a FetchAPI handler @@ -134,3 +136,8 @@ export const createReactStreamingHandler = async ( return reactResponse } } + +function makeFilePath(path: string): string { + // Without this, absolute paths can't be imported on Windows + return 'file:///' + path +}