Skip to content

Commit

Permalink
RSC: Rename to rscBuildForServer, and tweak some comments (#10102)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored Mar 3, 2024
1 parent 3432cd0 commit 80d9bfd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions packages/vite/src/buildRscFeServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { rscBuildAnalyze } from './rsc/rscBuildAnalyze'
import { rscBuildClient } from './rsc/rscBuildClient'
import { rscBuildClientEntriesMappings } from './rsc/rscBuildClientEntriesFile'
import { rscBuildCopyCssAssets } from './rsc/rscBuildCopyCssAssets'
import { rscBuildForServer } from './rsc/rscBuildForServer'
import { rscBuildRwEnvVars } from './rsc/rscBuildRwEnvVars'
import { rscBuildServer } from './rsc/rscBuildServer'

export const buildRscFeServer = async () => {
// Analyze all files and generate a list of RSCs and RSFs
Expand All @@ -13,7 +13,7 @@ export const buildRscFeServer = async () => {
const clientBuildOutput = await rscBuildClient(clientEntryFiles)

// Generate the server output
const serverBuildOutput = await rscBuildServer(
const serverBuildOutput = await rscBuildForServer(
clientEntryFiles,
serverEntryFiles,
{}
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/rsc/rscBuildClientEntriesFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from 'fs/promises'
import { getPaths } from '@redwoodjs/project-config'

import type { rscBuildClient } from './rscBuildClient'
import type { rscBuildServer } from './rscBuildServer'
import type { rscBuildForServer } from './rscBuildForServer'

/**
* RSC build. Step 5.
Expand All @@ -12,7 +12,7 @@ import type { rscBuildServer } from './rscBuildServer'
*/
export function rscBuildClientEntriesMappings(
clientBuildOutput: Awaited<ReturnType<typeof rscBuildClient>>,
serverBuildOutput: Awaited<ReturnType<typeof rscBuildServer>>,
serverBuildOutput: Awaited<ReturnType<typeof rscBuildForServer>>,
clientEntryFiles: Record<string, string>
) {
console.log('\n')
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/rsc/rscBuildCopyCssAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import path from 'path'

import { getPaths } from '@redwoodjs/project-config'

import type { rscBuildServer } from './rscBuildServer'
import type { rscBuildForServer } from './rscBuildForServer'

/**
* RSC build. Step 4.
* Copy CSS assets from server to client
*/
export function rscBuildCopyCssAssets(
serverBuildOutput: Awaited<ReturnType<typeof rscBuildServer>>
serverBuildOutput: Awaited<ReturnType<typeof rscBuildForServer>>
) {
console.log('\n')
console.log('4. rscBuildCopyCssAssets')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ import { rscTransformPlugin } from './rscVitePlugins'

/**
* RSC build. Step 3.
* buildFeServer -> buildRscFeServer -> rscBuildClient
* Generate the client bundle
* buildFeServer -> buildRscFeServer -> rscBuildForServer
* Generate the output to be used by the rsc worker (not the actual server!)
*/
export async function rscBuildServer(
export async function rscBuildForServer(
clientEntryFiles: Record<string, string>,
serverEntryFiles: Record<string, string>,
customModules: Record<string, string>
) {
console.log('\n')
console.log('3. rscBuildServer')
console.log('=================\n')
console.log('3. rscBuildForServer')
console.log('====================\n')

const rwPaths = getPaths()

Expand All @@ -38,7 +38,8 @@ export async function rscBuildServer(
...customModules,
}

const serverBuildOutput = await viteBuild({
// TODO (RSC): No redwood-vite plugin, add it in here
const rscServerBuildOutput = await viteBuild({
// ...configFileConfig,
root: rwPaths.web.src,
envPrefix: 'REDWOOD_ENV_',
Expand Down Expand Up @@ -103,10 +104,8 @@ export async function rscBuildServer(
build: {
ssr: true,
ssrEmitAssets: true,
// TODO (RSC) Change output dir to just dist. We should be "server
// first". Client components are the "special case" and should be output
// to dist/client
outDir: rwPaths.web.distRsc,
emptyOutDir: true, // Needed because `outDir` is not inside `root`
manifest: 'server-build-manifest.json',
rollupOptions: {
onwarn: onWarn,
Expand Down Expand Up @@ -150,9 +149,9 @@ export async function rscBuildServer(
},
})

if (!('output' in serverBuildOutput)) {
if (!('output' in rscServerBuildOutput)) {
throw new Error('Unexpected vite server build output')
}

return serverBuildOutput.output
return rscServerBuildOutput.output
}

0 comments on commit 80d9bfd

Please sign in to comment.