diff --git a/loader/src/runner.ts b/loader/src/runner.ts index 11f8f3979ea..9bce743e594 100644 --- a/loader/src/runner.ts +++ b/loader/src/runner.ts @@ -278,10 +278,8 @@ export async function load({ const workerProcess = fork(workerFilePath, { // Note: this is required for PostCSS. cwd: rootDir, - stdio: "pipe", + stdio: "inherit", }); - workerProcess.stdout?.pipe(prettyLoggerStream); - workerProcess.stderr?.pipe(prettyLoggerStream); const killWorker = async () => { if (workerPromise?.resolved) { workerPromise.resolved.exiting = true; @@ -340,6 +338,9 @@ export async function load({ resolveWorkerReady(message); rejectWorkerReady = null; break; + case "log": + prettyLoggerStream.write(message.message); + break; case "crash": logger.error(message.message); rejectWorkerReady?.(new Error(message.message)); diff --git a/loader/src/worker-api.ts b/loader/src/worker-api.ts index 9c4e638d5ad..6e30c397751 100644 --- a/loader/src/worker-api.ts +++ b/loader/src/worker-api.ts @@ -53,6 +53,10 @@ export type FromWorkerMessage = kind: "ready"; port: number; } + | { + kind: "log"; + message: string; + } | { kind: "crash"; message: string; diff --git a/loader/src/worker.ts b/loader/src/worker.ts index dd0c7c6d2d1..142b006766e 100644 --- a/loader/src/worker.ts +++ b/loader/src/worker.ts @@ -1,6 +1,5 @@ import assertNever from "assert-never"; import createLogger from "pino"; -import prettyLogger from "pino-pretty"; import { loadModules } from "./modules"; import type { FromWorkerMessage, @@ -21,11 +20,17 @@ async function runWorker({ port, onServerStartModuleName, }: WorkerData) { - const prettyLoggerStream = prettyLogger({ - colorize: true, - destination: process.stdout, - }); - const logger = createLogger({ level: logLevel }, prettyLoggerStream); + const logger = createLogger( + { level: logLevel }, + { + write(message) { + sendMessageFromWorker({ + kind: "log", + message, + }); + }, + } + ); const { core, vfs, frameworkPlugins, onServerStart } = await loadModules({ logger, installDir,