{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["/**\n * @intlayer/unmerged-dictionaries-entry is a package that only returns the unmerged dictionary entry file.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\n\nimport {\n  clearModuleCache,\n  ESMxCJSRequire,\n  getConfiguration,\n  type IntlayerConfig,\n} from '@intlayer/config';\nimport { existsSync } from 'fs';\nimport { join } from 'path';\n// @ts-ignore intlayer declared for module augmentation\nimport type { Dictionary, IntlayerDictionaryTypesConnector } from 'intlayer';\n\nexport const getUnmergedDictionaries = (\n  configuration: IntlayerConfig = getConfiguration(),\n  projectRequire = ESMxCJSRequire\n) => {\n  const { content } = configuration;\n\n  // Always use cjs for dictionaries entry as it uses require\n  const dictionariesPath = join(content.mainDir, `unmerged_dictionaries.cjs`);\n  let dictionaries: Record<\n    IntlayerDictionaryTypesConnector['key'],\n    Dictionary[]\n  > = {};\n\n  if (existsSync(dictionariesPath)) {\n    // Clear cache for unmerged_dictionaries.cjs and all its dependencies (JSON files)\n    clearModuleCache(dictionariesPath);\n    dictionaries = projectRequire(dictionariesPath);\n  }\n\n  return dictionaries;\n};\n\nexport default (() => getUnmergedDictionaries())();\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,oBAKO;AACP,gBAA2B;AAC3B,kBAAqB;AAId,MAAM,0BAA0B,CACrC,oBAAgC,gCAAiB,GACjD,iBAAiB,iCACd;AACH,QAAM,EAAE,QAAQ,IAAI;AAGpB,QAAM,uBAAmB,kBAAK,QAAQ,SAAS,2BAA2B;AAC1E,MAAI,eAGA,CAAC;AAEL,UAAI,sBAAW,gBAAgB,GAAG;AAEhC,wCAAiB,gBAAgB;AACjC,mBAAe,eAAe,gBAAgB;AAAA,EAChD;AAEA,SAAO;AACT;AAEA,IAAO,iBAAS,MAAM,wBAAwB,GAAG;","names":[]}