Files
hyperframes/packages/cli/src/renderSetupWorker.ts
T
Miguel Ángel 8996d928d9 perf(studio): keep lint off the preview open path
The bundler linted every build only to print a StaticGuard warning; a preview bundle now
skips it through a staticGuard option, since Studio lints on its own route. That route now
lints in the CLI child-process worker the render path already uses, so seconds of parsing
no longer stall the preview and every other Studio request on the server event loop.
2026-09-23 01:24:35 -04:00

37 lines
1.3 KiB
TypeScript

// fallow-ignore-file unused-file
import { ensureBrowser, releaseOwnedBrowserInstallLock } from "./browser/manager.js";
import { lintProject } from "./utils/lintProject.js";
import { killOrphanedProcesses } from "./utils/orphanCleanup.js";
import { installRenderSetupSignalHandlers } from "./renderSetupWorkerLifecycle.js";
const RESULT_PREFIX = "HYPERFRAMES_RENDER_SETUP_RESULT:";
const mode = process.argv[2];
const input = JSON.parse(process.env.HYPERFRAMES_RENDER_SETUP_INPUT ?? "{}");
const disposeSignalHandlers = installRenderSetupSignalHandlers(
process,
releaseOwnedBrowserInstallLock,
(signal) => process.kill(process.pid, signal),
process.env.HYPERFRAMES_RENDER_DETACHED !== "1",
);
let result: unknown;
if (mode === "browser") {
result = await ensureBrowser(input);
} else if (mode === "lint") {
result = await lintProject(
input.projectDir,
input.entryFile,
input.host ? { host: input.host } : undefined,
);
} else if (mode === "orphan-cleanup") {
const killed = killOrphanedProcesses();
result = killed;
if (killed > 0) await new Promise((resolve) => setTimeout(resolve, 600));
} else {
throw new Error(`Unknown render setup mode: ${mode}`);
}
disposeSignalHandlers();
process.stdout.write(RESULT_PREFIX + JSON.stringify(result) + "\n");