Skip to content

Commit

Permalink
reduce code churn
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe committed Oct 9, 2024
1 parent 3cf6b5c commit ae76616
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 50 deletions.
12 changes: 0 additions & 12 deletions packages/router/src/rsc/SsrRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,4 @@ const LocationAwareRouter = ({ paramTypes, children }: RouterProps) => {
Object.assign(namedRoutes, namedRoutesMap)

return renderRoutesSsr(pathname)

// return (
// <>
// SSR Router renderRoutesSsr(pathname)
// <p>pathname:</p>
// {pathname}
// <p>namedRoutes:</p>
// <pre>
// <code>{JSON.stringify(Object.entries(namedRoutes), null, 2)}</code>
// </pre>
// </>
// )
}
13 changes: 0 additions & 13 deletions packages/router/src/rsc/clientSsr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 2 additions & 18 deletions packages/router/src/rsc/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand All @@ -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<RSDWServerType> {
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
Expand Down
5 changes: 0 additions & 5 deletions packages/vite/src/devFeServer.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -53,8 +50,6 @@ async function createServer() {
app.use('*', (req, _res, next) => {
const fullUrl = getFullUrl(req, rscEnabled)

console.log('fullUrl', fullUrl)

const perReqStore = createPerRequestMap({
// Convert express headers to fetch header
headers: convertExpressHeaders(req.headersDistinct),
Expand Down
2 changes: 0 additions & 2 deletions packages/vite/src/streaming/streamHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ae76616

Please sign in to comment.