// eslint-disable-next-line @typescript-eslint/no-explicit-any export type LoadValues = Record; export type FileLoader = ( text: string, filePath: string, values: LoadValues ) => Promise; export const loadFromFile = async ( uri: string, loader: FileLoader, values: LoadValues = {} ): Promise => { try { const fs = await import("node:fs/promises"); return loader(await fs.readFile(uri, { encoding: "utf-8" }), uri, values); } catch (e) { console.error(e); throw new Error(`Could not load file at ${uri}`); } };