const require_ESMxCJSHelpers = require('./ESMxCJSHelpers.cjs');

//#region ../@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 = require_ESMxCJSHelpers.configESMxCJSRequire.resolve(modulePath);
		const cachedModule = require_ESMxCJSHelpers.configESMxCJSRequire.cache[resolvedPath];
		if (cachedModule) {
			if (cachedModule.children) cachedModule.children.forEach((child) => {
				clearModuleCache(child.filename, visited);
			});
			delete require_ESMxCJSHelpers.configESMxCJSRequire.cache[resolvedPath];
		}
	} catch (error) {
		console.warn(`Could not clear cache for module: ${modulePath}`, error);
	}
};

//#endregion
exports.clearModuleCache = clearModuleCache;
//# sourceMappingURL=clearModuleCache.cjs.map