From 8e8b9ec8a391d9af9786c189fba1dcaea4f4e59d Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Wed, 9 Oct 2024 08:53:29 +0200 Subject: [PATCH] reduce code churn --- packages/router/src/rsc/SsrRouter.tsx | 12 ------------ packages/router/src/rsc/clientSsr.ts | 13 ------------- packages/router/src/rsc/utils.ts | 20 ++------------------ packages/vite/src/devFeServer.ts | 3 --- packages/vite/src/streaming/streamHelpers.ts | 2 -- 5 files changed, 2 insertions(+), 48 deletions(-) diff --git a/packages/router/src/rsc/SsrRouter.tsx b/packages/router/src/rsc/SsrRouter.tsx index 6c745b49f21f..402c0b005911 100644 --- a/packages/router/src/rsc/SsrRouter.tsx +++ b/packages/router/src/rsc/SsrRouter.tsx @@ -32,16 +32,4 @@ const LocationAwareRouter = ({ paramTypes, children }: RouterProps) => { Object.assign(namedRoutes, namedRoutesMap) return renderRoutesSsr(pathname) - - // return ( - // <> - // SSR Router renderRoutesSsr(pathname) - //

pathname:

- // {pathname} - //

namedRoutes:

- //
-  //       {JSON.stringify(Object.entries(namedRoutes), null, 2)}
-  //     
- // - // ) } diff --git a/packages/router/src/rsc/clientSsr.ts b/packages/router/src/rsc/clientSsr.ts index a8cbf2317f45..330122659cb4 100644 --- a/packages/router/src/rsc/clientSsr.ts +++ b/packages/router/src/rsc/clientSsr.ts @@ -169,19 +169,6 @@ export async function renderRoutesSsr(pathname: string) { console.log('Stream content:', logContent) })() - // if (Math.random() < 5) { - // const elementPromise = Promise.resolve( - // createElement( - // 'p', - // null, - // 'Hello from clientSsr.ts after renderToReadableStream', - // ), - // ) - - // rscCache.set(pathname, elementPromise) - // return elementPromise - // } - // We have to do this weird import thing because we need a version of // react-server-dom-webpack/client.edge that uses the same bundled version // of React as all the client components. Also see comment in diff --git a/packages/router/src/rsc/utils.ts b/packages/router/src/rsc/utils.ts index 4a8f44135466..fe51f5e82737 100644 --- a/packages/router/src/rsc/utils.ts +++ b/packages/router/src/rsc/utils.ts @@ -20,10 +20,7 @@ export function makeFilePath(path: string) { export async function importReact() { if (globalThis.__rwjs__vite_ssr_runtime) { const reactMod = await import('react') - console.log('rsc/utils.ts reactMod', reactMod.default) return reactMod.default - // return (await globalThis.__rwjs__vite_ssr_runtime.executeUrl('react')) - // .default } const distSsr = getPaths().web.distSsr @@ -40,12 +37,6 @@ export async function importReact() { */ export async function importRsdwClient() { if (globalThis.__rwjs__vite_ssr_runtime) { - // const rsdwcMod = await globalThis.__rwjs__vite_ssr_runtime.executeUrl( - // 'react-server-dom-webpack/client.edge', - // // '/Users/tobbe/dev/redwood/redwood/packages/router/vite-fix/react-server-dom-webpack.client.edge', - // ) - // - // return rsdwcMod.default const rsdwcMod = await import('react-server-dom-webpack/client.edge') return rsdwcMod.default } @@ -58,20 +49,13 @@ export async function importRsdwClient() { return (await import(rsdwClientPath)).default } -// TODO (RSC): Rename this method if we keep importing from react-dom/server.edge -export async function importRsdwServer() { +export async function importRsdwServer(): Promise { if (globalThis.__rwjs__vite_rsc_runtime) { - // return (await import('react-dom/server.edge')).default - // return (await import('react-server-dom-webpack/server.edge')).default const rsdwServerMod = await globalThis.__rwjs__vite_rsc_runtime.executeUrl( - // await globalThis.__rwjs__vite_rsc_server.ssrLoadModule( 'react-server-dom-webpack/server.edge', - // 'react-dom/server.edge', - // '/Users/tobbe/dev/redwood/redwood/packages/router/vite-fix/react-server-dom-webpack.server.edge', - // '../../vite-fix/react-server-dom-webpack.server.edge', ) - return rsdwServerMod.default as RSDWServerType + return rsdwServerMod.default } else { // We need to do this weird import dance because we need to import a version // of react-server-dom-webpack/server.edge that has been built with the diff --git a/packages/vite/src/devFeServer.ts b/packages/vite/src/devFeServer.ts index c073ec0f32b7..d0f6a02ac870 100644 --- a/packages/vite/src/devFeServer.ts +++ b/packages/vite/src/devFeServer.ts @@ -1,6 +1,3 @@ -// import path from 'node:path' -// import url from 'node:url' - import { createServerAdapter } from '@whatwg-node/server' import express from 'express' import type { HTTPMethod } from 'find-my-way' diff --git a/packages/vite/src/streaming/streamHelpers.ts b/packages/vite/src/streaming/streamHelpers.ts index 776c31facc3c..42c3c879f06c 100644 --- a/packages/vite/src/streaming/streamHelpers.ts +++ b/packages/vite/src/streaming/streamHelpers.ts @@ -303,8 +303,6 @@ async function importModule( isDev?: boolean, ) { if (isDev) { - console.log('asking vite to load module', mod) - if (mod === 'rd-server') { const loadedMod = await import('react-dom/server.edge') return loadedMod.default