{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// @ts-nocheck intlayer declared for module augmentation\n\n/**\n * @intlayer/dynamic-dictionaries-entry is a package that only returns the dynamic 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 {\n  Dictionary,\n  IntlayerDictionaryTypesConnector,\n  LanguageContent,\n} from 'intlayer';\nimport { join } from 'path';\n\nexport const getRemoteDictionaries = (\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, `remote_dictionaries.cjs`);\n  let dictionaries: Record<\n    IntlayerDictionaryTypesConnector['key'],\n    LanguageContent<Dictionary>\n  > = {};\n\n  if (existsSync(dictionariesPath)) {\n    // Clear cache for dynamic_dictionaries.cjs and all its dependencies (JSON files)\n    clearModuleCache(dictionariesPath);\n    dictionaries = projectRequire(dictionariesPath);\n  }\n\n  return dictionaries;\n};\n\nexport default (() => getRemoteDictionaries())();\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,oBAKO;AACP,gBAA2B;AAM3B,kBAAqB;AAEd,MAAM,wBAAwB,CACnC,oBAAgC,gCAAiB,GACjD,iBAAiB,iCACd;AACH,QAAM,EAAE,QAAQ,IAAI;AAGpB,QAAM,uBAAmB,kBAAK,QAAQ,SAAS,yBAAyB;AACxE,MAAI,eAGA,CAAC;AAEL,UAAI,sBAAW,gBAAgB,GAAG;AAEhC,wCAAiB,gBAAgB;AACjC,mBAAe,eAAe,gBAAgB;AAAA,EAChD;AAEA,SAAO;AACT;AAEA,IAAO,iBAAS,MAAM,sBAAsB,GAAG;","names":[]}