zephyr-xpack-internal
Version:
Xpack internals for Zephyr
83 lines • 3.96 kB
text/typescript
import { type BuildParticipant, type ZeBuildAssetsMap, type ZephyrBuildHooks, type ZephyrEngine } from 'zephyr-agent';
import type { ZephyrBuildStats, ZephyrModuleFederationConfig } from 'zephyr-edge-contract';
export interface XPackParticipantDependencyPaths {
fileDependencies: readonly string[];
contextDependencies: readonly string[];
missingDependencies: readonly string[];
buildDependencies: readonly string[];
}
export interface XPackBuildContribution {
participant: string;
/** Compiler-local watch generation. All coordinated compilers start at zero. */
generation?: number;
assetsMap: ZeBuildAssetsMap;
buildStats: ZephyrBuildStats;
/** Every serializable MF config emitted by this compiler. */
mfConfigs?: ZephyrModuleFederationConfig[];
hooks?: ZephyrBuildHooks;
dependencyPaths?: XPackParticipantDependencyPaths;
}
export interface XPackBuildCoordinatorOptions {
snapshotType?: 'csr' | 'ssr';
entrypoint?: string;
}
export interface XPackBuildParticipant extends BuildParticipant {
/** Participant names this compiler depends on in the MultiCompiler graph. */
dependencies?: readonly string[];
}
/** One logical publication shared by Rspack/Webpack child compilers. */
export declare class XPackBuildCoordinator {
private readonly engine;
private readonly context;
private readonly participants;
private readonly participantNames;
private readonly dependents;
private readonly lastSuccessful;
private readonly localGenerations;
private readonly rejectedLocalGenerations;
private readonly pendingRecoveryParticipants;
private readonly participantBaseHrefs;
private readonly preparationPromises;
private applicationBaseHref;
private activeBuild;
private nextLogicalGeneration;
constructor(engine: ZephyrEngine, participants: readonly XPackBuildParticipant[], options?: XPackBuildCoordinatorOptions);
/**
* Select one application-wide snapshot base for every coordinated compiler. Root-like
* and missing values normalize to the empty base; conflicting child bases fail before
* compilation can publish a snapshot with paths from the last-applied plugin.
*/
registerParticipantBaseHref(participant: string, baseHref: string | null | undefined): void;
/**
* Open one invalidation batch before its child compilers start. Webpack/Rspack may
* execute children sequentially (`parallelism: 1`), so all invalidated participants
* must enter the barrier before the first child is allowed to publish.
*/
beginBatch(participants: readonly string[]): void;
/**
* Register a child invalidation using dependencies from the last complete build. The
* first hook therefore marks every affected child before parallelism=1 can let one fast
* compiler publish with another child's stale output.
*/
invalidateParticipant(participant: string, filename?: string | null): void;
/** Mark a child compiler dirty before its compilation starts. */
beginParticipant(participant: string, localGeneration: number): void;
/**
* Allocate the Zephyr build identity before a participant derives versioned build
* metadata. Publication also awaits this same single-flight promise.
*/
prepareParticipant(participant: string, localGeneration?: number): Promise<void>;
contribute(contribution: XPackBuildContribution): Promise<boolean>;
/** Fail and release the shared generation when a child never reaches contribution. */
failParticipant(participant: string, error: unknown): void;
private createBuild;
private resolveBuild;
private resolveParticipantBuild;
private prepareLogicalGeneration;
private publishIfReady;
private rememberFailedBuild;
private openInvalidationBatch;
private resolveAffectedParticipants;
private assertParticipant;
}
//# sourceMappingURL=xpack-build-coordinator.d.mts.map