Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSC: Rename to rscBuildForServer, and tweak some comments #10102

Merged
merged 2 commits into from
Mar 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
RSC: Rename to rscBuildForServer, and tweak some comments
Tobbe committed Mar 3, 2024
commit dc100c6daebe1847b6d54db417817a9b27c3545b
4 changes: 2 additions & 2 deletions packages/vite/src/buildRscFeServer.ts
Original file line number Diff line number Diff line change
@@ -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
@@ -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,
{}
2 changes: 1 addition & 1 deletion packages/vite/src/rsc/rscBuildClientEntriesFile.ts
Original file line number Diff line number Diff line change
@@ -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 { rscBuildServer } from './rscBuildForServer'

/**
* RSC build. Step 5.
4 changes: 2 additions & 2 deletions packages/vite/src/rsc/rscBuildCopyCssAssets.ts
Original file line number Diff line number Diff line change
@@ -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')
Original file line number Diff line number Diff line change
@@ -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()

@@ -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_',
@@ -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,
@@ -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
}