Skip to content

Commit

Permalink
RSC: Clean up overly verbose logging (redwoodjs#10536)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe committed May 3, 2024
1 parent e1e9171 commit b862c6e
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 19 deletions.
3 changes: 2 additions & 1 deletion packages/vite/src/clientSsr.ts
Expand Up @@ -61,10 +61,11 @@ function resolveClientEntryForProd(
const absoluteClientEntries = Object.fromEntries(
Object.entries(clientEntries).map(([key, val]) => {
let fullKey = path.join(baseDir, key)

if (process.platform === 'win32') {
fullKey = fullKey.replaceAll('\\', '/')
}
console.log('fullKey', fullKey, 'value', basePath + path.sep + val)

return [fullKey, basePath + path.sep + val]
}),
)
Expand Down
2 changes: 0 additions & 2 deletions packages/vite/src/rsc/rscBuildAnalyze.ts
Expand Up @@ -94,8 +94,6 @@ export async function rscBuildAnalyze() {
}),
)

console.log('clientEntryFileSet', Array.from(clientEntryFileSet))
console.log('serverEntryFileSet', Array.from(serverEntryFileSet))
console.log('clientEntryFiles', clientEntryFiles)
console.log('serverEntryFiles', serverEntryFiles)

Expand Down
8 changes: 4 additions & 4 deletions packages/vite/src/rsc/rscBuildEntriesFile.ts
Expand Up @@ -45,12 +45,10 @@ export async function rscBuildEntriesMappings(
)?.fileName

if (entryFile) {
console.log('entryFile', entryFile)
if (process.platform === 'win32') {
// Prevent errors on Windows like
// Error: No client entry found for D:/a/redwood/rsc-project/web/dist/server/assets/rsc0.js
const entryFileSlash = entryFile.replaceAll('\\', '/')
console.log('entryFileSlash', entryFileSlash)
clientEntries[entryFileSlash] = fileName
} else {
clientEntries[entryFile] = fileName
Expand All @@ -61,7 +59,8 @@ export async function rscBuildEntriesMappings(
console.log('clientEntries', clientEntries)
await fs.appendFile(
rwPaths.web.distRscEntries,
`// client component mapping (dist/rsc -> dist/client)\nexport const clientEntries = ${JSON.stringify(clientEntries, undefined, 2)};\n\n`,
'// client component mapping (dist/rsc -> dist/client)\n' +
`export const clientEntries = ${JSON.stringify(clientEntries, undefined, 2)};\n\n`,
)

// Server component names to RSC server asset mapping
Expand All @@ -80,6 +79,7 @@ export async function rscBuildEntriesMappings(
console.log('serverEntries', serverEntries)
await fs.appendFile(
rwPaths.web.distRscEntries,
`// server component mapping (src -> dist/rsc)\nexport const serverEntries = ${JSON.stringify(serverEntries, undefined, 2)};\n\n`,
'// server component mapping (src -> dist/rsc)\n' +
`export const serverEntries = ${JSON.stringify(serverEntries, undefined, 2)};\n\n`,
)
}
5 changes: 0 additions & 5 deletions packages/vite/src/rsc/rscBuildForServer.ts
Expand Up @@ -92,17 +92,12 @@ export async function rscBuildForServer(
// HACK to bring directives to the front
let code = ''
const clientValues = Object.values(clientEntryFiles)
console.log('chunk.moduleIds', chunk.moduleIds)
console.log('clientValues', clientValues)
if (chunk.moduleIds.some((id) => clientValues.includes(id))) {
console.log('adding "use client" to', chunk.fileName)
code += '"use client";'
}

const serverValues = Object.values(serverEntryFiles)
console.log('serverValues', serverValues)
if (chunk.moduleIds.some((id) => serverValues.includes(id))) {
console.log('adding "use server" to', chunk.fileName)
code += '"use server";'
}
return code
Expand Down
3 changes: 2 additions & 1 deletion packages/vite/src/rsc/rscWorker.ts
Expand Up @@ -290,10 +290,11 @@ async function setClientEntries(): Promise<void> {
absoluteClientEntries = Object.fromEntries(
Object.entries(clientEntries).map(([key, val]) => {
let fullKey = path.join(baseDir, key)

if (process.platform === 'win32') {
fullKey = fullKey.replaceAll('\\', '/')
}
console.log('fullKey', fullKey, 'value', config.base + val)

return [fullKey, config.base + val]
}),
)
Expand Down
6 changes: 0 additions & 6 deletions packages/vite/src/runFeServer.ts
Expand Up @@ -77,12 +77,6 @@ export async function runFeServer() {
await import(clientBuildManifestUrl, { with: { type: 'json' } })
).default

if (rwConfig.experimental?.rsc?.enabled) {
console.log('='.repeat(80))
console.log('buildManifest', clientBuildManifest)
console.log('='.repeat(80))
}

// @MARK: Surely there's a better way than this!
const clientEntry = Object.values(clientBuildManifest).find(
(manifestItem) => {
Expand Down

0 comments on commit b862c6e

Please sign in to comment.