@intlayer/babel 9.0.0-canary.11 → 9.0.0-canary.13
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.
- package/dist/cjs/babel-plugin-intlayer-extract.cjs +2 -1
- package/dist/cjs/babel-plugin-intlayer-extract.cjs.map +1 -1
- package/dist/cjs/babel-plugin-intlayer-field-rename.cjs +3 -2
- package/dist/cjs/babel-plugin-intlayer-field-rename.cjs.map +1 -1
- package/dist/cjs/babel-plugin-intlayer-optimize.cjs +141 -11
- package/dist/cjs/babel-plugin-intlayer-optimize.cjs.map +1 -1
- package/dist/cjs/babel-plugin-intlayer-purge.cjs +1 -1
- package/dist/cjs/babel-plugin-intlayer-purge.cjs.map +1 -1
- package/dist/cjs/babel-plugin-intlayer-usage-analyzer.cjs +47 -16
- package/dist/cjs/babel-plugin-intlayer-usage-analyzer.cjs.map +1 -1
- package/dist/cjs/extractContent/babelProcessor.cjs +85 -74
- package/dist/cjs/extractContent/babelProcessor.cjs.map +1 -1
- package/dist/cjs/extractContent/contentWriter.cjs +10 -14
- package/dist/cjs/extractContent/contentWriter.cjs.map +1 -1
- package/dist/cjs/extractContent/extractContent.cjs +3 -3
- package/dist/cjs/extractContent/extractContent.cjs.map +1 -1
- package/dist/cjs/extractContent/processTsxFile.cjs +3 -6
- package/dist/cjs/extractContent/processTsxFile.cjs.map +1 -1
- package/dist/cjs/extractContent/utils/constants.cjs +1 -1
- package/dist/cjs/extractContent/utils/constants.cjs.map +1 -1
- package/dist/cjs/extractContent/utils/extractDictionaryInfo.cjs +4 -4
- package/dist/cjs/extractContent/utils/extractDictionaryInfo.cjs.map +1 -1
- package/dist/cjs/extractContent/utils/extractDictionaryKey.cjs +2 -2
- package/dist/cjs/extractContent/utils/extractDictionaryKey.cjs.map +1 -1
- package/dist/cjs/getExtractPluginOptions.cjs +2 -2
- package/dist/cjs/getExtractPluginOptions.cjs.map +1 -1
- package/dist/cjs/getOptimizePluginOptions.cjs +2 -2
- package/dist/cjs/getOptimizePluginOptions.cjs.map +1 -1
- package/dist/cjs/getPurgePluginOptions.cjs +2 -2
- package/dist/cjs/getPurgePluginOptions.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/normalizedFilesList.cjs +31 -0
- package/dist/cjs/normalizedFilesList.cjs.map +1 -0
- package/dist/cjs/transformers.cjs +20 -1
- package/dist/cjs/transformers.cjs.map +1 -1
- package/dist/esm/babel-plugin-intlayer-extract.mjs +2 -1
- package/dist/esm/babel-plugin-intlayer-extract.mjs.map +1 -1
- package/dist/esm/babel-plugin-intlayer-field-rename.mjs +3 -2
- package/dist/esm/babel-plugin-intlayer-field-rename.mjs.map +1 -1
- package/dist/esm/babel-plugin-intlayer-optimize.mjs +138 -8
- package/dist/esm/babel-plugin-intlayer-optimize.mjs.map +1 -1
- package/dist/esm/babel-plugin-intlayer-purge.mjs +2 -2
- package/dist/esm/babel-plugin-intlayer-purge.mjs.map +1 -1
- package/dist/esm/babel-plugin-intlayer-usage-analyzer.mjs +47 -16
- package/dist/esm/babel-plugin-intlayer-usage-analyzer.mjs.map +1 -1
- package/dist/esm/extractContent/babelProcessor.mjs +85 -74
- package/dist/esm/extractContent/babelProcessor.mjs.map +1 -1
- package/dist/esm/extractContent/contentWriter.mjs +6 -10
- package/dist/esm/extractContent/contentWriter.mjs.map +1 -1
- package/dist/esm/extractContent/extractContent.mjs +1 -1
- package/dist/esm/extractContent/extractContent.mjs.map +1 -1
- package/dist/esm/extractContent/processTsxFile.mjs +2 -5
- package/dist/esm/extractContent/processTsxFile.mjs.map +1 -1
- package/dist/esm/extractContent/utils/constants.mjs +1 -1
- package/dist/esm/extractContent/utils/constants.mjs.map +1 -1
- package/dist/esm/extractContent/utils/extractDictionaryInfo.mjs +1 -1
- package/dist/esm/extractContent/utils/extractDictionaryInfo.mjs.map +1 -1
- package/dist/esm/extractContent/utils/extractDictionaryKey.mjs +1 -1
- package/dist/esm/extractContent/utils/extractDictionaryKey.mjs.map +1 -1
- package/dist/esm/getExtractPluginOptions.mjs +1 -1
- package/dist/esm/getExtractPluginOptions.mjs.map +1 -1
- package/dist/esm/getOptimizePluginOptions.mjs +1 -1
- package/dist/esm/getOptimizePluginOptions.mjs.map +1 -1
- package/dist/esm/getPurgePluginOptions.mjs +1 -1
- package/dist/esm/getPurgePluginOptions.mjs.map +1 -1
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/normalizedFilesList.mjs +29 -0
- package/dist/esm/normalizedFilesList.mjs.map +1 -0
- package/dist/esm/transformers.mjs +20 -2
- package/dist/esm/transformers.mjs.map +1 -1
- package/dist/types/babel-plugin-intlayer-extract.d.ts.map +1 -1
- package/dist/types/babel-plugin-intlayer-field-rename.d.ts.map +1 -1
- package/dist/types/babel-plugin-intlayer-optimize.d.ts +17 -1
- package/dist/types/babel-plugin-intlayer-optimize.d.ts.map +1 -1
- package/dist/types/babel-plugin-intlayer-purge.d.ts.map +1 -1
- package/dist/types/babel-plugin-intlayer-usage-analyzer.d.ts +8 -116
- package/dist/types/babel-plugin-intlayer-usage-analyzer.d.ts.map +1 -1
- package/dist/types/extractContent/babelProcessor.d.ts +3 -1
- package/dist/types/extractContent/babelProcessor.d.ts.map +1 -1
- package/dist/types/extractContent/contentWriter.d.ts.map +1 -1
- package/dist/types/extractContent/index.d.ts +1 -1
- package/dist/types/extractContent/processTsxFile.d.ts.map +1 -1
- package/dist/types/extractContent/utils/constants.d.ts +1 -1
- package/dist/types/index.d.ts +4 -4
- package/dist/types/normalizedFilesList.d.ts +12 -0
- package/dist/types/normalizedFilesList.d.ts.map +1 -0
- package/dist/types/transformers.d.ts +7 -1
- package/dist/types/transformers.d.ts.map +1 -1
- package/package.json +17 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractDictionaryKey.mjs","names":[],"sources":["../../../../src/extractContent/utils/extractDictionaryKey.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"extractDictionaryKey.mjs","names":[],"sources":["../../../../src/extractContent/utils/extractDictionaryKey.ts"],"sourcesContent":["import { COMPILER_DICTIONARY_KEY_PREFIX } from '@intlayer/config/defaultValues';\nimport { camelCaseToKebabCase } from '@intlayer/config/utils';\nimport { detectExportedComponentName } from '@intlayer/engine/cli';\n\n/**\n * Extracts a dictionary key from a file path.\n *\n * Example: \"src/components/MyComponent/index.tsx\" -> \"comp-my-component\"\n */\nexport const extractDictionaryKeyFromPath = (\n filePath: string,\n prefix = COMPILER_DICTIONARY_KEY_PREFIX\n): string => {\n const pathParts = filePath.split(/[\\\\/]/);\n const fileNameWithExt = pathParts.pop() || '';\n const lastDotIndex = fileNameWithExt.lastIndexOf('.');\n let baseName =\n lastDotIndex !== -1\n ? fileNameWithExt.slice(0, lastDotIndex)\n : fileNameWithExt;\n\n if (baseName.toLowerCase() === 'index') {\n baseName = pathParts.pop() || baseName;\n }\n\n return `${prefix}${camelCaseToKebabCase(baseName)}`;\n};\n\nexport const extractDictionaryKey = (\n filePath: string,\n fileText: string,\n prefix = COMPILER_DICTIONARY_KEY_PREFIX\n): string => {\n const componentName = detectExportedComponentName(fileText);\n\n if (componentName) {\n return `${prefix}${camelCaseToKebabCase(componentName)}`;\n }\n\n return extractDictionaryKeyFromPath(filePath, prefix);\n};\n"],"mappings":";;;;;;;;;;AASA,MAAa,gCACX,UACA,SAAS,mCACE;CACX,MAAM,YAAY,SAAS,MAAM,QAAQ;CACzC,MAAM,kBAAkB,UAAU,KAAK,IAAI;CAC3C,MAAM,eAAe,gBAAgB,YAAY,IAAI;CACrD,IAAI,WACF,iBAAiB,KACb,gBAAgB,MAAM,GAAG,aAAa,GACtC;AAEN,KAAI,SAAS,aAAa,KAAK,QAC7B,YAAW,UAAU,KAAK,IAAI;AAGhC,QAAO,GAAG,SAAS,qBAAqB,SAAS;;AAGnD,MAAa,wBACX,UACA,UACA,SAAS,mCACE;CACX,MAAM,gBAAgB,4BAA4B,SAAS;AAE3D,KAAI,cACF,QAAO,GAAG,SAAS,qBAAqB,cAAc;AAGxD,QAAO,6BAA6B,UAAU,OAAO"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { writeContentHelper } from "./extractContent/contentWriter.mjs";
|
|
2
|
-
import { buildComponentFilesList } from "@intlayer/chokidar/utils";
|
|
3
2
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
4
3
|
import { COMPILER_ENABLED } from "@intlayer/config/defaultValues";
|
|
5
4
|
import { colorize, colorizeKey, getAppLogger } from "@intlayer/config/logger";
|
|
6
5
|
import { getConfiguration } from "@intlayer/config/node";
|
|
6
|
+
import { buildComponentFilesList } from "@intlayer/engine/utils";
|
|
7
7
|
|
|
8
8
|
//#region src/getExtractPluginOptions.ts
|
|
9
9
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getExtractPluginOptions.mjs","names":[],"sources":["../../src/getExtractPluginOptions.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"getExtractPluginOptions.mjs","names":[],"sources":["../../src/getExtractPluginOptions.ts"],"sourcesContent":["import * as ANSIColors from '@intlayer/config/colors';\nimport { COMPILER_ENABLED } from '@intlayer/config/defaultValues';\nimport { colorize, colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { buildComponentFilesList } from '@intlayer/engine/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { ExtractPluginOptions } from './babel-plugin-intlayer-extract';\nimport { writeContentHelper } from './extractContent/contentWriter';\n\n/**\n * Mode of the compiler\n * - 'dev': Development mode with HMR support\n * - 'build': Production build mode\n */\nexport type CompilerMode = 'dev' | 'build';\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 = (\n configuration: IntlayerConfig = getConfiguration(),\n isDev: CompilerMode | string | undefined = process.env.INTLAYER_IS_DEV_COMMAND\n): ExtractPluginOptions => {\n // Accept 'dev'/'serve' (Vite), boolean true, or the string 'true' (env var)\n const isDevBoolean = isDev === 'dev' || isDev === 'serve' || isDev === 'true';\n\n const compilerMode: CompilerMode = isDevBoolean ? 'dev' : 'build';\n\n const logger = getAppLogger(configuration);\n\n if (configuration.compiler?.enabled === 'build-only' && isDevBoolean) {\n logger(\n `${colorize('Compiler:', ANSIColors.GREY_DARK)} i18n function is not inserted in the code in dev mode to optimize build time. (to test i18n in dev mode set compiler.enabled to true)`\n );\n }\n\n let enabled = configuration.compiler?.enabled ?? COMPILER_ENABLED;\n\n if (enabled === 'build-only') {\n if (compilerMode) {\n enabled = compilerMode === 'build';\n } else {\n // Fallback if mode isn't explicitly provided (e.g. pure babel plugin context)\n enabled = process.env.NODE_ENV === 'production';\n }\n }\n\n const filesList = buildComponentFilesList(configuration);\n\n return {\n enabled,\n configuration,\n filesList,\n onExtract: async ({ dictionaryKey, content, filePath }) => {\n try {\n await writeContentHelper(\n content,\n dictionaryKey,\n filePath,\n configuration\n );\n } catch (error) {\n logger(\n [\n `Failed to process extracted content for ${colorizeKey(dictionaryKey)}:`,\n error,\n ],\n { level: 'error' }\n );\n }\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;AAqBA,MAAa,2BACX,gBAAgC,kBAAkB,EAClD,QAA2C,QAAQ,IAAI,4BAC9B;CAEzB,MAAM,eAAe,UAAU,SAAS,UAAU,WAAW,UAAU;CAEvE,MAAM,eAA6B,eAAe,QAAQ;CAE1D,MAAM,SAAS,aAAa,cAAc;AAE1C,KAAI,cAAc,UAAU,YAAY,gBAAgB,aACtD,QACE,GAAG,SAAS,aAAa,WAAW,UAAU,CAAC,wIAChD;CAGH,IAAI,UAAU,cAAc,UAAU,WAAW;AAEjD,KAAI,YAAY,aACd,KAAI,aACF,WAAU,iBAAiB;KAG3B,WAAU;CAId,MAAM,YAAY,wBAAwB,cAAc;AAExD,QAAO;EACL;EACA;EACA;EACA,WAAW,OAAO,EAAE,eAAe,SAAS,eAAe;AACzD,OAAI;AACF,UAAM,mBACJ,SACA,eACA,UACA,cACD;YACM,OAAO;AACd,WACE,CACE,2CAA2C,YAAY,cAAc,CAAC,IACtE,MACD,EACD,EAAE,OAAO,SAAS,CACnB;;;EAGN"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __require } from "./_virtual/_rolldown/runtime.mjs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { buildComponentFilesList } from "@intlayer/chokidar/utils";
|
|
4
3
|
import { getConfiguration } from "@intlayer/config/node";
|
|
4
|
+
import { buildComponentFilesList } from "@intlayer/engine/utils";
|
|
5
5
|
|
|
6
6
|
//#region src/getOptimizePluginOptions.ts
|
|
7
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOptimizePluginOptions.mjs","names":[],"sources":["../../src/getOptimizePluginOptions.ts"],"sourcesContent":["import { join } from 'node:path';\nimport {
|
|
1
|
+
{"version":3,"file":"getOptimizePluginOptions.mjs","names":[],"sources":["../../src/getOptimizePluginOptions.ts"],"sourcesContent":["import { join } from 'node:path';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { buildComponentFilesList } from '@intlayer/engine/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\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 * Whether the current transform is for an SSR bundle. When using Babel\n * directly (e.g. in `babel.config.js`), forward the bundler's server flag\n * here so SSR-specific static dictionary transforms apply.\n */\n isServer?: boolean;\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);\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 isServer,\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 = config.build.importMode ?? config.dictionary?.importMode;\n const optimize = config.build.optimize;\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 filesListPattern = buildComponentFilesList(config);\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<\n string,\n 'static' | 'dynamic' | 'fetch' | undefined\n > = {};\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 isServer,\n ...overrides,\n };\n};\n"],"mappings":";;;;;;;;;AAkCA,MAAM,oBAAoB,WAAyC;AACjE,KAAI;EAGF,MAAM,EAAE,8BAA4B,+BAA+B;EACnE,MAAM,qBAAqB,gBAAgB,OAAO;AAElD,SAAO,OAAO,OAAO,mBAAmB;SAClC;AAEN,SAAO,EAAE;;;;;;;;AASb,MAAa,4BACX,WAC0B;CAC1B,MAAM,EACJ,eACA,cAAc,sBACd,UACA,cACE,UAAU,EAAE;CAEhB,MAAM,SAAS,iBAAiB,cAAc;CAC9C,MAAM,EACJ,SACA,iBACA,yBACA,wBACA,yBACE,OAAO;CACX,MAAM,aAAa,OAAO,MAAM,cAAc,OAAO,YAAY;CACjE,MAAM,WAAW,OAAO,MAAM;CAE9B,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;CAI1E,MAAM,YAAY;EAChB,GAHuB,wBAAwB,OAG5B;EACnB;EACA;EACD;CAGD,MAAM,eAAe,wBAAwB,iBAAiB,OAAO;CAErE,MAAM,oBAGF,EAAE;AAEN,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;EACA,GAAG;EACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __require } from "./_virtual/_rolldown/runtime.mjs";
|
|
2
|
-
import { buildComponentFilesList } from "@intlayer/chokidar/utils";
|
|
3
2
|
import { IMPORT_MODE } from "@intlayer/config/defaultValues";
|
|
4
3
|
import { getConfiguration } from "@intlayer/config/node";
|
|
4
|
+
import { buildComponentFilesList } from "@intlayer/engine/utils";
|
|
5
5
|
|
|
6
6
|
//#region src/getPurgePluginOptions.ts
|
|
7
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPurgePluginOptions.mjs","names":[],"sources":["../../src/getPurgePluginOptions.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"getPurgePluginOptions.mjs","names":[],"sources":["../../src/getPurgePluginOptions.ts"],"sourcesContent":["import { IMPORT_MODE } from '@intlayer/config/defaultValues';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { buildComponentFilesList } from '@intlayer/engine/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { MinifyPluginOptions } from './babel-plugin-intlayer-minify';\nimport type { PurgePluginOptions } from './babel-plugin-intlayer-purge';\n\n// ── Shared config helpers ─────────────────────────────────────────────────────\n\n/**\n * Attempts to load compiled dictionaries from `@intlayer/dictionaries-entry`.\n * Returns an empty array if the entry point is not available (e.g. dictionaries\n * have not been built yet).\n */\nconst loadDictionaries = (config: IntlayerConfig): Dictionary[] => {\n try {\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 return [];\n }\n};\n\n// ── getPurgePluginOptions ─────────────────────────────────────────────────────\n\ntype GetPurgePluginOptionsParams = {\n /**\n * Options forwarded to the intlayer configuration loader.\n * Pass this when `intlayer.config.ts` lives outside the default search path\n * (e.g. in a monorepo workspace root).\n */\n configOptions?: GetConfigurationOptions;\n\n /**\n * Pre-loaded dictionaries (optional – loaded automatically when omitted).\n * Providing them avoids a second `getDictionaries` call when you already\n * have them at hand.\n */\n dictionaries?: Dictionary[];\n\n /**\n * Override specific resolved option values after the defaults are computed.\n */\n overrides?: Partial<PurgePluginOptions>;\n};\n\n/**\n * Returns fully-resolved options for {@link intlayerPurgeBabelPlugin}.\n *\n * Loads the intlayer configuration once at babel.config.js evaluation time so\n * the plugin itself does not need to re-read the config on every file\n * transform.\n *\n * @example\n * ```js\n * // babel.config.js\n * const {\n * intlayerPurgeBabelPlugin,\n * getPurgePluginOptions,\n * } = require(\"@intlayer/babel\");\n *\n * module.exports = {\n * presets: [\"next/babel\"],\n * plugins: [\n * [intlayerPurgeBabelPlugin, getPurgePluginOptions()],\n * ],\n * };\n * ```\n */\nexport const getPurgePluginOptions = (\n params?: GetPurgePluginOptionsParams\n): PurgePluginOptions => {\n const {\n configOptions,\n dictionaries: providedDictionaries,\n overrides,\n } = params ?? {};\n\n const config = getConfiguration(configOptions);\n\n const { baseDir, dictionariesDir, dynamicDictionariesDir } = config.system;\n const { purge, minify, optimize } = config.build;\n const editorEnabled = config.editor.enabled;\n\n const importMode = config.build.importMode ?? config.dictionary?.importMode;\n\n const componentFilesList = buildComponentFilesList(config);\n\n const dictionaries = providedDictionaries ?? loadDictionaries(config);\n\n const dictionaryKeyToImportModeMap: Record<\n string,\n 'static' | 'dynamic' | 'fetch' | undefined\n > = {};\n for (const dictionary of dictionaries) {\n dictionaryKeyToImportModeMap[dictionary.key] =\n dictionary.importMode ?? importMode ?? IMPORT_MODE;\n }\n\n return {\n baseDir,\n purge: Boolean(purge),\n minify: Boolean(minify),\n optimize,\n editorEnabled,\n dictionariesDir,\n dynamicDictionariesDir,\n componentFilesList,\n dictionaryKeyToImportModeMap,\n ...overrides,\n };\n};\n\n// ── getMinifyPluginOptions ────────────────────────────────────────────────────\n\ntype GetMinifyPluginOptionsParams = {\n /**\n * Options forwarded to the intlayer configuration loader.\n */\n configOptions?: GetConfigurationOptions;\n\n /**\n * Override specific resolved option values after the defaults are computed.\n */\n overrides?: Partial<MinifyPluginOptions>;\n};\n\n/**\n * Returns fully-resolved options for {@link intlayerMinifyBabelPlugin}.\n *\n * Loads the intlayer configuration once at babel.config.js evaluation time.\n *\n * @example\n * ```js\n * // babel.config.js\n * const {\n * intlayerMinifyBabelPlugin,\n * getMinifyPluginOptions,\n * } = require(\"@intlayer/babel\");\n *\n * module.exports = {\n * presets: [\"next/babel\"],\n * plugins: [\n * [intlayerMinifyBabelPlugin, getMinifyPluginOptions()],\n * ],\n * };\n * ```\n */\nexport const getMinifyPluginOptions = (\n params?: GetMinifyPluginOptionsParams\n): MinifyPluginOptions => {\n const { configOptions, overrides } = params ?? {};\n\n const config = getConfiguration(configOptions);\n\n const { baseDir } = config.system;\n const { minify, optimize } = config.build;\n const editorEnabled = config.editor.enabled;\n\n return {\n baseDir,\n minify: Boolean(minify),\n optimize,\n editorEnabled,\n ...overrides,\n };\n};\n"],"mappings":";;;;;;;;;;;AAkBA,MAAM,oBAAoB,WAAyC;AACjE,KAAI;EAEF,MAAM,EAAE,8BAA4B,+BAA+B;EACnE,MAAM,qBAAqB,gBAAgB,OAAO;AAIlD,SAAO,OAAO,OAAO,mBAAmB;SAClC;AACN,SAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDb,MAAa,yBACX,WACuB;CACvB,MAAM,EACJ,eACA,cAAc,sBACd,cACE,UAAU,EAAE;CAEhB,MAAM,SAAS,iBAAiB,cAAc;CAE9C,MAAM,EAAE,SAAS,iBAAiB,2BAA2B,OAAO;CACpE,MAAM,EAAE,OAAO,QAAQ,aAAa,OAAO;CAC3C,MAAM,gBAAgB,OAAO,OAAO;CAEpC,MAAM,aAAa,OAAO,MAAM,cAAc,OAAO,YAAY;CAEjE,MAAM,qBAAqB,wBAAwB,OAAO;CAE1D,MAAM,eAAe,wBAAwB,iBAAiB,OAAO;CAErE,MAAM,+BAGF,EAAE;AACN,MAAK,MAAM,cAAc,aACvB,8BAA6B,WAAW,OACtC,WAAW,cAAc,cAAc;AAG3C,QAAO;EACL;EACA,OAAO,QAAQ,MAAM;EACrB,QAAQ,QAAQ,OAAO;EACvB;EACA;EACA;EACA;EACA;EACA;EACA,GAAG;EACJ;;;;;;;;;;;;;;;;;;;;;;;AAsCH,MAAa,0BACX,WACwB;CACxB,MAAM,EAAE,eAAe,cAAc,UAAU,EAAE;CAEjD,MAAM,SAAS,iBAAiB,cAAc;CAE9C,MAAM,EAAE,YAAY,OAAO;CAC3B,MAAM,EAAE,QAAQ,aAAa,OAAO;CACpC,MAAM,gBAAgB,OAAO,OAAO;AAEpC,QAAO;EACL;EACA,QAAQ,QAAQ,OAAO;EACvB;EACA;EACA,GAAG;EACJ"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -12,10 +12,10 @@ import { extractContent, extractContentSync } from "./extractContent/extractCont
|
|
|
12
12
|
import { intlayerExtractBabelPlugin } from "./babel-plugin-intlayer-extract.mjs";
|
|
13
13
|
import { buildNestedRenameMapFromContent, generateShortFieldName, makeFieldRenameBabelPlugin } from "./babel-plugin-intlayer-field-rename.mjs";
|
|
14
14
|
import { intlayerOptimizeBabelPlugin } from "./babel-plugin-intlayer-optimize.mjs";
|
|
15
|
-
import { BABEL_PARSER_OPTIONS, INTLAYER_USAGE_REGEX, SOURCE_FILE_REGEX, analyzeFieldUsageInFile, buildUsageCheckRegex, optimizeSourceFile, renameFieldsInCode, renameFieldsInSourceFile } from "./transformers.mjs";
|
|
15
|
+
import { BABEL_PARSER_OPTIONS, INTLAYER_USAGE_REGEX, SOURCE_FILE_REGEX, analyzeFieldUsageInFile, buildUsageCheckRegex, getUsageCheckRegex, optimizeSourceFile, renameFieldsInCode, renameFieldsInSourceFile } from "./transformers.mjs";
|
|
16
16
|
import { getSharedPruneContext, intlayerPurgeBabelPlugin } from "./babel-plugin-intlayer-purge.mjs";
|
|
17
17
|
import { intlayerMinifyBabelPlugin } from "./babel-plugin-intlayer-minify.mjs";
|
|
18
18
|
import { getOptimizePluginOptions } from "./getOptimizePluginOptions.mjs";
|
|
19
19
|
import { getMinifyPluginOptions, getPurgePluginOptions } from "./getPurgePluginOptions.mjs";
|
|
20
20
|
|
|
21
|
-
export { ATTRIBUTES_TO_EXTRACT, BABEL_PARSER_OPTIONS, DEFAULT_COMPAT_CALLERS, INTLAYER_CALLER_NAMES, INTLAYER_USAGE_REGEX, SERVER_CAPABLE_PACKAGES, SOURCE_FILE_REGEX, analyzeFieldUsageInFile, buildNestedRenameMapFromContent, buildUsageCheckRegex, createPruneContext, detectPackageName, extractContent, extractContentSync, extractDictionaryInfo, extractDictionaryKey, extractDictionaryKeyFromPath, extractScriptBlocks, generateKey, generateShortFieldName, getComponentName, getExtractPluginOptions, getMinifyPluginOptions, getOptimizePluginOptions, getOutput, getPurgePluginOptions, getSharedPruneContext, injectScriptBlocks, intlayerExtractBabelPlugin, intlayerMinifyBabelPlugin, intlayerOptimizeBabelPlugin, intlayerPurgeBabelPlugin, makeFieldRenameBabelPlugin, makeUsageAnalyzerBabelPlugin, mergeWithExistingMultilingualDictionary, mergeWithExistingPerLocaleDictionary, optimizeSourceFile, packageList, renameFieldsInCode, renameFieldsInSourceFile, resolveContentFilePaths, writeContentHelper };
|
|
21
|
+
export { ATTRIBUTES_TO_EXTRACT, BABEL_PARSER_OPTIONS, DEFAULT_COMPAT_CALLERS, INTLAYER_CALLER_NAMES, INTLAYER_USAGE_REGEX, SERVER_CAPABLE_PACKAGES, SOURCE_FILE_REGEX, analyzeFieldUsageInFile, buildNestedRenameMapFromContent, buildUsageCheckRegex, createPruneContext, detectPackageName, extractContent, extractContentSync, extractDictionaryInfo, extractDictionaryKey, extractDictionaryKeyFromPath, extractScriptBlocks, generateKey, generateShortFieldName, getComponentName, getExtractPluginOptions, getMinifyPluginOptions, getOptimizePluginOptions, getOutput, getPurgePluginOptions, getSharedPruneContext, getUsageCheckRegex, injectScriptBlocks, intlayerExtractBabelPlugin, intlayerMinifyBabelPlugin, intlayerOptimizeBabelPlugin, intlayerPurgeBabelPlugin, makeFieldRenameBabelPlugin, makeUsageAnalyzerBabelPlugin, mergeWithExistingMultilingualDictionary, mergeWithExistingPerLocaleDictionary, optimizeSourceFile, packageList, renameFieldsInCode, renameFieldsInSourceFile, resolveContentFilePaths, writeContentHelper };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { normalizePath } from "@intlayer/config/utils";
|
|
2
|
+
|
|
3
|
+
//#region src/normalizedFilesList.ts
|
|
4
|
+
/**
|
|
5
|
+
* Cache of normalized files-list sets, keyed by the files-list array
|
|
6
|
+
* reference. Babel reuses the same plugin options object for every file of a
|
|
7
|
+
* build, so the (potentially large) list is normalized once per build instead
|
|
8
|
+
* of once per transformed file.
|
|
9
|
+
*/
|
|
10
|
+
const normalizedFilesListCache = /* @__PURE__ */ new WeakMap();
|
|
11
|
+
/**
|
|
12
|
+
* Returns a set of POSIX-normalized paths for the given files list, computed
|
|
13
|
+
* once per unique array reference.
|
|
14
|
+
*
|
|
15
|
+
* @param filesList - The plugin's `filesList` option (absolute file paths).
|
|
16
|
+
* @returns A set of the same paths normalized via `normalizePath`.
|
|
17
|
+
*/
|
|
18
|
+
const getNormalizedFilesListSet = (filesList) => {
|
|
19
|
+
let normalizedSet = normalizedFilesListCache.get(filesList);
|
|
20
|
+
if (!normalizedSet) {
|
|
21
|
+
normalizedSet = new Set(filesList.map(normalizePath));
|
|
22
|
+
normalizedFilesListCache.set(filesList, normalizedSet);
|
|
23
|
+
}
|
|
24
|
+
return normalizedSet;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { getNormalizedFilesListSet };
|
|
29
|
+
//# sourceMappingURL=normalizedFilesList.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizedFilesList.mjs","names":[],"sources":["../../src/normalizedFilesList.ts"],"sourcesContent":["import { normalizePath } from '@intlayer/config/utils';\n\n/**\n * Cache of normalized files-list sets, keyed by the files-list array\n * reference. Babel reuses the same plugin options object for every file of a\n * build, so the (potentially large) list is normalized once per build instead\n * of once per transformed file.\n */\nconst normalizedFilesListCache = new WeakMap<readonly string[], Set<string>>();\n\n/**\n * Returns a set of POSIX-normalized paths for the given files list, computed\n * once per unique array reference.\n *\n * @param filesList - The plugin's `filesList` option (absolute file paths).\n * @returns A set of the same paths normalized via `normalizePath`.\n */\nexport const getNormalizedFilesListSet = (\n filesList: readonly string[]\n): Set<string> => {\n let normalizedSet = normalizedFilesListCache.get(filesList);\n\n if (!normalizedSet) {\n normalizedSet = new Set(filesList.map(normalizePath));\n normalizedFilesListCache.set(filesList, normalizedSet);\n }\n\n return normalizedSet;\n};\n"],"mappings":";;;;;;;;;AAQA,MAAM,2CAA2B,IAAI,SAAyC;;;;;;;;AAS9E,MAAa,6BACX,cACgB;CAChB,IAAI,gBAAgB,yBAAyB,IAAI,UAAU;AAE3D,KAAI,CAAC,eAAe;AAClB,kBAAgB,IAAI,IAAI,UAAU,IAAI,cAAc,CAAC;AACrD,2BAAyB,IAAI,WAAW,cAAc;;AAGxD,QAAO"}
|
|
@@ -56,6 +56,24 @@ const buildUsageCheckRegex = (extraCallerNames) => {
|
|
|
56
56
|
const uniqueNames = [...new Set(callerNames)];
|
|
57
57
|
return new RegExp(`\\b(${uniqueNames.join("|")})\\b`);
|
|
58
58
|
};
|
|
59
|
+
/** Usage-check regex covering only the native callers (no compat callers). */
|
|
60
|
+
const NATIVE_USAGE_CHECK_REGEX = buildUsageCheckRegex();
|
|
61
|
+
/** Cache of usage-check regexes, keyed by the compat-caller array reference. */
|
|
62
|
+
const usageCheckRegexCache = /* @__PURE__ */ new WeakMap();
|
|
63
|
+
/**
|
|
64
|
+
* Returns the usage-check regex for the given compat callers, memoised by the
|
|
65
|
+
* array reference. Plugins pass the same options array for every analysed
|
|
66
|
+
* file, so the regex is built once per build instead of once per file.
|
|
67
|
+
*/
|
|
68
|
+
const getUsageCheckRegex = (compatCallers) => {
|
|
69
|
+
if (!compatCallers || compatCallers.length === 0) return NATIVE_USAGE_CHECK_REGEX;
|
|
70
|
+
let usageCheckRegex = usageCheckRegexCache.get(compatCallers);
|
|
71
|
+
if (!usageCheckRegex) {
|
|
72
|
+
usageCheckRegex = buildUsageCheckRegex(compatCallers.map((caller) => caller.callerName));
|
|
73
|
+
usageCheckRegexCache.set(compatCallers, usageCheckRegex);
|
|
74
|
+
}
|
|
75
|
+
return usageCheckRegex;
|
|
76
|
+
};
|
|
59
77
|
/**
|
|
60
78
|
* Matches source files that are valid targets for usage analysis and Babel
|
|
61
79
|
* transformation. Excludes sourcemap files, declaration files, and other
|
|
@@ -90,7 +108,7 @@ const analyzeScriptContent = async (scriptContent, sourceFilePath, pruneContext,
|
|
|
90
108
|
* `pruneContext.hasUnparsableSourceFiles`).
|
|
91
109
|
*/
|
|
92
110
|
const analyzeFieldUsageInFile = async (sourceFilePath, code, pruneContext, compatCallers) => {
|
|
93
|
-
const usageCheckRegex =
|
|
111
|
+
const usageCheckRegex = getUsageCheckRegex(compatCallers);
|
|
94
112
|
const scriptBlocks = extractScriptBlocks(sourceFilePath, code);
|
|
95
113
|
for (const block of scriptBlocks) {
|
|
96
114
|
if (!usageCheckRegex.test(block.content)) continue;
|
|
@@ -163,5 +181,5 @@ const optimizeSourceFile = async (code, sourceFilePath, options) => {
|
|
|
163
181
|
};
|
|
164
182
|
|
|
165
183
|
//#endregion
|
|
166
|
-
export { BABEL_PARSER_OPTIONS, INTLAYER_USAGE_REGEX, SOURCE_FILE_REGEX, analyzeFieldUsageInFile, buildUsageCheckRegex, optimizeSourceFile, renameFieldsInCode, renameFieldsInSourceFile };
|
|
184
|
+
export { BABEL_PARSER_OPTIONS, INTLAYER_USAGE_REGEX, SOURCE_FILE_REGEX, analyzeFieldUsageInFile, buildUsageCheckRegex, getUsageCheckRegex, optimizeSourceFile, renameFieldsInCode, renameFieldsInSourceFile };
|
|
167
185
|
//# sourceMappingURL=transformers.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformers.mjs","names":[],"sources":["../../src/transformers.ts"],"sourcesContent":["import { type TransformOptions, transformAsync } from '@babel/core';\nimport { makeFieldRenameBabelPlugin } from './babel-plugin-intlayer-field-rename';\nimport {\n intlayerOptimizeBabelPlugin,\n type OptimizePluginOptions,\n} from './babel-plugin-intlayer-optimize';\nimport {\n type CompatCallerConfig,\n makeUsageAnalyzerBabelPlugin,\n type PruneContext,\n} from './babel-plugin-intlayer-usage-analyzer';\nimport { extractScriptBlocks, injectScriptBlocks } from './extractScriptBlocks';\n\n// ── Shared Babel parser configuration ─────────────────────────────────────────\n\n/**\n * Babel parser options covering the superset of syntaxes used across all\n * supported frameworks (React / Vue / Svelte / Angular / …).\n */\nexport const BABEL_PARSER_OPTIONS: NonNullable<TransformOptions['parserOpts']> =\n {\n sourceType: 'module',\n allowImportExportEverywhere: true,\n plugins: [\n 'typescript',\n 'jsx',\n 'decorators-legacy',\n 'classProperties',\n 'objectRestSpread',\n 'asyncGenerators',\n 'functionBind',\n 'exportDefaultFrom',\n 'exportNamespaceFrom',\n 'dynamicImport',\n 'nullishCoalescingOperator',\n 'optionalChaining',\n ],\n };\n\n/**\n * Fast pre-check: matches files that could contain native intlayer calls\n * (`useIntlayer` / `getIntlayer`). Used by the optimize/transform pass, which\n * only rewrites native calls.\n */\nexport const INTLAYER_USAGE_REGEX = /\\b(use|get)Intlayer\\b/;\n\n/**\n * Builds a fast pre-check regex that matches files potentially containing\n * native intlayer calls and/or the given compat namespace caller names.\n *\n * The result is used to skip files that definitely contain none of the\n * relevant function names, avoiding unnecessary Babel parsing.\n *\n * Compat caller names are NOT hardcoded here — they are provided at runtime by\n * the compat adapter packages that configure the usage-analysis pipeline.\n *\n * @param extraCallerNames - Additional caller function names to match\n * (e.g. `['useTranslation', 'getFixedT']` from `@intlayer/react-i18next`).\n * @returns A `RegExp` matching any of the native or provided caller names.\n */\nexport const buildUsageCheckRegex = (extraCallerNames?: string[]): RegExp => {\n const callerNames = [\n 'useIntlayer',\n 'getIntlayer',\n ...(extraCallerNames ?? []),\n ];\n const uniqueNames = [...new Set(callerNames)];\n return new RegExp(`\\\\b(${uniqueNames.join('|')})\\\\b`);\n};\n\n/**\n * Matches source files that are valid targets for usage analysis and Babel\n * transformation. Excludes sourcemap files, declaration files, and other\n * non-source extensions.\n */\nexport const SOURCE_FILE_REGEX = /\\.(tsx?|[mc]?jsx?|vue|svelte|astro)$/;\n\n// ── High-level transformer functions ──────────────────────────────────────────\n\n/**\n * Runs the usage-analysis Babel plugin on a single JS/TS code string.\n *\n * This is analysis-only: the transformed code output is discarded.\n * Throws if Babel cannot parse the content.\n */\nconst analyzeScriptContent = async (\n scriptContent: string,\n sourceFilePath: string,\n pruneContext: PruneContext,\n compatCallers?: CompatCallerConfig[]\n): Promise<void> => {\n await transformAsync(scriptContent, {\n filename: sourceFilePath,\n plugins: [makeUsageAnalyzerBabelPlugin(pruneContext, { compatCallers })],\n parserOpts: BABEL_PARSER_OPTIONS,\n ast: false,\n code: false, // analysis only – no output needed\n });\n};\n\n/**\n * Runs the usage-analysis Babel plugin on a source file, accumulating\n * field-usage data into `pruneContext`.\n *\n * For Vue / Svelte SFC files, script blocks are extracted before analysis so\n * Babel does not attempt to parse the full SFC syntax (templates, styles, …).\n * For plain JS/TS files, the whole file content is analysed directly.\n *\n * This is analysis-only: the transformed code output is discarded.\n * Throws if Babel cannot parse the file (caller should handle and flag\n * `pruneContext.hasUnparsableSourceFiles`).\n */\nexport const analyzeFieldUsageInFile = async (\n sourceFilePath: string,\n code: string,\n pruneContext: PruneContext,\n compatCallers?: CompatCallerConfig[]\n): Promise<void> => {\n const extraCallerNames = (compatCallers ?? []).map(\n (caller) => caller.callerName\n );\n const usageCheckRegex = buildUsageCheckRegex(extraCallerNames);\n const scriptBlocks = extractScriptBlocks(sourceFilePath, code);\n\n // For SFC files (Vue / Svelte): scriptBlocks[0].contentStartOffset > 0\n // means we extracted actual <script> tags from the file.\n // For plain JS/TS: extractScriptBlocks returns the whole file as a single\n // block with offset 0, so we fall through to the same path.\n for (const block of scriptBlocks) {\n if (!usageCheckRegex.test(block.content)) continue;\n await analyzeScriptContent(\n block.content,\n sourceFilePath,\n pruneContext,\n compatCallers\n );\n }\n};\n\n/**\n * Applies field-renaming to a single JS/TS code string (not an SFC).\n *\n * Returns the renamed code string, or `null` if nothing changed or if\n * Babel failed to parse the input (caller should fall back to original code).\n */\nexport const renameFieldsInCode = async (\n code: string,\n sourceFilePath: string,\n pruneContext: PruneContext\n): Promise<string | null> => {\n try {\n const result = await transformAsync(code, {\n filename: sourceFilePath,\n plugins: [makeFieldRenameBabelPlugin(pruneContext)],\n parserOpts: BABEL_PARSER_OPTIONS,\n ast: false,\n });\n return result?.code ?? null;\n } catch {\n return null; // parse failure – caller falls back to original code\n }\n};\n\n/**\n * Applies field-renaming to a source file, correctly handling both plain\n * JS/TS files and SFC files (Vue / Svelte) by operating on each script block\n * individually and injecting the results back into the original source.\n *\n * Returns the renamed code string, or `null` if nothing changed.\n */\nexport const renameFieldsInSourceFile = async (\n sourceFilePath: string,\n code: string,\n pruneContext: PruneContext\n): Promise<string | null> => {\n if (pruneContext.dictionaryKeyToFieldRenameMap.size === 0) return null;\n if (!INTLAYER_USAGE_REGEX.test(code)) return null;\n\n const scriptBlocks = extractScriptBlocks(sourceFilePath, code);\n\n const isSFC =\n scriptBlocks.length > 0 &&\n ((scriptBlocks[0]?.contentStartOffset ?? 0) > 0 || scriptBlocks.length > 1);\n\n if (isSFC) {\n // Raw SFC: rename each script block individually and inject back.\n const modifications: Array<{\n block: (typeof scriptBlocks)[number];\n modifiedContent: string;\n }> = [];\n\n for (const block of scriptBlocks) {\n if (!INTLAYER_USAGE_REGEX.test(block.content)) continue;\n\n const renamedCode = await renameFieldsInCode(\n block.content,\n sourceFilePath,\n pruneContext\n );\n if (renamedCode && renamedCode !== block.content) {\n modifications.push({ block, modifiedContent: renamedCode });\n }\n }\n\n if (modifications.length === 0) return null;\n return injectScriptBlocks(code, modifications);\n }\n\n // Plain JS/TS or compiled SFC (no block delimiters) – rename the whole file.\n return renameFieldsInCode(code, sourceFilePath, pruneContext);\n};\n\n/**\n * Runs the intlayer optimize Babel plugin on a source file, transforming\n * `useIntlayer('key')` / `getIntlayer('key')` calls into `useDictionary(_hash)`\n * / `getDictionary(_hash)` and injecting the corresponding dictionary imports.\n *\n * Returns `{ code, map }` on success, or `null` if the transformation produced\n * no output.\n */\nexport const optimizeSourceFile = async (\n code: string,\n sourceFilePath: string,\n options: OptimizePluginOptions\n): Promise<{\n code: string;\n map: string | object | null | undefined;\n} | null> => {\n const result = await transformAsync(code, {\n filename: sourceFilePath,\n plugins: [[intlayerOptimizeBabelPlugin, options]],\n parserOpts: BABEL_PARSER_OPTIONS,\n });\n\n if (!result?.code) return null;\n\n return { code: result.code, map: result.map };\n};\n"],"mappings":";;;;;;;;;;;AAmBA,MAAa,uBACX;CACE,YAAY;CACZ,6BAA6B;CAC7B,SAAS;EACP;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD;CACF;;;;;;AAOH,MAAa,uBAAuB;;;;;;;;;;;;;;;AAgBpC,MAAa,wBAAwB,qBAAwC;CAC3E,MAAM,cAAc;EAClB;EACA;EACA,GAAI,oBAAoB,EAAE;EAC3B;CACD,MAAM,cAAc,CAAC,GAAG,IAAI,IAAI,YAAY,CAAC;AAC7C,QAAO,IAAI,OAAO,OAAO,YAAY,KAAK,IAAI,CAAC,MAAM;;;;;;;AAQvD,MAAa,oBAAoB;;;;;;;AAUjC,MAAM,uBAAuB,OAC3B,eACA,gBACA,cACA,kBACkB;AAClB,OAAM,eAAe,eAAe;EAClC,UAAU;EACV,SAAS,CAAC,6BAA6B,cAAc,EAAE,eAAe,CAAC,CAAC;EACxE,YAAY;EACZ,KAAK;EACL,MAAM;EACP,CAAC;;;;;;;;;;;;;;AAeJ,MAAa,0BAA0B,OACrC,gBACA,MACA,cACA,kBACkB;CAIlB,MAAM,kBAAkB,sBAHE,iBAAiB,EAAE,EAAE,KAC5C,WAAW,OAAO,WAEwC,CAAC;CAC9D,MAAM,eAAe,oBAAoB,gBAAgB,KAAK;AAM9D,MAAK,MAAM,SAAS,cAAc;AAChC,MAAI,CAAC,gBAAgB,KAAK,MAAM,QAAQ,CAAE;AAC1C,QAAM,qBACJ,MAAM,SACN,gBACA,cACA,cACD;;;;;;;;;AAUL,MAAa,qBAAqB,OAChC,MACA,gBACA,iBAC2B;AAC3B,KAAI;AAOF,UAAO,MANc,eAAe,MAAM;GACxC,UAAU;GACV,SAAS,CAAC,2BAA2B,aAAa,CAAC;GACnD,YAAY;GACZ,KAAK;GACN,CAAC,GACa,QAAQ;SACjB;AACN,SAAO;;;;;;;;;;AAWX,MAAa,2BAA2B,OACtC,gBACA,MACA,iBAC2B;AAC3B,KAAI,aAAa,8BAA8B,SAAS,EAAG,QAAO;AAClE,KAAI,CAAC,qBAAqB,KAAK,KAAK,CAAE,QAAO;CAE7C,MAAM,eAAe,oBAAoB,gBAAgB,KAAK;AAM9D,KAHE,aAAa,SAAS,OACpB,aAAa,IAAI,sBAAsB,KAAK,KAAK,aAAa,SAAS,IAEhE;EAET,MAAM,gBAGD,EAAE;AAEP,OAAK,MAAM,SAAS,cAAc;AAChC,OAAI,CAAC,qBAAqB,KAAK,MAAM,QAAQ,CAAE;GAE/C,MAAM,cAAc,MAAM,mBACxB,MAAM,SACN,gBACA,aACD;AACD,OAAI,eAAe,gBAAgB,MAAM,QACvC,eAAc,KAAK;IAAE;IAAO,iBAAiB;IAAa,CAAC;;AAI/D,MAAI,cAAc,WAAW,EAAG,QAAO;AACvC,SAAO,mBAAmB,MAAM,cAAc;;AAIhD,QAAO,mBAAmB,MAAM,gBAAgB,aAAa;;;;;;;;;;AAW/D,MAAa,qBAAqB,OAChC,MACA,gBACA,YAIW;CACX,MAAM,SAAS,MAAM,eAAe,MAAM;EACxC,UAAU;EACV,SAAS,CAAC,CAAC,6BAA6B,QAAQ,CAAC;EACjD,YAAY;EACb,CAAC;AAEF,KAAI,CAAC,QAAQ,KAAM,QAAO;AAE1B,QAAO;EAAE,MAAM,OAAO;EAAM,KAAK,OAAO;EAAK"}
|
|
1
|
+
{"version":3,"file":"transformers.mjs","names":[],"sources":["../../src/transformers.ts"],"sourcesContent":["import { type TransformOptions, transformAsync } from '@babel/core';\nimport { makeFieldRenameBabelPlugin } from './babel-plugin-intlayer-field-rename';\nimport {\n intlayerOptimizeBabelPlugin,\n type OptimizePluginOptions,\n} from './babel-plugin-intlayer-optimize';\nimport {\n type CompatCallerConfig,\n makeUsageAnalyzerBabelPlugin,\n type PruneContext,\n} from './babel-plugin-intlayer-usage-analyzer';\nimport { extractScriptBlocks, injectScriptBlocks } from './extractScriptBlocks';\n\n// ── Shared Babel parser configuration ─────────────────────────────────────────\n\n/**\n * Babel parser options covering the superset of syntaxes used across all\n * supported frameworks (React / Vue / Svelte / Angular / …).\n */\nexport const BABEL_PARSER_OPTIONS: NonNullable<TransformOptions['parserOpts']> =\n {\n sourceType: 'module',\n allowImportExportEverywhere: true,\n plugins: [\n 'typescript',\n 'jsx',\n 'decorators-legacy',\n 'classProperties',\n 'objectRestSpread',\n 'asyncGenerators',\n 'functionBind',\n 'exportDefaultFrom',\n 'exportNamespaceFrom',\n 'dynamicImport',\n 'nullishCoalescingOperator',\n 'optionalChaining',\n ],\n };\n\n/**\n * Fast pre-check: matches files that could contain native intlayer calls\n * (`useIntlayer` / `getIntlayer`). Used by the optimize/transform pass, which\n * only rewrites native calls.\n */\nexport const INTLAYER_USAGE_REGEX = /\\b(use|get)Intlayer\\b/;\n\n/**\n * Builds a fast pre-check regex that matches files potentially containing\n * native intlayer calls and/or the given compat namespace caller names.\n *\n * The result is used to skip files that definitely contain none of the\n * relevant function names, avoiding unnecessary Babel parsing.\n *\n * Compat caller names are NOT hardcoded here — they are provided at runtime by\n * the compat adapter packages that configure the usage-analysis pipeline.\n *\n * @param extraCallerNames - Additional caller function names to match\n * (e.g. `['useTranslation', 'getFixedT']` from `@intlayer/react-i18next`).\n * @returns A `RegExp` matching any of the native or provided caller names.\n */\nexport const buildUsageCheckRegex = (extraCallerNames?: string[]): RegExp => {\n const callerNames = [\n 'useIntlayer',\n 'getIntlayer',\n ...(extraCallerNames ?? []),\n ];\n const uniqueNames = [...new Set(callerNames)];\n return new RegExp(`\\\\b(${uniqueNames.join('|')})\\\\b`);\n};\n\n/** Usage-check regex covering only the native callers (no compat callers). */\nconst NATIVE_USAGE_CHECK_REGEX = buildUsageCheckRegex();\n\n/** Cache of usage-check regexes, keyed by the compat-caller array reference. */\nconst usageCheckRegexCache = new WeakMap<\n readonly CompatCallerConfig[],\n RegExp\n>();\n\n/**\n * Returns the usage-check regex for the given compat callers, memoised by the\n * array reference. Plugins pass the same options array for every analysed\n * file, so the regex is built once per build instead of once per file.\n */\nexport const getUsageCheckRegex = (\n compatCallers?: readonly CompatCallerConfig[]\n): RegExp => {\n if (!compatCallers || compatCallers.length === 0) {\n return NATIVE_USAGE_CHECK_REGEX;\n }\n\n let usageCheckRegex = usageCheckRegexCache.get(compatCallers);\n if (!usageCheckRegex) {\n usageCheckRegex = buildUsageCheckRegex(\n compatCallers.map((caller) => caller.callerName)\n );\n usageCheckRegexCache.set(compatCallers, usageCheckRegex);\n }\n return usageCheckRegex;\n};\n\n/**\n * Matches source files that are valid targets for usage analysis and Babel\n * transformation. Excludes sourcemap files, declaration files, and other\n * non-source extensions.\n */\nexport const SOURCE_FILE_REGEX = /\\.(tsx?|[mc]?jsx?|vue|svelte|astro)$/;\n\n// ── High-level transformer functions ──────────────────────────────────────────\n\n/**\n * Runs the usage-analysis Babel plugin on a single JS/TS code string.\n *\n * This is analysis-only: the transformed code output is discarded.\n * Throws if Babel cannot parse the content.\n */\nconst analyzeScriptContent = async (\n scriptContent: string,\n sourceFilePath: string,\n pruneContext: PruneContext,\n compatCallers?: CompatCallerConfig[]\n): Promise<void> => {\n await transformAsync(scriptContent, {\n filename: sourceFilePath,\n plugins: [makeUsageAnalyzerBabelPlugin(pruneContext, { compatCallers })],\n parserOpts: BABEL_PARSER_OPTIONS,\n ast: false,\n code: false, // analysis only – no output needed\n });\n};\n\n/**\n * Runs the usage-analysis Babel plugin on a source file, accumulating\n * field-usage data into `pruneContext`.\n *\n * For Vue / Svelte SFC files, script blocks are extracted before analysis so\n * Babel does not attempt to parse the full SFC syntax (templates, styles, …).\n * For plain JS/TS files, the whole file content is analysed directly.\n *\n * This is analysis-only: the transformed code output is discarded.\n * Throws if Babel cannot parse the file (caller should handle and flag\n * `pruneContext.hasUnparsableSourceFiles`).\n */\nexport const analyzeFieldUsageInFile = async (\n sourceFilePath: string,\n code: string,\n pruneContext: PruneContext,\n compatCallers?: CompatCallerConfig[]\n): Promise<void> => {\n const usageCheckRegex = getUsageCheckRegex(compatCallers);\n const scriptBlocks = extractScriptBlocks(sourceFilePath, code);\n\n // For SFC files (Vue / Svelte): scriptBlocks[0].contentStartOffset > 0\n // means we extracted actual <script> tags from the file.\n // For plain JS/TS: extractScriptBlocks returns the whole file as a single\n // block with offset 0, so we fall through to the same path.\n for (const block of scriptBlocks) {\n if (!usageCheckRegex.test(block.content)) continue;\n await analyzeScriptContent(\n block.content,\n sourceFilePath,\n pruneContext,\n compatCallers\n );\n }\n};\n\n/**\n * Applies field-renaming to a single JS/TS code string (not an SFC).\n *\n * Returns the renamed code string, or `null` if nothing changed or if\n * Babel failed to parse the input (caller should fall back to original code).\n */\nexport const renameFieldsInCode = async (\n code: string,\n sourceFilePath: string,\n pruneContext: PruneContext\n): Promise<string | null> => {\n try {\n const result = await transformAsync(code, {\n filename: sourceFilePath,\n plugins: [makeFieldRenameBabelPlugin(pruneContext)],\n parserOpts: BABEL_PARSER_OPTIONS,\n ast: false,\n });\n return result?.code ?? null;\n } catch {\n return null; // parse failure – caller falls back to original code\n }\n};\n\n/**\n * Applies field-renaming to a source file, correctly handling both plain\n * JS/TS files and SFC files (Vue / Svelte) by operating on each script block\n * individually and injecting the results back into the original source.\n *\n * Returns the renamed code string, or `null` if nothing changed.\n */\nexport const renameFieldsInSourceFile = async (\n sourceFilePath: string,\n code: string,\n pruneContext: PruneContext\n): Promise<string | null> => {\n if (pruneContext.dictionaryKeyToFieldRenameMap.size === 0) return null;\n if (!INTLAYER_USAGE_REGEX.test(code)) return null;\n\n const scriptBlocks = extractScriptBlocks(sourceFilePath, code);\n\n const isSFC =\n scriptBlocks.length > 0 &&\n ((scriptBlocks[0]?.contentStartOffset ?? 0) > 0 || scriptBlocks.length > 1);\n\n if (isSFC) {\n // Raw SFC: rename each script block individually and inject back.\n const modifications: Array<{\n block: (typeof scriptBlocks)[number];\n modifiedContent: string;\n }> = [];\n\n for (const block of scriptBlocks) {\n if (!INTLAYER_USAGE_REGEX.test(block.content)) continue;\n\n const renamedCode = await renameFieldsInCode(\n block.content,\n sourceFilePath,\n pruneContext\n );\n if (renamedCode && renamedCode !== block.content) {\n modifications.push({ block, modifiedContent: renamedCode });\n }\n }\n\n if (modifications.length === 0) return null;\n return injectScriptBlocks(code, modifications);\n }\n\n // Plain JS/TS or compiled SFC (no block delimiters) – rename the whole file.\n return renameFieldsInCode(code, sourceFilePath, pruneContext);\n};\n\n/**\n * Runs the intlayer optimize Babel plugin on a source file, transforming\n * `useIntlayer('key')` / `getIntlayer('key')` calls into `useDictionary(_hash)`\n * / `getDictionary(_hash)` and injecting the corresponding dictionary imports.\n *\n * Returns `{ code, map }` on success, or `null` if the transformation produced\n * no output.\n */\nexport const optimizeSourceFile = async (\n code: string,\n sourceFilePath: string,\n options: OptimizePluginOptions\n): Promise<{\n code: string;\n map: string | object | null | undefined;\n} | null> => {\n const result = await transformAsync(code, {\n filename: sourceFilePath,\n plugins: [[intlayerOptimizeBabelPlugin, options]],\n parserOpts: BABEL_PARSER_OPTIONS,\n });\n\n if (!result?.code) return null;\n\n return { code: result.code, map: result.map };\n};\n"],"mappings":";;;;;;;;;;;AAmBA,MAAa,uBACX;CACE,YAAY;CACZ,6BAA6B;CAC7B,SAAS;EACP;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD;CACF;;;;;;AAOH,MAAa,uBAAuB;;;;;;;;;;;;;;;AAgBpC,MAAa,wBAAwB,qBAAwC;CAC3E,MAAM,cAAc;EAClB;EACA;EACA,GAAI,oBAAoB,EAAE;EAC3B;CACD,MAAM,cAAc,CAAC,GAAG,IAAI,IAAI,YAAY,CAAC;AAC7C,QAAO,IAAI,OAAO,OAAO,YAAY,KAAK,IAAI,CAAC,MAAM;;;AAIvD,MAAM,2BAA2B,sBAAsB;;AAGvD,MAAM,uCAAuB,IAAI,SAG9B;;;;;;AAOH,MAAa,sBACX,kBACW;AACX,KAAI,CAAC,iBAAiB,cAAc,WAAW,EAC7C,QAAO;CAGT,IAAI,kBAAkB,qBAAqB,IAAI,cAAc;AAC7D,KAAI,CAAC,iBAAiB;AACpB,oBAAkB,qBAChB,cAAc,KAAK,WAAW,OAAO,WAAW,CACjD;AACD,uBAAqB,IAAI,eAAe,gBAAgB;;AAE1D,QAAO;;;;;;;AAQT,MAAa,oBAAoB;;;;;;;AAUjC,MAAM,uBAAuB,OAC3B,eACA,gBACA,cACA,kBACkB;AAClB,OAAM,eAAe,eAAe;EAClC,UAAU;EACV,SAAS,CAAC,6BAA6B,cAAc,EAAE,eAAe,CAAC,CAAC;EACxE,YAAY;EACZ,KAAK;EACL,MAAM;EACP,CAAC;;;;;;;;;;;;;;AAeJ,MAAa,0BAA0B,OACrC,gBACA,MACA,cACA,kBACkB;CAClB,MAAM,kBAAkB,mBAAmB,cAAc;CACzD,MAAM,eAAe,oBAAoB,gBAAgB,KAAK;AAM9D,MAAK,MAAM,SAAS,cAAc;AAChC,MAAI,CAAC,gBAAgB,KAAK,MAAM,QAAQ,CAAE;AAC1C,QAAM,qBACJ,MAAM,SACN,gBACA,cACA,cACD;;;;;;;;;AAUL,MAAa,qBAAqB,OAChC,MACA,gBACA,iBAC2B;AAC3B,KAAI;AAOF,UAAO,MANc,eAAe,MAAM;GACxC,UAAU;GACV,SAAS,CAAC,2BAA2B,aAAa,CAAC;GACnD,YAAY;GACZ,KAAK;GACN,CAAC,GACa,QAAQ;SACjB;AACN,SAAO;;;;;;;;;;AAWX,MAAa,2BAA2B,OACtC,gBACA,MACA,iBAC2B;AAC3B,KAAI,aAAa,8BAA8B,SAAS,EAAG,QAAO;AAClE,KAAI,CAAC,qBAAqB,KAAK,KAAK,CAAE,QAAO;CAE7C,MAAM,eAAe,oBAAoB,gBAAgB,KAAK;AAM9D,KAHE,aAAa,SAAS,OACpB,aAAa,IAAI,sBAAsB,KAAK,KAAK,aAAa,SAAS,IAEhE;EAET,MAAM,gBAGD,EAAE;AAEP,OAAK,MAAM,SAAS,cAAc;AAChC,OAAI,CAAC,qBAAqB,KAAK,MAAM,QAAQ,CAAE;GAE/C,MAAM,cAAc,MAAM,mBACxB,MAAM,SACN,gBACA,aACD;AACD,OAAI,eAAe,gBAAgB,MAAM,QACvC,eAAc,KAAK;IAAE;IAAO,iBAAiB;IAAa,CAAC;;AAI/D,MAAI,cAAc,WAAW,EAAG,QAAO;AACvC,SAAO,mBAAmB,MAAM,cAAc;;AAIhD,QAAO,mBAAmB,MAAM,gBAAgB,aAAa;;;;;;;;;;AAW/D,MAAa,qBAAqB,OAChC,MACA,gBACA,YAIW;CACX,MAAM,SAAS,MAAM,eAAe,MAAM;EACxC,UAAU;EACV,SAAS,CAAC,CAAC,6BAA6B,QAAQ,CAAC;EACjD,YAAY;EACb,CAAC;AAEF,KAAI,CAAC,QAAQ,KAAM,QAAO;AAE1B,QAAO;EAAE,MAAM,OAAO;EAAM,KAAK,OAAO;EAAK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-intlayer-extract.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-extract.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"babel-plugin-intlayer-extract.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-extract.ts"],"mappings":";;;;;;;;KAeY,aAAA;EACV,aAAA;EACA,QAAA;EACA,OAAA,EAAS,MAAA;EACT,MAAA,EAAQ,MAAA;AAAA;AAAA,KAGE,oBAAA;EACV,WAAA,GAAc,WAAA;EACd,SAAA;EACA,OAAA;EAEA,aAAA,IAAiB,IAAA;EACjB,aAAA,EAAe,cAAA;EATD;;AAGhB;;;EAYE,SAAA,IAAa,MAAA,EAAQ,aAAA,YAAyB,OAAA;EAN/B;;;EAUf,MAAA,GAAS,eAAA;AAAA;AAAA,KAGN,KAAA,GAAQ,UAAA;EAAe,IAAA,EAAM,oBAAA;AAAA;;;;;;;;;;;;;;;AAFhC;;;cAqBW,0BAAA,GAA8B,MAAA;EACzC,KAAA,SAAc,UAAA;AAAA,MACZ,YAAA,CAAa,KAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-intlayer-field-rename.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-field-rename.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"babel-plugin-intlayer-field-rename.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-field-rename.ts"],"mappings":";;;;;;;AAyBA;;cAAa,sBAAA,GAA0B,KAAA;;;AAoCvC;;;;;AAyQA;;;;;;;;;;;;;;;;;;;;cAzQa,+BAAA,GACX,YAAA,cACC,eAAA;;;;;;;;;;;;;;;;;;;;;;;;;;cAuQU,0BAAA,GACV,YAAA,EAAc,YAAA;EACd,KAAA,EAAA;AAAA;EAAyB,KAAA,SAAc,UAAA;AAAA,MAAe,YAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PluginObject, PluginPass } from "@babel/core";
|
|
2
2
|
import * as BabelTypes from "@babel/types";
|
|
3
|
+
import { CallerDescriptor } from "@intlayer/config/callers";
|
|
3
4
|
|
|
4
5
|
//#region src/babel-plugin-intlayer-optimize.d.ts
|
|
5
6
|
declare const CALLER_LIST: readonly ["useIntlayer", "getIntlayer"];
|
|
@@ -63,6 +64,20 @@ type OptimizePluginOptions = {
|
|
|
63
64
|
* Whether the current transform is for an SSR bundle.
|
|
64
65
|
*/
|
|
65
66
|
isServer?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Compat-adapter caller descriptors injected by the compat packages'
|
|
69
|
+
* bundler plugins (e.g. `@intlayer/react-i18next/plugin`).
|
|
70
|
+
*
|
|
71
|
+
* Callers carrying `staticReplacement` / `dynamicReplacement` are rewritten
|
|
72
|
+
* the same way as native `useIntlayer` calls: the namespace string argument
|
|
73
|
+
* is replaced by a pre-imported dictionary object and the import specifier
|
|
74
|
+
* is re-pointed to the dictionary-accepting variant, e.g.
|
|
75
|
+
* `useTranslation('about')` → `useDictionary(_dictHash)`.
|
|
76
|
+
*
|
|
77
|
+
* No compat-specific name is hard-coded in this plugin — the whole rewrite
|
|
78
|
+
* is driven by these descriptors.
|
|
79
|
+
*/
|
|
80
|
+
compatCallers?: CallerDescriptor[];
|
|
66
81
|
};
|
|
67
82
|
type State = PluginPass & {
|
|
68
83
|
opts: OptimizePluginOptions; /** map key → generated ident (per-file) for static imports */
|
|
@@ -70,7 +85,8 @@ type State = PluginPass & {
|
|
|
70
85
|
_newDynamicImports?: Map<string, BabelTypes.Identifier>; /** whether the current file imported *any* intlayer package */
|
|
71
86
|
_hasValidImport?: boolean; /** map from local identifier name to the imported intlayer func name ('useIntlayer' | 'getIntlayer') */
|
|
72
87
|
_callerMap?: Map<string, (typeof CALLER_LIST)[number]>; /** map from local identifier name to the intlayer package it was imported from */
|
|
73
|
-
_callerPackageMap?: Map<string, string>; /**
|
|
88
|
+
_callerPackageMap?: Map<string, string>; /** map from local identifier name to the compat caller descriptor it was imported as */
|
|
89
|
+
_compatCallerMap?: Map<string, CallerDescriptor>; /** whether the current file *is* the dictionaries entry file */
|
|
74
90
|
_isDictEntry?: boolean; /** whether the current file is included in the filesList */
|
|
75
91
|
_isIncluded?: boolean;
|
|
76
92
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-intlayer-optimize.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-optimize.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"babel-plugin-intlayer-optimize.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-optimize.ts"],"mappings":";;;;;cA6BM,WAAA;;AAvB4B;;KA4EtB,qBAAA;EArD+C;;AAqD3D;EAIE,QAAA;;;;EAIA,eAAA;EAIA;;;EAAA,qBAAA;EAgBA;;;EAZA,6BAAA;EA4BA;;;EAxBA,uBAAA;EAuCA;;;EAnCA,sBAAA;EAiDgC;AAChC;;EA9CA,4BAAA;EAgDW;;;EA5CX,oBAAA;EAiDiC;;;EA7CjC,0BAAA;EAmDoB;;;EA/CpB,sBAAA;EAiDsB;;;EA7CtB,UAAA;EAmCA;;;EA/BA,iBAAA,GAAoB,MAAA;EAiCpB;;;EA1BA,SAAA;EA4BA;;;EAxBA,QAAA;EA4BA;;;;;;;;;AAoSF;;;;EAlTE,aAAA,GAAgB,gBAAA;AAAA;AAAA,KAGb,KAAA,GAAQ,UAAA;EACX,IAAA,EAAM,qBAAA,EA+SN;EA7SA,iBAAA,GAAoB,GAAA,SAAY,UAAA,CAAW,UAAA,GA4SD;EA1S1C,kBAAA,GAAqB,GAAA,SAAY,UAAA,CAAW,UAAA,GA4S7B;EA1Sf,eAAA,YA0SoB;EAxSpB,UAAA,GAAa,GAAA,iBAAoB,WAAA;EAEjC,iBAAA,GAAoB,GAAA;EAEpB,gBAAA,GAAmB,GAAA,SAAY,gBAAA;EAE/B,YAAA;EAEA,WAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8RW,2BAAA,GAA+B,KAAA;EAC1C,KAAA,SAAc,UAAA;AAAA,MACZ,YAAA,CAAa,KAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-intlayer-purge.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-purge.ts"],"mappings":";;;;;;;AA6BA;;;;;KAAY,kBAAA;EAmBV;;;;;EAbA,OAAA;EAoDA;;;;EA9CA,KAAA;EA8DkC;AAyBpC;;;;EAhFE,MAAA;
|
|
1
|
+
{"version":3,"file":"babel-plugin-intlayer-purge.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-purge.ts"],"mappings":";;;;;;;AA6BA;;;;;KAAY,kBAAA;EAmBV;;;;;EAbA,OAAA;EAoDA;;;;EA9CA,KAAA;EA8DkC;AAyBpC;;;;EAhFE,MAAA;EAusBW;;;;;EAhsBX,QAAA;EAgsBuC;;;;EA1rBvC,aAAA;;;;;EAMA,eAAA;;;;;EAMA,sBAAA;;;;;;EAOA,kBAAA;;;;;;EAOA,4BAAA,EAA8B,MAAA;;;;;;;;;;;;EAgB9B,aAAA,GAAgB,kBAAA;AAAA;;;;;;;;;cAyBL,qBAAA,GAAyB,OAAA,aAAkB,YAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAunB3C,wBAAA,GAA4B,MAAA;EACvC,KAAA,SAAc,UAAA;AAAA,MACZ,YAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PluginObject } from "@babel/core";
|
|
2
2
|
import * as BabelTypes from "@babel/types";
|
|
3
|
+
import { CallerDescriptor, CallerDescriptor as CallerDescriptor$1, CallerResultShape, CallerValueSource } from "@intlayer/config/callers";
|
|
3
4
|
|
|
4
5
|
//#region src/babel-plugin-intlayer-usage-analyzer.d.ts
|
|
5
6
|
/**
|
|
@@ -101,122 +102,13 @@ declare const createPruneContext: () => PruneContext;
|
|
|
101
102
|
/** Canonical intlayer caller names that trigger usage analysis. */
|
|
102
103
|
declare const INTLAYER_CALLER_NAMES: readonly ["useIntlayer", "getIntlayer"];
|
|
103
104
|
type IntlayerCallerName = (typeof INTLAYER_CALLER_NAMES)[number];
|
|
104
|
-
/**
|
|
105
|
-
* Describes how a compat-adapter "namespace caller" exposes the dictionary key
|
|
106
|
-
* (namespace) and the translation function `t`.
|
|
107
|
-
*
|
|
108
|
-
* Compat adapters (`@intlayer/react-i18next`, `@intlayer/next-intl`, …) expose
|
|
109
|
-
* the original i18n library API while delegating to intlayer under the hood.
|
|
110
|
-
* Their call sites look like:
|
|
111
|
-
*
|
|
112
|
-
* const { t } = useTranslation('about'); t('counter.label')
|
|
113
|
-
* const t = useTranslations('about'); t('counter.label')
|
|
114
|
-
* const t = await getTranslations('about');
|
|
115
|
-
* const t = i18n.getFixedT(null, 'about', 'counter');
|
|
116
|
-
* const { t } = useI18n({ namespace: 'about' });
|
|
117
|
-
*
|
|
118
|
-
* The dictionary key is the *namespace* argument and the consumed top-level
|
|
119
|
-
* field is the **first segment** of every dot-path passed to `t()` (or the
|
|
120
|
-
* first segment of `keyPrefix` when one is supplied).
|
|
121
|
-
*/
|
|
122
|
-
type CompatNamespaceSource = /** Namespace is a positional argument (string literal or `{ namespace }`). */{
|
|
123
|
-
from: 'argument';
|
|
124
|
-
index: number;
|
|
125
|
-
} /** Namespace is a property of an options object argument. */ | {
|
|
126
|
-
from: 'option';
|
|
127
|
-
argumentIndex: number;
|
|
128
|
-
property: string;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Namespace is a compile-time constant — the same dictionary key is used for
|
|
132
|
-
* every call site. Used by single-catalog libraries such as lingui, where all
|
|
133
|
-
* translations live in a `messages` dictionary regardless of call location.
|
|
134
|
-
*/
|
|
135
|
-
| {
|
|
136
|
-
from: 'fixed';
|
|
137
|
-
value: string;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Namespace is the first dot-segment of the `id` in the first call argument.
|
|
141
|
-
*
|
|
142
|
-
* Used for libraries like react-intl where the full dotted id encodes both the
|
|
143
|
-
* dictionary key and the field path in a single string:
|
|
144
|
-
* `formatMessage({ id: 'home.title' })` → dictionaryKey = `'home'`, field = `'title'`
|
|
145
|
-
*
|
|
146
|
-
* Works with both string form (`func('home.title')`) and descriptor form
|
|
147
|
-
* (`func({ id: 'home.title', ... })`). The paired `translationFunction` should
|
|
148
|
-
* be `'self'` so the field (second segment) is also extracted from the same call.
|
|
149
|
-
*/
|
|
150
|
-
| {
|
|
151
|
-
from: 'path-first-segment';
|
|
152
|
-
};
|
|
153
105
|
/**
|
|
154
106
|
* Configuration entry for a single compat namespace caller.
|
|
107
|
+
*
|
|
108
|
+
* @deprecated Alias kept for backward compatibility — use the shared
|
|
109
|
+
* {@link CallerDescriptor} from `@intlayer/config/callers` instead.
|
|
155
110
|
*/
|
|
156
|
-
type CompatCallerConfig =
|
|
157
|
-
/** The imported (or method) function name, e.g. `'useTranslation'`. */callerName: string;
|
|
158
|
-
/**
|
|
159
|
-
* Module specifiers from which `callerName` must be imported to be treated as
|
|
160
|
-
* a compat caller. Includes both the original library names and their
|
|
161
|
-
* `@intlayer/*` adapter equivalents, because the bundler aliases the former
|
|
162
|
-
* to the latter but user source code may import either.
|
|
163
|
-
*
|
|
164
|
-
* Ignored when `matchAsMethod` is `true`.
|
|
165
|
-
*/
|
|
166
|
-
importSources: string[];
|
|
167
|
-
/**
|
|
168
|
-
* When `true`, the caller is matched by method name on any object
|
|
169
|
-
* (`x.getFixedT(...)`) without an import check. Used for `i18next` instance
|
|
170
|
-
* methods that are never imported as named specifiers.
|
|
171
|
-
*/
|
|
172
|
-
matchAsMethod?: boolean; /** How the dictionary key (namespace) is read from the call arguments. */
|
|
173
|
-
namespace: CompatNamespaceSource;
|
|
174
|
-
/**
|
|
175
|
-
* Optional location of a `keyPrefix` that prefixes every `t()` path. When a
|
|
176
|
-
* static prefix is present, the only consumed top-level field is the first
|
|
177
|
-
* segment of the prefix.
|
|
178
|
-
*/
|
|
179
|
-
keyPrefix?: CompatNamespaceSource;
|
|
180
|
-
/**
|
|
181
|
-
* How the translation function is obtained from the call result.
|
|
182
|
-
*
|
|
183
|
-
* - `'return-value'` — `const t = useTranslations('ns'); t('key')`
|
|
184
|
-
* - `'destructured-t'` — `const { t } = useTranslation('ns'); t('key')`
|
|
185
|
-
* - `'self'` — the caller IS the translation call;
|
|
186
|
-
* the first argument is the message key.
|
|
187
|
-
* Used for lingui's `i18n._('key')` / `i18n.t('key')`.
|
|
188
|
-
* - `'all'` — mark the entire dictionary as used without tracking
|
|
189
|
-
* individual fields. Use when static key analysis is
|
|
190
|
-
* impossible (e.g. lingui hashed IDs, Angular templates).
|
|
191
|
-
*/
|
|
192
|
-
translationFunction: 'return-value' | 'destructured-t' | 'self' | 'all';
|
|
193
|
-
/**
|
|
194
|
-
* When `true`, the message key is a *flat* dictionary field that itself
|
|
195
|
-
* contains dots (e.g. lingui's `i18n._('results-table.bundleSize')`, where the
|
|
196
|
-
* catalog stores the entry under the literal `'results-table.bundleSize'` key
|
|
197
|
-
* rather than nesting it as `{ 'results-table': { bundleSize } }`).
|
|
198
|
-
*
|
|
199
|
-
* The whole key is then recorded as the consumed top-level field. When unset
|
|
200
|
-
* (the default), only the first dot-segment is recorded, matching libraries
|
|
201
|
-
* whose dotted keys map onto nested dictionary objects (next-intl, vue-i18n).
|
|
202
|
-
*
|
|
203
|
-
* Only meaningful with `translationFunction: 'self'` and a
|
|
204
|
-
* `'fixed'` / `'argument'` / `'option'` namespace.
|
|
205
|
-
*/
|
|
206
|
-
flatKey?: boolean;
|
|
207
|
-
/**
|
|
208
|
-
* When set, the caller is *also* matched as a JSX element whose local name is
|
|
209
|
-
* `callerName` (gated by `importSources`). The named attribute is read as the
|
|
210
|
-
* message id and analysed with the same `namespace` + `translationFunction`
|
|
211
|
-
* (`'self'` / `'all'`) semantics as the call-expression form.
|
|
212
|
-
*
|
|
213
|
-
* Required for libraries with a JSX message component, e.g. react-intl's
|
|
214
|
-
* `<FormattedMessage id="home.title" />`. Without it, JSX usages are invisible
|
|
215
|
-
* to the analyser and field-level pruning of the same dictionary becomes
|
|
216
|
-
* unsafe (it could prune a field only referenced from JSX).
|
|
217
|
-
*/
|
|
218
|
-
jsxIdAttribute?: string;
|
|
219
|
-
};
|
|
111
|
+
type CompatCallerConfig = CallerDescriptor$1;
|
|
220
112
|
/**
|
|
221
113
|
* Default registry of compat namespace callers.
|
|
222
114
|
*
|
|
@@ -248,7 +140,7 @@ declare const makeUsageAnalyzerBabelPlugin: (pruneContext: PruneContext, options
|
|
|
248
140
|
types: babelTypes
|
|
249
141
|
}: {
|
|
250
142
|
types: typeof BabelTypes;
|
|
251
|
-
}) =>
|
|
143
|
+
}) => PluginObject;
|
|
252
144
|
//#endregion
|
|
253
|
-
export {
|
|
145
|
+
export { type CallerDescriptor, type CallerResultShape, type CallerValueSource, CompatCallerConfig, DEFAULT_COMPAT_CALLERS, DictionaryFieldUsage, INTLAYER_CALLER_NAMES, IntlayerCallerName, NestedRenameEntry, NestedRenameMap, PruneContext, createPruneContext, makeUsageAnalyzerBabelPlugin };
|
|
254
146
|
//# sourceMappingURL=babel-plugin-intlayer-usage-analyzer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-intlayer-usage-analyzer.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-usage-analyzer.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"babel-plugin-intlayer-usage-analyzer.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-usage-analyzer.ts"],"mappings":";;;;;;;AAgBA;;;;;KAAY,oBAAA,GAAuB,GAAA;;;;;;;;KASvB,iBAAA;EACV,SAAA;EACA,QAAA,EAAU,eAAA;AAAA;;KAIA,eAAA,GAAkB,GAAA,SAAY,iBAAA;AAS1C;;;;;;;AAAA,KAAY,YAAA;EAiCqB;;;;;EA3B/B,4BAAA,EAA8B,GAAA,SAAY,oBAAA;EA+Db;;;;EAzD7B,yBAAA,EAA2B,GAAA;EAAA;;;;;EAO3B,wBAAA;EAc2C;;;;;EAP3C,mCAAA,EAAqC,GAAA;EA2CrC;;;;;EApCA,6BAAA,EAA+B,GAAA,SAAY,eAAA;EA0ChC;;;;;AAiBb;;;EAjDE,sCAAA,EAAwC,GAAA,SAAY,GAAA;EAiDsB;AAC5E;;;;;AAmBA;;;;;AAYA;EAnEE,+BAAA,EAAiC,GAAA;;;;AA8+BnC;;;;;;;EAl+BE,wBAAA,EAA0B,GAAA;IAEtB,YAAA;IAAsB,aAAA;EAAA;AAAA;AAAA,cAIf,kBAAA,QAAyB,YAAA;;cAiBzB,qBAAA;AAAA,KACD,kBAAA,WAA6B,qBAAA;;;;;;;KAmB7B,kBAAA,GAAqB,kBAAA;;;;;;;;;;;cAYpB,sBAAA,EAAwB,kBAAA;;;;;;;;;;;;;;;cA26BxB,4BAAA,GAET,YAAA,EAAc,YAAA,EACd,OAAA;EAAY,aAAA,GAAgB,kBAAA;AAAA;EAE7B,KAAA,EAAA;AAAA;EAAyB,KAAA,SAAc,UAAA;AAAA,MAAe,YAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ExistingIntlayerInfo } from "./utils/getExistingIntlayerInfo.js";
|
|
1
2
|
import * as t from "@babel/types";
|
|
2
3
|
import { IntlayerConfig } from "@intlayer/types/config";
|
|
3
4
|
import { NodePath } from "@babel/traverse";
|
|
@@ -26,7 +27,8 @@ declare const extractBabelContentForComponents: (ast: t.File, fileCode: string,
|
|
|
26
27
|
componentsNeedingHooks: Set<NodePath>;
|
|
27
28
|
componentKeyMap: Map<t.Node, string>;
|
|
28
29
|
componentPaths: NodePath[];
|
|
29
|
-
hookMap: Map<t.Node, "useIntlayer" | "getIntlayer">;
|
|
30
|
+
hookMap: Map<t.Node, "useIntlayer" | "getIntlayer">; /** Cached `getExistingIntlayerInfo` result per component node, so callers do not re-traverse. */
|
|
31
|
+
existingInfoByNode: Map<t.Node, ExistingIntlayerInfo | undefined>;
|
|
30
32
|
isSolid: boolean;
|
|
31
33
|
};
|
|
32
34
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babelProcessor.d.ts","names":[],"sources":["../../../src/extractContent/babelProcessor.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"babelProcessor.d.ts","names":[],"sources":["../../../src/extractContent/babelProcessor.ts"],"mappings":";;;;;;KAaY,gBAAA;EACV,IAAA,EAAM,QAAA;EACN,GAAA;EACA,IAAA;EAOA,YAAA;EACA,iBAAA,GAAoB,CAAA,CAAE,IAAA;EACtB,SAAA;AAAA;;;;;cA4IW,uBAAA,GACX,IAAA,EAAM,QAAA,CAAS,CAAA,CAAE,UAAA,GAAa,CAAA,CAAE,WAAA,GAChC,QAAA,UACA,YAAA,EAAc,GAAA,UACd,sBAAA,GAAyB,IAAA,EAAM,QAAA,aAC/B,gBAAA,EAAkB,MAAA,SAAe,MAAA,mBACjC,YAAA,EAAc,gBAAA,IACd,YAAA,EAAc,GAAA,CAAI,CAAA,CAAE,IAAA;;;;;cAwIT,gCAAA,GACX,GAAA,EAAK,CAAA,CAAE,IAAA,EACP,QAAA,UACA,YAAA,EAAc,GAAA,UACd,UAAA,UACA,aAAA,EAAe,cAAA,EACf,QAAA,UACA,oBAAA,GAAsB,MAAA;EAEtB,gBAAA,EAAkB,MAAA,SAAe,MAAA;EACjC,YAAA,EAAc,gBAAA;EACd,sBAAA,EAAwB,GAAA,CAAI,QAAA;EAC5B,eAAA,EAAiB,GAAA,CAAI,CAAA,CAAE,IAAA;EACvB,cAAA,EAAgB,QAAA;EAChB,OAAA,EAAS,GAAA,CAAI,CAAA,CAAE,IAAA,kCA1JD;EA4Jd,kBAAA,EAAoB,GAAA,CAAI,CAAA,CAAE,IAAA,EAAM,oBAAA;EAChC,OAAA;AAAA;;;;cA6ZW,gBAAA,GACX,GAAA,EAAK,CAAA,CAAE,IAAA,EACP,QAAA,UACA,YAAA,EAAc,GAAA,UACd,aAAA,EAAe,cAAA,EACf,QAAA,UACA,oBAAA,GAAsB,MAAA;EAEtB,gBAAA,EAAkB,MAAA;EAClB,YAAA,EAAc,gBAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contentWriter.d.ts","names":[],"sources":["../../../src/extractContent/contentWriter.ts"],"mappings":";;;;;;AAY4E;
|
|
1
|
+
{"version":3,"file":"contentWriter.d.ts","names":[],"sources":["../../../src/extractContent/contentWriter.ts"],"mappings":";;;;;;AAY4E;KAuBvE,eAAA;EACH,QAAA;EACA,WAAA,EAAa,MAAA;AAAA;;;;KAMV,oBAAA,GAAuB,MAAA,SAAe,eAAA;AANtB;;;;;AAmBrB;AAnBqB,cAmBR,uCAAA,GACX,gBAAA,EAAkB,MAAA,kBAClB,kBAAA,EAAoB,UAAA,SACpB,aAAA,aACC,oBAAA;;;;;;;cAkDU,oCAAA,GACX,gBAAA,EAAkB,MAAA,kBAClB,kBAAA,EAAoB,UAAA,YACnB,MAAA;;;;cA8CU,kBAAA,GACX,gBAAA,EAAkB,MAAA,kBAClB,aAAA,EAAe,aAAA,EACf,QAAA,UACA,aAAA,EAAe,cAAA,KACd,OAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ATTRIBUTES_TO_EXTRACT, PackageName, SERVER_CAPABLE_PACKAGES, packageList } from "./utils/constants.js";
|
|
2
|
-
import { mergeWithExistingMultilingualDictionary, mergeWithExistingPerLocaleDictionary, writeContentHelper } from "./contentWriter.js";
|
|
3
2
|
import { detectPackageName } from "./utils/detectPackageName.js";
|
|
4
3
|
import { ExtractDictionaryInfoOptions, ResolveContentFilePaths, extractDictionaryInfo, getOutput, resolveContentFilePaths } from "./utils/extractDictionaryInfo.js";
|
|
5
4
|
import { extractDictionaryKey, extractDictionaryKeyFromPath } from "./utils/extractDictionaryKey.js";
|
|
6
5
|
import { generateKey } from "./utils/generateKey.js";
|
|
7
6
|
import { getComponentName } from "./utils/getComponentName.js";
|
|
7
|
+
import { mergeWithExistingMultilingualDictionary, mergeWithExistingPerLocaleDictionary, writeContentHelper } from "./contentWriter.js";
|
|
8
8
|
import { ExtractIntlayerOptions, extractContent, extractContentSync } from "./extractContent.js";
|
|
9
9
|
export { ATTRIBUTES_TO_EXTRACT, ExtractDictionaryInfoOptions, ExtractIntlayerOptions, PackageName, ResolveContentFilePaths, SERVER_CAPABLE_PACKAGES, detectPackageName, extractContent, extractContentSync, extractDictionaryInfo, extractDictionaryKey, extractDictionaryKeyFromPath, generateKey, getComponentName, getOutput, mergeWithExistingMultilingualDictionary, mergeWithExistingPerLocaleDictionary, packageList, resolveContentFilePaths, writeContentHelper };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processTsxFile.d.ts","names":[],"sources":["../../../src/extractContent/processTsxFile.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"processTsxFile.d.ts","names":[],"sources":["../../../src/extractContent/processTsxFile.ts"],"mappings":";;;;KAcY,QAAA;EACV,KAAA;EACA,GAAA;EACA,WAAA;AAAA;;;;cA4BW,cAAA,GACX,QAAA,UACA,YAAA,UACA,WAAA,EAAa,WAAA,EACb,aAAA,EAAe,cAAA,EACf,IAAA,YACA,oBAAA,GAAsB,MAAA,mBACtB,gBAAA;EAEA,gBAAA,EAAkB,MAAA,SAAe,MAAA;EACjC,YAAA;AAAA"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Attributes that should be extracted as translatable strings from JSX/HTML elements.
|
|
4
4
|
* This is the single source of truth shared across all Intlayer compiler packages
|
|
5
|
-
* (@intlayer/babel, @intlayer/vue-compiler, @intlayer/svelte-compiler, @intlayer/
|
|
5
|
+
* (@intlayer/babel, @intlayer/vue-compiler, @intlayer/svelte-compiler, @intlayer/engine).
|
|
6
6
|
*/
|
|
7
7
|
declare const ATTRIBUTES_TO_EXTRACT: readonly ["title", "placeholder", "alt", "aria-label", "label"];
|
|
8
8
|
/**
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { ATTRIBUTES_TO_EXTRACT, PackageName, SERVER_CAPABLE_PACKAGES, packageList } from "./extractContent/utils/constants.js";
|
|
2
2
|
import { ExtractPluginOptions, ExtractResult, intlayerExtractBabelPlugin } from "./babel-plugin-intlayer-extract.js";
|
|
3
|
-
import {
|
|
3
|
+
import { CallerDescriptor, CallerResultShape, CallerValueSource, CompatCallerConfig, DEFAULT_COMPAT_CALLERS, DictionaryFieldUsage, INTLAYER_CALLER_NAMES, IntlayerCallerName, NestedRenameEntry, NestedRenameMap, PruneContext, createPruneContext, makeUsageAnalyzerBabelPlugin } from "./babel-plugin-intlayer-usage-analyzer.js";
|
|
4
4
|
import { buildNestedRenameMapFromContent, generateShortFieldName, makeFieldRenameBabelPlugin } from "./babel-plugin-intlayer-field-rename.js";
|
|
5
5
|
import { MinifyPluginOptions, intlayerMinifyBabelPlugin } from "./babel-plugin-intlayer-minify.js";
|
|
6
6
|
import { OptimizePluginOptions, intlayerOptimizeBabelPlugin } from "./babel-plugin-intlayer-optimize.js";
|
|
7
7
|
import { PurgePluginOptions, getSharedPruneContext, intlayerPurgeBabelPlugin } from "./babel-plugin-intlayer-purge.js";
|
|
8
|
-
import { mergeWithExistingMultilingualDictionary, mergeWithExistingPerLocaleDictionary, writeContentHelper } from "./extractContent/contentWriter.js";
|
|
9
8
|
import { detectPackageName } from "./extractContent/utils/detectPackageName.js";
|
|
10
9
|
import { ExtractDictionaryInfoOptions, ResolveContentFilePaths, extractDictionaryInfo, getOutput, resolveContentFilePaths } from "./extractContent/utils/extractDictionaryInfo.js";
|
|
11
10
|
import { extractDictionaryKey, extractDictionaryKeyFromPath } from "./extractContent/utils/extractDictionaryKey.js";
|
|
12
11
|
import { generateKey } from "./extractContent/utils/generateKey.js";
|
|
13
12
|
import { getComponentName } from "./extractContent/utils/getComponentName.js";
|
|
13
|
+
import { mergeWithExistingMultilingualDictionary, mergeWithExistingPerLocaleDictionary, writeContentHelper } from "./extractContent/contentWriter.js";
|
|
14
14
|
import { ExtractIntlayerOptions, extractContent, extractContentSync } from "./extractContent/extractContent.js";
|
|
15
15
|
import { ScriptBlock, extractScriptBlocks, injectScriptBlocks } from "./extractScriptBlocks.js";
|
|
16
16
|
import { CompilerMode, getExtractPluginOptions } from "./getExtractPluginOptions.js";
|
|
17
17
|
import { getOptimizePluginOptions } from "./getOptimizePluginOptions.js";
|
|
18
18
|
import { getMinifyPluginOptions, getPurgePluginOptions } from "./getPurgePluginOptions.js";
|
|
19
|
-
import { BABEL_PARSER_OPTIONS, INTLAYER_USAGE_REGEX, SOURCE_FILE_REGEX, analyzeFieldUsageInFile, buildUsageCheckRegex, optimizeSourceFile, renameFieldsInCode, renameFieldsInSourceFile } from "./transformers.js";
|
|
20
|
-
export { ATTRIBUTES_TO_EXTRACT, BABEL_PARSER_OPTIONS,
|
|
19
|
+
import { BABEL_PARSER_OPTIONS, INTLAYER_USAGE_REGEX, SOURCE_FILE_REGEX, analyzeFieldUsageInFile, buildUsageCheckRegex, getUsageCheckRegex, optimizeSourceFile, renameFieldsInCode, renameFieldsInSourceFile } from "./transformers.js";
|
|
20
|
+
export { ATTRIBUTES_TO_EXTRACT, BABEL_PARSER_OPTIONS, CallerDescriptor, CallerResultShape, CallerValueSource, CompatCallerConfig, type CompilerMode, DEFAULT_COMPAT_CALLERS, DictionaryFieldUsage, ExtractDictionaryInfoOptions, ExtractIntlayerOptions, ExtractPluginOptions, ExtractResult, INTLAYER_CALLER_NAMES, INTLAYER_USAGE_REGEX, IntlayerCallerName, MinifyPluginOptions, NestedRenameEntry, NestedRenameMap, OptimizePluginOptions, PackageName, PruneContext, PurgePluginOptions, ResolveContentFilePaths, SERVER_CAPABLE_PACKAGES, SOURCE_FILE_REGEX, ScriptBlock, analyzeFieldUsageInFile, buildNestedRenameMapFromContent, buildUsageCheckRegex, createPruneContext, detectPackageName, extractContent, extractContentSync, extractDictionaryInfo, extractDictionaryKey, extractDictionaryKeyFromPath, extractScriptBlocks, generateKey, generateShortFieldName, getComponentName, getExtractPluginOptions, getMinifyPluginOptions, getOptimizePluginOptions, getOutput, getPurgePluginOptions, getSharedPruneContext, getUsageCheckRegex, injectScriptBlocks, intlayerExtractBabelPlugin, intlayerMinifyBabelPlugin, intlayerOptimizeBabelPlugin, intlayerPurgeBabelPlugin, makeFieldRenameBabelPlugin, makeUsageAnalyzerBabelPlugin, mergeWithExistingMultilingualDictionary, mergeWithExistingPerLocaleDictionary, optimizeSourceFile, packageList, renameFieldsInCode, renameFieldsInSourceFile, resolveContentFilePaths, writeContentHelper };
|