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

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

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