@bazel/worker
Version:
Adapt Node programs to run as a Bazel worker
36 lines (35 loc) • 1.42 kB
TypeScript
import "./gc";
/**
* Whether to print debug messages (to console.error) from the debug function
* below.
*/
export declare const DEBUG = false;
/**
* Write a message to stderr, which appears in the bazel log and is visible to
* the end user.
*/
export declare function log(...args: Array<unknown>): void;
/** Maybe print a debug message (depending on a flag defaulting to false). */
export declare function debug(...args: Array<unknown>): void;
/**
* runAsWorker returns true if the given arguments indicate the process should
* run as a persistent worker.
*/
export declare function runAsWorker(args: string[]): boolean;
export declare type Inputs = {
[path: string]: string | null;
};
export declare type OneBuildFunc = (args: string[], inputs: Inputs) => boolean | Promise<boolean>;
/**
* runWorkerLoop handles the interacton between bazel workers and the
* any compiler. It reads compilation requests from stdin, unmarshals the
* data, and dispatches into `runOneBuild` for the actual compilation to happen.
*
* The compilation handler is parameterized so that this code can be used by
* different compiler entry points (currently TypeScript compilation, Angular
* compilation, and the contrib vulcanize worker).
*
* It's also exposed publicly as an npm package:
* https://www.npmjs.com/package/@bazel/worker
*/
export declare function runWorkerLoop(runOneBuild: OneBuildFunc): Promise<void>;