{"version":3,"sources":["../../../src/plugin/pluginIntlayerLynx.ts"],"sourcesContent":["import { prepareIntlayer, watch } from '@intlayer/chokidar';\nimport { ESMxCJSRequire, getAlias, getConfiguration } from '@intlayer/config';\nimport type { RsbuildPlugin } from '@rsbuild/core';\n\n/**\n * A Lynx plugin to integrate Intlayer into the Lynx build process.\n *\n * - Loads the Intlayer configuration and injects environment variables.\n * - If enabled, starts a file watcher for dictionary changes.\n * - On build, prepares the Intlayer configuration.\n * - Optionally checks for dictionary changes before compiling (hot reload).\n *\n * Usage in your lynx.config.ts:\n *\n *   import { defineConfig } from '@lynx-js/rspeedy'\n *   import { pluginIntlayerLynx } from '@intlayer/lynx-plugin'\n *\n *   export default defineConfig({\n *     plugins: [\n *       pluginIntlayerLynx(),\n *     ],\n *     // ...other configuration\n *   })\n */\nexport const pluginIntlayerLynx = (): RsbuildPlugin => {\n  return {\n    name: 'plugin-intlayer-lynx',\n\n    async setup(api) {\n      // Load the Intlayer configuration and format env variables for Lynx.\n      const configuration = getConfiguration();\n\n      await prepareIntlayer(configuration);\n\n      // If file watching is enabled in Intlayer's config, start it.\n      if (configuration.content.watch) {\n        watch({ configuration });\n      }\n\n      // Merge Intlayer-specific environment variables and alias configuration.\n      api.modifyRsbuildConfig(async (config, { mergeRsbuildConfig }) => {\n        return mergeRsbuildConfig(config, {\n          resolve: {\n            alias: {\n              ...getAlias({ configuration }),\n              react: ESMxCJSRequire.resolve('@lynx-js/react'),\n            },\n          },\n        });\n      });\n    },\n  };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAuC;AACvC,oBAA2D;AAuBpD,MAAM,qBAAqB,MAAqB;AACrD,SAAO;AAAA,IACL,MAAM;AAAA,IAEN,MAAM,MAAM,KAAK;AAEf,YAAM,oBAAgB,gCAAiB;AAEvC,gBAAM,iCAAgB,aAAa;AAGnC,UAAI,cAAc,QAAQ,OAAO;AAC/B,mCAAM,EAAE,cAAc,CAAC;AAAA,MACzB;AAGA,UAAI,oBAAoB,OAAO,QAAQ,EAAE,mBAAmB,MAAM;AAChE,eAAO,mBAAmB,QAAQ;AAAA,UAChC,SAAS;AAAA,YACP,OAAO;AAAA,cACL,OAAG,wBAAS,EAAE,cAAc,CAAC;AAAA,cAC7B,OAAO,6BAAe,QAAQ,gBAAgB;AAAA,YAChD;AAAA,UACF;AAAA,QACF,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}