Skip to content

Commit

Permalink
RSC: Move loaders to worker thread (#9412)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored Nov 11, 2023
1 parent e2a90f8 commit df88574
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 1 addition & 6 deletions packages/cli/src/commands/serveBothHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,7 @@ export const bothRscServerHandler = async (argv) => {
// TODO (RSC) More gracefully handle Ctrl-C
const fePromise = execa(
'node',
[
// TODO (RSC): Do we need these on the worker thread?
'--experimental-loader @redwoodjs/vite/node-loader',
'--experimental-loader @redwoodjs/vite/react-node-loader',
'./node_modules/@redwoodjs/vite/dist/runRscFeServer.js',
],
['./node_modules/@redwoodjs/vite/dist/runRscFeServer.js'],
{
cwd: getPaths().base,
stdio: 'inherit',
Expand Down
9 changes: 8 additions & 1 deletion packages/vite/src/rsc/rscWorkerCommunication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ import type { Readable } from 'node:stream'
import { Worker } from 'node:worker_threads'

const worker = new Worker(path.join(__dirname, 'rscWorker.js'), {
execArgv: ['--conditions', 'react-server'],
execArgv: [
'--conditions',
'react-server',
'--experimental-loader',
'@redwoodjs/vite/node-loader',
'--experimental-loader',
'@redwoodjs/vite/react-node-loader',
],
})

export type RenderInput<
Expand Down

0 comments on commit df88574

Please sign in to comment.