Skip to content

Commit

Permalink
RSC: Make rw dev not crash for /about (#10191)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored Mar 11, 2024
1 parent 598df34 commit e386d2c
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions packages/vite/src/plugins/vite-plugin-rsc-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,19 +316,15 @@ async function transformClientModule(
await parseExportNamesIntoNames(code, body, names)
console.log('transformClientModule names', names)

// entryRecord will be undefined for dev, because clientEntryFiles will just
// be an empty object. See rscWorker.ts, where we do rscTransformPlugin({})
const entryRecord = Object.entries(clientEntryFiles).find(
([_key, value]) => value === url,
)

if (!entryRecord || !entryRecord[0]) {
throw new Error('Entry not found for ' + url)
}

const loadId = path.join(
getPaths().web.distRsc,
'assets',
`${entryRecord[0]}.mjs`,
)
const loadId = entryRecord
? path.join(getPaths().web.distRsc, 'assets', `${entryRecord[0]}.mjs`)
: url

let newSrc =
"const CLIENT_REFERENCE = Symbol.for('react.client.reference');\n"
Expand Down

0 comments on commit e386d2c

Please sign in to comment.