@farmfe/runtime-plugin-hmr
Version:
Runtime hmr plugin of Farm
79 lines (78 loc) • 2.1 kB
TypeScript
import type { Resource } from '@farmfe/runtime';
type ModuleMap = Record<string, (module: any, exports: any, require: (id: string) => any, dynamicRequire: (id: string) => Promise<any>) => void>;
export interface HmrUpdateResult {
added: string[];
changed: string[];
removed: string[];
boundaries: Record<string, string[][]>;
modules: ModuleMap;
dynamicResources: Resource[] | null;
dynamicModuleResourcesMap: Record<string, number[]> | null;
}
export interface RawHmrUpdateResult {
added: string[];
changed: string[];
removed: string[];
boundaries: Record<string, string[][]>;
immutableModules: string;
mutableModules: string;
dynamicResources: Resource[] | null;
dynamicModuleResourcesMap: Record<string, number[]> | null;
}
export type HMRPayload = FarmHmrPayload | ConnectedPayload | UpdatePayload | FullReloadPayload | CustomPayload | ErrorPayload | PrunePayload | ClosingPayload;
export interface FarmHmrPayload {
type: 'farm-update';
result: RawHmrUpdateResult;
}
export interface ConnectedPayload {
type: 'connected';
}
export interface UpdatePayload {
type: 'update';
updates: Update[];
}
export interface Update {
type: 'js-update' | 'css-update';
path: string;
acceptedPath: string;
timestamp: number;
/**
* @experimental internal
*/
explicitImportRequired?: boolean | undefined;
}
export interface PrunePayload {
type: 'prune';
paths: string[];
}
export interface FullReloadPayload {
type: 'full-reload';
path?: string;
}
export interface CustomPayload {
type: 'custom';
event: string;
data?: any;
}
export interface ClosingPayload {
type: 'closing';
}
export interface ErrorPayload {
type: 'error';
err: {
[name: string]: any;
message: string;
stack: string;
id?: string;
frame?: string;
plugin?: string;
pluginCode?: string;
loc?: {
file?: string;
line: number;
column: number;
};
};
overlay: boolean;
}
export {};