Skip to content

Commit

Permalink
prepend file://
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe committed Sep 4, 2024
1 parent c0ea4e5 commit 4891334
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/vite/src/rsc/rscWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ const shutdown = async () => {
parentPort.close()
}

async function loadServerFile(filePath: string) {
return import(`file://${filePath}`)
}

if (!parentPort) {
throw new Error('parentPort is undefined')
}
Expand Down Expand Up @@ -241,7 +245,7 @@ const getRoutesComponent: any = async () => {
throw new StatusError('No entry found for __rwjs__Routes', 404)
}

const routes = await import(`file://${routesPath}`)
const routes = await loadServerFile(routesPath)

return routes.default
}
Expand Down Expand Up @@ -298,7 +302,7 @@ async function setClientEntries(): Promise<void> {

const entriesFile = getPaths().web.distRscEntries
console.log('setClientEntries :: entriesFile', entriesFile)
const { clientEntries } = await import(entriesFile)
const { clientEntries } = await loadServerFile(entriesFile)
console.log('setClientEntries :: clientEntries', clientEntries)
if (!clientEntries) {
throw new Error('Failed to load clientEntries')
Expand Down Expand Up @@ -424,7 +428,7 @@ async function handleRsa(input: RenderInput): Promise<PipeableStream> {

const [fileName, actionName] = input.rsaId.split('#')
console.log('Server Action fileName', fileName, 'actionName', actionName)
const module = await import(fileName)
const module = await loadServerFile(fileName)

if (isSerializedFormData(input.args[0])) {
const formData = new FormData()
Expand Down

0 comments on commit 4891334

Please sign in to comment.