mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-16 14:27:26 +00:00
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.
37 lines
1.3 KiB
TypeScript
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");
|