import { configESMxCJSRequire } from "./ESMxCJSHelpers.mjs";

//#region ../react-intlayer/dist/esm/@intlayer/config/dist/esm/utils/clearModuleCache.mjs
/**
* Recursively clears the require cache for a module and all its dependencies
*/
const clearModuleCache = (modulePath, visited = /* @__PURE__ */ new Set()) => {
	if (visited.has(modulePath)) return;
	visited.add(modulePath);
	try {
		const resolvedPath = configESMxCJSRequire.resolve(modulePath);
		const cachedModule = configESMxCJSRequire.cache[resolvedPath];
		if (cachedModule) {
			if (cachedModule.children) cachedModule.children.forEach((child) => {
				clearModuleCache(child.filename, visited);
			});
			delete configESMxCJSRequire.cache[resolvedPath];
		}
	} catch (error) {
		console.warn(`Could not clear cache for module: ${modulePath}`, error);
	}
};

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