{"version":3,"file":"clearModuleCache.cjs","names":["configESMxCJSRequire"],"sources":["../../../src/utils/clearModuleCache.ts"],"sourcesContent":["import { configESMxCJSRequire } from './ESMxCJSHelpers';\n\n/**\n * Recursively clears the require cache for a module and all its dependencies\n */\nexport const clearModuleCache = (\n  modulePath: string,\n  visited = new Set<string>()\n) => {\n  // Avoid infinite loops\n  if (visited.has(modulePath)) {\n    return;\n  }\n  visited.add(modulePath);\n\n  try {\n    const resolvedPath = configESMxCJSRequire.resolve(modulePath);\n\n    // Get the cached module\n    const cachedModule = configESMxCJSRequire.cache[resolvedPath];\n\n    if (cachedModule) {\n      // Clear cache for all children (dependencies) first\n      if (cachedModule.children) {\n        cachedModule.children.forEach((child) => {\n          clearModuleCache(child.filename, visited);\n        });\n      }\n\n      // Clear the cache for this module\n      delete configESMxCJSRequire.cache[resolvedPath];\n    }\n  } catch (error) {\n    // Module might not exist or be resolvable, skip it\n    console.warn(`Could not clear cache for module: ${modulePath}`, error);\n  }\n};\n"],"mappings":";;;;;;;AAKA,MAAa,oBACX,YACA,0BAAU,IAAI,KAAa,KACxB;AAEH,KAAI,QAAQ,IAAI,WAAW,CACzB;AAEF,SAAQ,IAAI,WAAW;AAEvB,KAAI;EACF,MAAM,eAAeA,kDAAqB,QAAQ,WAAW;EAG7D,MAAM,eAAeA,kDAAqB,MAAM;AAEhD,MAAI,cAAc;AAEhB,OAAI,aAAa,SACf,cAAa,SAAS,SAAS,UAAU;AACvC,qBAAiB,MAAM,UAAU,QAAQ;KACzC;AAIJ,UAAOA,kDAAqB,MAAM;;UAE7B,OAAO;AAEd,UAAQ,KAAK,qCAAqC,cAAc,MAAM"}