import { built_default } from "./config/dist/esm/built.mjs";
import { join } from "node:path";
import { existsSync } from "node:fs";
import { clearModuleCache, configESMxCJSRequire } from "@intlayer/config";

//#region ../chokidar/dist/esm/remote-dictionaries-entry/dist/esm/index.mjs
/**
* @intlayer/dynamic-dictionaries-entry is a package that only returns the dynamic dictionary entry file.
* Using an external package allow to alias it in the bundle configuration (such as webpack).
* The alias allow hot reload the app (such as nextjs) on any dictionary change.
*/
const getRemoteDictionaries = (configuration = built_default) => {
	const { content, build } = configuration;
	const dictionariesPath = join(content.mainDir, `remote_dictionaries.cjs`);
	let dictionaries = {};
	if (existsSync(dictionariesPath)) {
		clearModuleCache(dictionariesPath);
		dictionaries = (build.require ?? configESMxCJSRequire)(dictionariesPath);
	}
	return dictionaries;
};

//#endregion
export { getRemoteDictionaries };
//# sourceMappingURL=index.mjs.map