@intlayer/babel 8.1.2 → 8.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"getExtractPluginOptions.mjs","names":[],"sources":["../../src/getExtractPluginOptions.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { buildDictionary, writeContentDeclaration } from '@intlayer/chokidar';\nimport { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/types';\nimport type {\n ExtractPluginOptions,\n ExtractResult,\n} from './babel-plugin-intlayer-extract';\n\n/**\n * Translation node structure used in dictionaries\n */\ntype TranslationNode = {\n nodeType: 'translation';\n translation: Record<string, string>;\n};\n\n/**\n * Dictionary content structure - map of keys to translation nodes\n */\ntype DictionaryContentMap = Record<string, TranslationNode>;\n\n/**\n * Get the options for the Intlayer Babel extraction plugin\n * This function loads the Intlayer configuration and sets up the onExtract callback\n * to write dictionaries to the filesystem.\n */\nexport const getExtractPluginOptions = (): ExtractPluginOptions => {\n const config = getConfiguration();\n const { baseDir } = config.content;\n const compilerDir = join(baseDir, config.compiler?.outputDir ?? 'compiler');\n\n /**\n * Read existing dictionary file if it exists\n */\n const readExistingDictionary = async (\n dictionaryPath: string\n ): Promise<Dictionary | null> => {\n try {\n if (!existsSync(dictionaryPath)) {\n return null;\n }\n const content = await readFile(dictionaryPath, 'utf-8');\n return JSON.parse(content) as Dictionary;\n } catch {\n return null;\n }\n };\n\n /**\n * Merge extracted content with existing dictionary, preserving translations.\n * - Keys in extracted but not in existing: added with default locale only\n * - Keys in both: preserve existing translations, update default locale value\n * - Keys in existing but not in extracted: removed (no longer in source)\n */\n const mergeWithExistingDictionary = (\n extractedContent: Record<string, string>,\n existingDictionary: Dictionary | null,\n defaultLocale: string\n ): DictionaryContentMap => {\n const mergedContent: DictionaryContentMap = {};\n const existingContent = existingDictionary?.content as\n | DictionaryContentMap\n | undefined;\n\n for (const [key, value] of Object.entries(extractedContent)) {\n const existingEntry = existingContent?.[key];\n\n if (\n existingEntry &&\n existingEntry.nodeType === 'translation' &&\n existingEntry.translation\n ) {\n // Key exists in both - preserve existing translations, update default locale\n mergedContent[key] = {\n nodeType: 'translation',\n translation: {\n ...existingEntry.translation,\n [defaultLocale]: value,\n },\n };\n } else {\n // New key - add with default locale only\n mergedContent[key] = {\n nodeType: 'translation',\n translation: {\n [defaultLocale]: value,\n },\n };\n }\n }\n\n return mergedContent;\n };\n\n const handleExtractedContent = async (result: ExtractResult) => {\n const { dictionaryKey, content, locale } = result;\n\n try {\n const dictionaryPath = join(compilerDir, `${dictionaryKey}.content.json`);\n\n // Read existing dictionary to preserve translations\n const existingDictionary = await readExistingDictionary(dictionaryPath);\n\n // Merge extracted content with existing translations\n const mergedContent = mergeWithExistingDictionary(\n content,\n existingDictionary,\n locale\n );\n\n const dictionary: Dictionary = {\n key: dictionaryKey,\n content: mergedContent,\n filePath: join(\n relative(baseDir, compilerDir),\n `${dictionaryKey}.content.json`\n ),\n };\n\n const writeResult = await writeContentDeclaration(dictionary, config, {\n newDictionariesPath: relative(baseDir, compilerDir),\n });\n\n // Build the dictionary immediately\n const dictionaryToBuild: Dictionary = {\n ...dictionary,\n filePath: relative(baseDir, writeResult.path),\n };\n\n await buildDictionary([dictionaryToBuild], config);\n } catch (error) {\n console.error(\n `[intlayer] Failed to process extracted content for ${dictionaryKey}:`,\n error\n );\n }\n };\n\n return {\n defaultLocale: config.internationalization.defaultLocale,\n // filesList can be passed if needed, but usually handled by include/exclude in build tool\n onExtract: handleExtractedContent,\n };\n};\n"],"mappings":";;;;;;;;;;;;AA6BA,MAAa,gCAAsD;CACjE,MAAM,SAAS,kBAAkB;CACjC,MAAM,EAAE,YAAY,OAAO;CAC3B,MAAM,cAAc,KAAK,SAAS,OAAO,UAAU,aAAa,WAAW;;;;CAK3E,MAAM,yBAAyB,OAC7B,mBAC+B;AAC/B,MAAI;AACF,OAAI,CAAC,WAAW,eAAe,CAC7B,QAAO;GAET,MAAM,UAAU,MAAM,SAAS,gBAAgB,QAAQ;AACvD,UAAO,KAAK,MAAM,QAAQ;UACpB;AACN,UAAO;;;;;;;;;CAUX,MAAM,+BACJ,kBACA,oBACA,kBACyB;EACzB,MAAM,gBAAsC,EAAE;EAC9C,MAAM,kBAAkB,oBAAoB;AAI5C,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,iBAAiB,EAAE;GAC3D,MAAM,gBAAgB,kBAAkB;AAExC,OACE,iBACA,cAAc,aAAa,iBAC3B,cAAc,YAGd,eAAc,OAAO;IACnB,UAAU;IACV,aAAa;KACX,GAAG,cAAc;MAChB,gBAAgB;KAClB;IACF;OAGD,eAAc,OAAO;IACnB,UAAU;IACV,aAAa,GACV,gBAAgB,OAClB;IACF;;AAIL,SAAO;;CAGT,MAAM,yBAAyB,OAAO,WAA0B;EAC9D,MAAM,EAAE,eAAe,SAAS,WAAW;AAE3C,MAAI;GAaF,MAAM,aAAyB;IAC7B,KAAK;IACL,SARoB,4BACpB,SAJyB,MAAM,uBAHV,KAAK,aAAa,GAAG,cAAc,eAAe,CAGF,EAMrE,OACD;IAKC,UAAU,KACR,SAAS,SAAS,YAAY,EAC9B,GAAG,cAAc,eAClB;IACF;GAED,MAAM,cAAc,MAAM,wBAAwB,YAAY,QAAQ,EACpE,qBAAqB,SAAS,SAAS,YAAY,EACpD,CAAC;AAQF,SAAM,gBAAgB,CALgB;IACpC,GAAG;IACH,UAAU,SAAS,SAAS,YAAY,KAAK;IAC9C,CAEwC,EAAE,OAAO;WAC3C,OAAO;AACd,WAAQ,MACN,sDAAsD,cAAc,IACpE,MACD;;;AAIL,QAAO;EACL,eAAe,OAAO,qBAAqB;EAE3C,WAAW;EACZ"}
1
+ {"version":3,"file":"getExtractPluginOptions.mjs","names":[],"sources":["../../src/getExtractPluginOptions.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport {\n buildDictionary,\n writeContentDeclaration,\n} from '@intlayer/chokidar/build';\nimport { getConfiguration } from '@intlayer/config/node';\nimport type { Dictionary } from '@intlayer/types';\nimport type {\n ExtractPluginOptions,\n ExtractResult,\n} from './babel-plugin-intlayer-extract';\n\n/**\n * Translation node structure used in dictionaries\n */\ntype TranslationNode = {\n nodeType: 'translation';\n translation: Record<string, string>;\n};\n\n/**\n * Dictionary content structure - map of keys to translation nodes\n */\ntype DictionaryContentMap = Record<string, TranslationNode>;\n\n/**\n * Get the options for the Intlayer Babel extraction plugin\n * This function loads the Intlayer configuration and sets up the onExtract callback\n * to write dictionaries to the filesystem.\n */\nexport const getExtractPluginOptions = (): ExtractPluginOptions => {\n const config = getConfiguration();\n const { baseDir } = config.content;\n const compilerDir = join(baseDir, config.compiler?.outputDir ?? 'compiler');\n\n /**\n * Read existing dictionary file if it exists\n */\n const readExistingDictionary = async (\n dictionaryPath: string\n ): Promise<Dictionary | null> => {\n try {\n if (!existsSync(dictionaryPath)) {\n return null;\n }\n const content = await readFile(dictionaryPath, 'utf-8');\n return JSON.parse(content) as Dictionary;\n } catch {\n return null;\n }\n };\n\n /**\n * Merge extracted content with existing dictionary, preserving translations.\n * - Keys in extracted but not in existing: added with default locale only\n * - Keys in both: preserve existing translations, update default locale value\n * - Keys in existing but not in extracted: removed (no longer in source)\n */\n const mergeWithExistingDictionary = (\n extractedContent: Record<string, string>,\n existingDictionary: Dictionary | null,\n defaultLocale: string\n ): DictionaryContentMap => {\n const mergedContent: DictionaryContentMap = {};\n const existingContent = existingDictionary?.content as\n | DictionaryContentMap\n | undefined;\n\n for (const [key, value] of Object.entries(extractedContent)) {\n const existingEntry = existingContent?.[key];\n\n if (\n existingEntry &&\n existingEntry.nodeType === 'translation' &&\n existingEntry.translation\n ) {\n // Key exists in both - preserve existing translations, update default locale\n mergedContent[key] = {\n nodeType: 'translation',\n translation: {\n ...existingEntry.translation,\n [defaultLocale]: value,\n },\n };\n } else {\n // New key - add with default locale only\n mergedContent[key] = {\n nodeType: 'translation',\n translation: {\n [defaultLocale]: value,\n },\n };\n }\n }\n\n return mergedContent;\n };\n\n const handleExtractedContent = async (result: ExtractResult) => {\n const { dictionaryKey, content, locale } = result;\n\n try {\n const dictionaryPath = join(compilerDir, `${dictionaryKey}.content.json`);\n\n // Read existing dictionary to preserve translations\n const existingDictionary = await readExistingDictionary(dictionaryPath);\n\n // Merge extracted content with existing translations\n const mergedContent = mergeWithExistingDictionary(\n content,\n existingDictionary,\n locale\n );\n\n const dictionary: Dictionary = {\n key: dictionaryKey,\n content: mergedContent,\n filePath: join(\n relative(baseDir, compilerDir),\n `${dictionaryKey}.content.json`\n ),\n };\n\n const writeResult = await writeContentDeclaration(dictionary, config, {\n newDictionariesPath: relative(baseDir, compilerDir),\n });\n\n // Build the dictionary immediately\n const dictionaryToBuild: Dictionary = {\n ...dictionary,\n filePath: relative(baseDir, writeResult.path),\n };\n\n await buildDictionary([dictionaryToBuild], config);\n } catch (error) {\n console.error(\n `[intlayer] Failed to process extracted content for ${dictionaryKey}:`,\n error\n );\n }\n };\n\n return {\n defaultLocale: config.internationalization.defaultLocale,\n // filesList can be passed if needed, but usually handled by include/exclude in build tool\n onExtract: handleExtractedContent,\n };\n};\n"],"mappings":"iRAgCA,MAAa,MAAsD,CACjE,IAAM,EAAS,GAAkB,CAC3B,CAAE,WAAY,EAAO,QACrB,EAAc,EAAK,EAAS,EAAO,UAAU,WAAa,WAAW,CAKrE,EAAyB,KAC7B,IAC+B,CAC/B,GAAI,CACF,GAAI,CAAC,EAAW,EAAe,CAC7B,OAAO,KAET,IAAM,EAAU,MAAM,EAAS,EAAgB,QAAQ,CACvD,OAAO,KAAK,MAAM,EAAQ,MACpB,CACN,OAAO,OAUL,GACJ,EACA,EACA,IACyB,CACzB,IAAM,EAAsC,EAAE,CACxC,EAAkB,GAAoB,QAI5C,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAiB,CAAE,CAC3D,IAAM,EAAgB,IAAkB,GAGtC,GACA,EAAc,WAAa,eAC3B,EAAc,YAGd,EAAc,GAAO,CACnB,SAAU,cACV,YAAa,CACX,GAAG,EAAc,aAChB,GAAgB,EAClB,CACF,CAGD,EAAc,GAAO,CACnB,SAAU,cACV,YAAa,EACV,GAAgB,EAClB,CACF,CAIL,OAAO,GA+CT,MAAO,CACL,cAAe,EAAO,qBAAqB,cAE3C,UA/C6B,KAAO,IAA0B,CAC9D,GAAM,CAAE,gBAAe,UAAS,UAAW,EAE3C,GAAI,CAaF,IAAM,EAAyB,CAC7B,IAAK,EACL,QARoB,EACpB,EAJyB,MAAM,EAHV,EAAK,EAAa,GAAG,EAAc,eAAe,CAGF,CAMrE,EACD,CAKC,SAAU,EACR,EAAS,EAAS,EAAY,CAC9B,GAAG,EAAc,eAClB,CACF,CAEK,EAAc,MAAM,EAAwB,EAAY,EAAQ,CACpE,oBAAqB,EAAS,EAAS,EAAY,CACpD,CAAC,CAQF,MAAM,EAAgB,CALgB,CACpC,GAAG,EACH,SAAU,EAAS,EAAS,EAAY,KAAK,CAC9C,CAEwC,CAAE,EAAO,OAC3C,EAAO,CACd,QAAQ,MACN,sDAAsD,EAAc,GACpE,EACD,GAQJ"}
@@ -1,64 +1,2 @@
1
- import { __require } from "./_virtual/_rolldown/runtime.mjs";
2
- import { join } from "node:path";
3
- import { getComponentTransformPatternSync } from "@intlayer/chokidar";
4
- import { getConfiguration } from "@intlayer/config";
5
-
6
- //#region src/getOptimizePluginOptions.ts
7
- /**
8
- * Load dictionaries from the dictionaries-entry package
9
- */
10
- const loadDictionaries = (config) => {
11
- try {
12
- const { getDictionaries } = __require("@intlayer/dictionaries-entry");
13
- const dictionariesRecord = getDictionaries(config);
14
- return Object.values(dictionariesRecord);
15
- } catch {
16
- return [];
17
- }
18
- };
19
- /**
20
- * Get the options for the Intlayer Babel optimization plugin
21
- * This function loads the Intlayer configuration and returns the paths
22
- * needed for dictionary optimization and import rewriting.
23
- */
24
- const getOptimizePluginOptions = (params) => {
25
- const { configOptions, dictionaries: providedDictionaries, overrides } = params ?? {};
26
- const config = getConfiguration(configOptions);
27
- const { mainDir, dictionariesDir, unmergedDictionariesDir, dynamicDictionariesDir, fetchDictionariesDir } = config.system;
28
- const { importMode, optimize } = config.build;
29
- const filesListPattern = getComponentTransformPatternSync(config);
30
- const dictionariesEntryPath = join(mainDir, "dictionaries.mjs");
31
- const unmergedDictionariesEntryPath = join(mainDir, "unmerged_dictionaries.mjs");
32
- const dynamicDictionariesEntryPath = join(mainDir, "dynamic_dictionaries.mjs");
33
- const fetchDictionariesEntryPath = join(mainDir, "fetch_dictionaries.mjs");
34
- const filesList = [
35
- ...filesListPattern,
36
- dictionariesEntryPath,
37
- unmergedDictionariesEntryPath
38
- ];
39
- const dictionaries = providedDictionaries ?? loadDictionaries(config);
40
- const dictionaryModeMap = {};
41
- dictionaries.forEach((dictionary) => {
42
- dictionaryModeMap[dictionary.key] = dictionary.importMode ?? importMode;
43
- });
44
- return {
45
- optimize,
46
- dictionariesDir,
47
- dictionariesEntryPath,
48
- unmergedDictionariesDir,
49
- unmergedDictionariesEntryPath,
50
- dynamicDictionariesDir,
51
- dynamicDictionariesEntryPath,
52
- fetchDictionariesDir,
53
- fetchDictionariesEntryPath,
54
- replaceDictionaryEntry: true,
55
- importMode,
56
- dictionaryModeMap,
57
- filesList,
58
- ...overrides
59
- };
60
- };
61
-
62
- //#endregion
63
- export { getOptimizePluginOptions };
1
+ import{__require as e}from"./_virtual/_rolldown/runtime.mjs";import{join as t}from"node:path";import{getComponentTransformPatternSync as n}from"@intlayer/chokidar/utils";import{getConfiguration as r}from"@intlayer/config/node";const i=t=>{try{let{getDictionaries:n}=e(`@intlayer/dictionaries-entry`),r=n(t);return Object.values(r)}catch{return[]}},a=e=>{let{configOptions:a,dictionaries:o,overrides:s}=e??{},c=r(a),{mainDir:l,dictionariesDir:u,unmergedDictionariesDir:d,dynamicDictionariesDir:f,fetchDictionariesDir:p}=c.system,{importMode:m,optimize:h}=c.build,g=n(c),_=t(l,`dictionaries.mjs`),v=t(l,`unmerged_dictionaries.mjs`),y=t(l,`dynamic_dictionaries.mjs`),b=t(l,`fetch_dictionaries.mjs`),x=[...g,_,v],S=o??i(c),C={};return S.forEach(e=>{C[e.key]=e.importMode??m}),{optimize:h,dictionariesDir:u,dictionariesEntryPath:_,unmergedDictionariesDir:d,unmergedDictionariesEntryPath:v,dynamicDictionariesDir:f,dynamicDictionariesEntryPath:y,fetchDictionariesDir:p,fetchDictionariesEntryPath:b,replaceDictionaryEntry:!0,importMode:m,dictionaryModeMap:C,filesList:x,...s}};export{a as getOptimizePluginOptions};
64
2
  //# sourceMappingURL=getOptimizePluginOptions.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getOptimizePluginOptions.mjs","names":[],"sources":["../../src/getOptimizePluginOptions.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { getComponentTransformPatternSync } from '@intlayer/chokidar';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport type { OptimizePluginOptions } from './babel-plugin-intlayer-optimize';\n\ntype GetOptimizePluginOptionsParams = {\n /**\n * Configuration options for loading intlayer config\n */\n configOptions?: GetConfigurationOptions;\n /**\n * Pre-loaded dictionaries (optional - will be loaded if not provided)\n */\n dictionaries?: Dictionary[];\n /**\n * Override specific options\n */\n overrides?: Partial<OptimizePluginOptions>;\n};\n\n/**\n * Load dictionaries from the dictionaries-entry package\n */\nconst loadDictionaries = (config: IntlayerConfig): Dictionary[] => {\n try {\n // Dynamic require to avoid build-time dependency issues\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { getDictionaries } = require('@intlayer/dictionaries-entry');\n const dictionariesRecord = getDictionaries(config) as Record<\n string,\n Dictionary\n >;\n return Object.values(dictionariesRecord);\n } catch {\n // If dictionaries-entry is not available, return empty array\n return [];\n }\n};\n\n/**\n * Get the options for the Intlayer Babel optimization plugin\n * This function loads the Intlayer configuration and returns the paths\n * needed for dictionary optimization and import rewriting.\n */\nexport const getOptimizePluginOptions = (\n params?: GetOptimizePluginOptionsParams\n): OptimizePluginOptions => {\n const {\n configOptions,\n dictionaries: providedDictionaries,\n overrides,\n } = params ?? {};\n\n const config = getConfiguration(configOptions);\n const {\n mainDir,\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n fetchDictionariesDir,\n } = config.system;\n const { importMode, optimize } = config.build;\n\n // Build files list from traverse pattern\n const filesListPattern = getComponentTransformPatternSync(config);\n\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n const unmergedDictionariesEntryPath = join(\n mainDir,\n 'unmerged_dictionaries.mjs'\n );\n const dynamicDictionariesEntryPath = join(\n mainDir,\n 'dynamic_dictionaries.mjs'\n );\n const fetchDictionariesEntryPath = join(mainDir, 'fetch_dictionaries.mjs');\n\n const filesList = [\n ...filesListPattern,\n dictionariesEntryPath, // should add dictionariesEntryPath to replace it by an empty object if import made dynamic\n unmergedDictionariesEntryPath, // should add dictionariesEntryPath to replace it by an empty object if import made dynamic\n ];\n\n // Load dictionaries if not provided\n const dictionaries = providedDictionaries ?? loadDictionaries(config);\n\n const dictionaryModeMap: Record<string, 'static' | 'dynamic' | 'fetch'> = {};\n\n dictionaries.forEach((dictionary) => {\n dictionaryModeMap[dictionary.key] = dictionary.importMode ?? importMode;\n });\n\n return {\n optimize,\n dictionariesDir,\n dictionariesEntryPath,\n unmergedDictionariesDir,\n unmergedDictionariesEntryPath,\n dynamicDictionariesDir,\n dynamicDictionariesEntryPath,\n fetchDictionariesDir,\n fetchDictionariesEntryPath,\n replaceDictionaryEntry: true,\n importMode,\n dictionaryModeMap,\n filesList,\n ...overrides,\n };\n};\n"],"mappings":";;;;;;;;;AA2BA,MAAM,oBAAoB,WAAyC;AACjE,KAAI;EAGF,MAAM,EAAE,8BAA4B,+BAA+B;EACnE,MAAM,qBAAqB,gBAAgB,OAAO;AAIlD,SAAO,OAAO,OAAO,mBAAmB;SAClC;AAEN,SAAO,EAAE;;;;;;;;AASb,MAAa,4BACX,WAC0B;CAC1B,MAAM,EACJ,eACA,cAAc,sBACd,cACE,UAAU,EAAE;CAEhB,MAAM,SAAS,iBAAiB,cAAc;CAC9C,MAAM,EACJ,SACA,iBACA,yBACA,wBACA,yBACE,OAAO;CACX,MAAM,EAAE,YAAY,aAAa,OAAO;CAGxC,MAAM,mBAAmB,iCAAiC,OAAO;CAEjE,MAAM,wBAAwB,KAAK,SAAS,mBAAmB;CAC/D,MAAM,gCAAgC,KACpC,SACA,4BACD;CACD,MAAM,+BAA+B,KACnC,SACA,2BACD;CACD,MAAM,6BAA6B,KAAK,SAAS,yBAAyB;CAE1E,MAAM,YAAY;EAChB,GAAG;EACH;EACA;EACD;CAGD,MAAM,eAAe,wBAAwB,iBAAiB,OAAO;CAErE,MAAM,oBAAoE,EAAE;AAE5E,cAAa,SAAS,eAAe;AACnC,oBAAkB,WAAW,OAAO,WAAW,cAAc;GAC7D;AAEF,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,wBAAwB;EACxB;EACA;EACA;EACA,GAAG;EACJ"}
1
+ {"version":3,"file":"getOptimizePluginOptions.mjs","names":[],"sources":["../../src/getOptimizePluginOptions.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { getComponentTransformPatternSync } from '@intlayer/chokidar/utils';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport type { OptimizePluginOptions } from './babel-plugin-intlayer-optimize';\n\ntype GetOptimizePluginOptionsParams = {\n /**\n * Configuration options for loading intlayer config\n */\n configOptions?: GetConfigurationOptions;\n /**\n * Pre-loaded dictionaries (optional - will be loaded if not provided)\n */\n dictionaries?: Dictionary[];\n /**\n * Override specific options\n */\n overrides?: Partial<OptimizePluginOptions>;\n};\n\n/**\n * Load dictionaries from the dictionaries-entry package\n */\nconst loadDictionaries = (config: IntlayerConfig): Dictionary[] => {\n try {\n // Dynamic require to avoid build-time dependency issues\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { getDictionaries } = require('@intlayer/dictionaries-entry');\n const dictionariesRecord = getDictionaries(config) as Record<\n string,\n Dictionary\n >;\n return Object.values(dictionariesRecord);\n } catch {\n // If dictionaries-entry is not available, return empty array\n return [];\n }\n};\n\n/**\n * Get the options for the Intlayer Babel optimization plugin\n * This function loads the Intlayer configuration and returns the paths\n * needed for dictionary optimization and import rewriting.\n */\nexport const getOptimizePluginOptions = (\n params?: GetOptimizePluginOptionsParams\n): OptimizePluginOptions => {\n const {\n configOptions,\n dictionaries: providedDictionaries,\n overrides,\n } = params ?? {};\n\n const config = getConfiguration(configOptions);\n const {\n mainDir,\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n fetchDictionariesDir,\n } = config.system;\n const { importMode, optimize } = config.build;\n\n // Build files list from traverse pattern\n const filesListPattern = getComponentTransformPatternSync(config);\n\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n const unmergedDictionariesEntryPath = join(\n mainDir,\n 'unmerged_dictionaries.mjs'\n );\n const dynamicDictionariesEntryPath = join(\n mainDir,\n 'dynamic_dictionaries.mjs'\n );\n const fetchDictionariesEntryPath = join(mainDir, 'fetch_dictionaries.mjs');\n\n const filesList = [\n ...filesListPattern,\n dictionariesEntryPath, // should add dictionariesEntryPath to replace it by an empty object if import made dynamic\n unmergedDictionariesEntryPath, // should add dictionariesEntryPath to replace it by an empty object if import made dynamic\n ];\n\n // Load dictionaries if not provided\n const dictionaries = providedDictionaries ?? loadDictionaries(config);\n\n const dictionaryModeMap: Record<string, 'static' | 'dynamic' | 'fetch'> = {};\n\n dictionaries.forEach((dictionary) => {\n dictionaryModeMap[dictionary.key] = dictionary.importMode ?? importMode;\n });\n\n return {\n optimize,\n dictionariesDir,\n dictionariesEntryPath,\n unmergedDictionariesDir,\n unmergedDictionariesEntryPath,\n dynamicDictionariesDir,\n dynamicDictionariesEntryPath,\n fetchDictionariesDir,\n fetchDictionariesEntryPath,\n replaceDictionaryEntry: true,\n importMode,\n dictionaryModeMap,\n filesList,\n ...overrides,\n };\n};\n"],"mappings":"mOA2BA,MAAM,EAAoB,GAAyC,CACjE,GAAI,CAGF,GAAM,CAAE,mBAAA,EAA4B,+BAA+B,CAC7D,EAAqB,EAAgB,EAAO,CAIlD,OAAO,OAAO,OAAO,EAAmB,MAClC,CAEN,MAAO,EAAE,GASA,EACX,GAC0B,CAC1B,GAAM,CACJ,gBACA,aAAc,EACd,aACE,GAAU,EAAE,CAEV,EAAS,EAAiB,EAAc,CACxC,CACJ,UACA,kBACA,0BACA,yBACA,wBACE,EAAO,OACL,CAAE,aAAY,YAAa,EAAO,MAGlC,EAAmB,EAAiC,EAAO,CAE3D,EAAwB,EAAK,EAAS,mBAAmB,CACzD,EAAgC,EACpC,EACA,4BACD,CACK,EAA+B,EACnC,EACA,2BACD,CACK,EAA6B,EAAK,EAAS,yBAAyB,CAEpE,EAAY,CAChB,GAAG,EACH,EACA,EACD,CAGK,EAAe,GAAwB,EAAiB,EAAO,CAE/D,EAAoE,EAAE,CAM5E,OAJA,EAAa,QAAS,GAAe,CACnC,EAAkB,EAAW,KAAO,EAAW,YAAc,GAC7D,CAEK,CACL,WACA,kBACA,wBACA,0BACA,gCACA,yBACA,+BACA,uBACA,6BACA,uBAAwB,GACxB,aACA,oBACA,YACA,GAAG,EACJ"}
@@ -1,6 +1 @@
1
- import { intlayerExtractBabelPlugin } from "./babel-plugin-intlayer-extract.mjs";
2
- import { intlayerOptimizeBabelPlugin } from "./babel-plugin-intlayer-optimize.mjs";
3
- import { getExtractPluginOptions } from "./getExtractPluginOptions.mjs";
4
- import { getOptimizePluginOptions } from "./getOptimizePluginOptions.mjs";
5
-
6
- export { getExtractPluginOptions, getOptimizePluginOptions, intlayerExtractBabelPlugin, intlayerOptimizeBabelPlugin };
1
+ import{intlayerExtractBabelPlugin as e}from"./babel-plugin-intlayer-extract.mjs";import{intlayerOptimizeBabelPlugin as t}from"./babel-plugin-intlayer-optimize.mjs";import{getExtractPluginOptions as n}from"./getExtractPluginOptions.mjs";import{getOptimizePluginOptions as r}from"./getOptimizePluginOptions.mjs";export{n as getExtractPluginOptions,r as getOptimizePluginOptions,e as intlayerExtractBabelPlugin,t as intlayerOptimizeBabelPlugin};
@@ -1 +1 @@
1
- {"version":3,"file":"getExtractPluginOptions.d.ts","names":[],"sources":["../../src/getExtractPluginOptions.ts"],"mappings":";;;;;AA6BA;;;cAAa,uBAAA,QAA8B,oBAAA"}
1
+ {"version":3,"file":"getExtractPluginOptions.d.ts","names":[],"sources":["../../src/getExtractPluginOptions.ts"],"mappings":";;;;;AAgCA;;;cAAa,uBAAA,QAA8B,oBAAA"}
@@ -1,5 +1,5 @@
1
1
  import { OptimizePluginOptions } from "./babel-plugin-intlayer-optimize.js";
2
- import { GetConfigurationOptions } from "@intlayer/config";
2
+ import { GetConfigurationOptions } from "@intlayer/config/node";
3
3
  import { Dictionary } from "@intlayer/types";
4
4
 
5
5
  //#region src/getOptimizePluginOptions.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/babel",
3
- "version": "8.1.2",
3
+ "version": "8.1.3",
4
4
  "private": false,
5
5
  "description": "A Babel plugin for Intlayer that transforms declaration files and provides internationalization features during the build process according to the Intlayer configuration.",
6
6
  "keywords": [
@@ -81,16 +81,16 @@
81
81
  "@babel/parser": "7.1.5",
82
82
  "@babel/traverse": "7.28.0",
83
83
  "@babel/types": "7.28.4",
84
- "@intlayer/chokidar": "8.1.2",
85
- "@intlayer/config": "8.1.2",
86
- "@intlayer/types": "8.1.2",
84
+ "@intlayer/chokidar": "8.1.3",
85
+ "@intlayer/config": "8.1.3",
86
+ "@intlayer/types": "8.1.3",
87
87
  "@types/babel__core": "7.20.5",
88
88
  "@types/babel__generator": "7.27.0",
89
89
  "@types/babel__traverse": "7.28.0",
90
90
  "fast-glob": "3.3.3"
91
91
  },
92
92
  "devDependencies": {
93
- "@intlayer/dictionaries-entry": "8.1.2",
93
+ "@intlayer/dictionaries-entry": "8.1.3",
94
94
  "@types/crypto-js": "4.2.2",
95
95
  "@types/node": "25.2.3",
96
96
  "@utils/ts-config": "1.0.4",
@@ -102,7 +102,7 @@
102
102
  "vitest": "4.0.18"
103
103
  },
104
104
  "peerDependencies": {
105
- "@intlayer/dictionaries-entry": "8.1.2"
105
+ "@intlayer/dictionaries-entry": "8.1.3"
106
106
  },
107
107
  "peerDependenciesMeta": {
108
108
  "@intlayer/dictionaries-entry": {