@launchmenu/hmr
Version:
34 lines • 1.42 kB
TypeScript
import chokidar from "chokidar";
/**
* Listens to changes for a module and triggers the callback when data changed
* @param dir The directory to check for changes in (path should be absolute)
* @param onChange The callback to perform when data is changed
* @param options Extra options
* @returns A chokidar watcher
*/
export default function hmr(dir: string, onChange: (changedFiled: string[], affectedFiles: string[]) => void, { timeoutTime, target, }?: {
/** The number of milliseconds to wait for before an update */
timeoutTime?: number;
/** The absolute path to a module, such that the onChange is only called if this module was affected */
target?: string;
}): HMRWatcher;
/**
* The FSWatcher returned by chokidar and HMR
*/
export declare type FSWatcher = chokidar.FSWatcher;
export declare type HMRWatcher = {
/** The chokidar watcher */
watcher: FSWatcher;
/**
* Destroys the watcher
* @param fully Whether to also clear any previously started update timeouts
*/
destroy(fully?: boolean): void;
};
/**
* Requires without storing child references, such that HMR doesn't think you're dependent on the module and you should be invalidated
* @param path The path to be required
* @returns The output of the require call
*/
export declare function referencelessRequire(path: string): any;
//# sourceMappingURL=index.d.ts.map