From df885749bdf150c3e536f463256e8cf34a987e78 Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Sat, 11 Nov 2023 23:24:38 +0100 Subject: [PATCH] RSC: Move loaders to worker thread (#9412) --- packages/cli/src/commands/serveBothHandler.js | 7 +------ packages/vite/src/rsc/rscWorkerCommunication.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/cli/src/commands/serveBothHandler.js b/packages/cli/src/commands/serveBothHandler.js index 349c4563f9..79b6921f6b 100644 --- a/packages/cli/src/commands/serveBothHandler.js +++ b/packages/cli/src/commands/serveBothHandler.js @@ -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', diff --git a/packages/vite/src/rsc/rscWorkerCommunication.ts b/packages/vite/src/rsc/rscWorkerCommunication.ts index 6570c0125c..1405a8661d 100644 --- a/packages/vite/src/rsc/rscWorkerCommunication.ts +++ b/packages/vite/src/rsc/rscWorkerCommunication.ts @@ -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<