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 ../@intlayer/chokidar/dist/esm/unmerged-dictionaries-entry/dist/esm/index.mjs
/**
* @intlayer/unmerged-dictionaries-entry is a package that only returns the unmerged 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 getUnmergedDictionaries = (configuration = built_default) => {
	const { content, build } = configuration;
	const dictionariesPath = join(content.mainDir, `unmerged_dictionaries.cjs`);
	let dictionaries = {};
	if (existsSync(dictionariesPath)) {
		clearModuleCache(dictionariesPath);
		dictionaries = (build.require ?? configESMxCJSRequire)(dictionariesPath);
	}
	return dictionaries;
};

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