@intlayer/babel 9.4.3 → 9.5.0
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/README.md +0 -2
- package/dist/cjs/analyzeContentUsage.cjs +301 -0
- package/dist/cjs/analyzeContentUsage.cjs.map +1 -0
- package/dist/cjs/babel-plugin-intlayer-field-rename.cjs +5 -4
- package/dist/cjs/babel-plugin-intlayer-field-rename.cjs.map +1 -1
- package/dist/cjs/babel-plugin-intlayer-optimize.cjs +173 -282
- package/dist/cjs/babel-plugin-intlayer-optimize.cjs.map +1 -1
- package/dist/cjs/babel-plugin-intlayer-purge.cjs +4 -3
- package/dist/cjs/babel-plugin-intlayer-purge.cjs.map +1 -1
- package/dist/cjs/babel-plugin-intlayer-usage-analyzer.cjs +49 -699
- package/dist/cjs/babel-plugin-intlayer-usage-analyzer.cjs.map +1 -1
- package/dist/cjs/compat/namespaceResolution.cjs +124 -0
- package/dist/cjs/compat/namespaceResolution.cjs.map +1 -0
- package/dist/cjs/compat/optimizePass.cjs +144 -0
- package/dist/cjs/compat/optimizePass.cjs.map +1 -0
- package/dist/cjs/compat/usageAnalysis.cjs +195 -0
- package/dist/cjs/compat/usageAnalysis.cjs.map +1 -0
- package/dist/cjs/dictionaryImports.cjs +40 -0
- package/dist/cjs/dictionaryImports.cjs.map +1 -0
- package/dist/cjs/extractContent/utils/extractDictionaryInfo.cjs +1 -1
- package/dist/cjs/getExtractPluginOptions.cjs +1 -1
- package/dist/cjs/getOptimizePluginOptions.cjs +1 -1
- package/dist/cjs/getPurgePluginOptions.cjs +1 -1
- package/dist/cjs/index.cjs +9 -5
- package/dist/cjs/nativeCallers.cjs +41 -0
- package/dist/cjs/nativeCallers.cjs.map +1 -0
- package/dist/cjs/pruneContext.cjs +79 -0
- package/dist/cjs/pruneContext.cjs.map +1 -0
- package/dist/cjs/staticAstReaders.cjs +140 -0
- package/dist/cjs/staticAstReaders.cjs.map +1 -0
- package/dist/cjs/transformers.cjs +2 -1
- package/dist/cjs/transformers.cjs.map +1 -1
- package/dist/esm/analyzeContentUsage.mjs +300 -0
- package/dist/esm/analyzeContentUsage.mjs.map +1 -0
- 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 +173 -282
- package/dist/esm/babel-plugin-intlayer-optimize.mjs.map +1 -1
- package/dist/esm/babel-plugin-intlayer-purge.mjs +3 -2
- package/dist/esm/babel-plugin-intlayer-purge.mjs.map +1 -1
- package/dist/esm/babel-plugin-intlayer-usage-analyzer.mjs +43 -694
- package/dist/esm/babel-plugin-intlayer-usage-analyzer.mjs.map +1 -1
- package/dist/esm/compat/namespaceResolution.mjs +120 -0
- package/dist/esm/compat/namespaceResolution.mjs.map +1 -0
- package/dist/esm/compat/optimizePass.mjs +143 -0
- package/dist/esm/compat/optimizePass.mjs.map +1 -0
- package/dist/esm/compat/usageAnalysis.mjs +193 -0
- package/dist/esm/compat/usageAnalysis.mjs.map +1 -0
- package/dist/esm/dictionaryImports.mjs +38 -0
- package/dist/esm/dictionaryImports.mjs.map +1 -0
- package/dist/esm/extractContent/utils/extractDictionaryInfo.mjs +1 -1
- package/dist/esm/getExtractPluginOptions.mjs +1 -1
- package/dist/esm/getOptimizePluginOptions.mjs +1 -1
- package/dist/esm/getPurgePluginOptions.mjs +1 -1
- package/dist/esm/index.mjs +5 -2
- package/dist/esm/nativeCallers.mjs +38 -0
- package/dist/esm/nativeCallers.mjs.map +1 -0
- package/dist/esm/pruneContext.mjs +76 -0
- package/dist/esm/pruneContext.mjs.map +1 -0
- package/dist/esm/staticAstReaders.mjs +129 -0
- package/dist/esm/staticAstReaders.mjs.map +1 -0
- package/dist/esm/transformers.mjs +2 -1
- package/dist/esm/transformers.mjs.map +1 -1
- package/dist/types/analyzeContentUsage.d.ts +18 -0
- package/dist/types/analyzeContentUsage.d.ts.map +1 -0
- package/dist/types/babel-plugin-intlayer-extract.d.ts +3 -4
- package/dist/types/babel-plugin-intlayer-extract.d.ts.map +1 -1
- package/dist/types/babel-plugin-intlayer-field-rename.d.ts +10 -10
- package/dist/types/babel-plugin-intlayer-field-rename.d.ts.map +1 -1
- package/dist/types/babel-plugin-intlayer-minify.d.ts +2 -3
- package/dist/types/babel-plugin-intlayer-minify.d.ts.map +1 -1
- package/dist/types/babel-plugin-intlayer-optimize.d.ts +11 -18
- package/dist/types/babel-plugin-intlayer-optimize.d.ts.map +1 -1
- package/dist/types/babel-plugin-intlayer-purge.d.ts +7 -7
- package/dist/types/babel-plugin-intlayer-purge.d.ts.map +1 -1
- package/dist/types/babel-plugin-intlayer-usage-analyzer.d.ts +22 -189
- package/dist/types/babel-plugin-intlayer-usage-analyzer.d.ts.map +1 -1
- package/dist/types/babelParser.d.ts +3 -4
- package/dist/types/babelParser.d.ts.map +1 -1
- package/dist/types/compat/namespaceResolution.d.ts +66 -0
- package/dist/types/compat/namespaceResolution.d.ts.map +1 -0
- package/dist/types/compat/optimizePass.d.ts +58 -0
- package/dist/types/compat/optimizePass.d.ts.map +1 -0
- package/dist/types/compat/usageAnalysis.d.ts +75 -0
- package/dist/types/compat/usageAnalysis.d.ts.map +1 -0
- package/dist/types/dictionaryImports.d.ts +46 -0
- package/dist/types/dictionaryImports.d.ts.map +1 -0
- package/dist/types/extractContent/babelProcessor.d.ts +4 -5
- package/dist/types/extractContent/babelProcessor.d.ts.map +1 -1
- package/dist/types/extractContent/contentWriter.d.ts +3 -4
- package/dist/types/extractContent/contentWriter.d.ts.map +1 -1
- package/dist/types/extractContent/extractContent.d.ts +3 -4
- package/dist/types/extractContent/extractContent.d.ts.map +1 -1
- package/dist/types/extractContent/processTsxFile.d.ts +2 -3
- package/dist/types/extractContent/processTsxFile.d.ts.map +1 -1
- package/dist/types/extractContent/utils/constants.d.ts +3 -4
- package/dist/types/extractContent/utils/constants.d.ts.map +1 -1
- package/dist/types/extractContent/utils/detectPackageName.d.ts +1 -2
- package/dist/types/extractContent/utils/detectPackageName.d.ts.map +1 -1
- package/dist/types/extractContent/utils/extractDictionaryInfo.d.ts +5 -6
- package/dist/types/extractContent/utils/extractDictionaryInfo.d.ts.map +1 -1
- package/dist/types/extractContent/utils/extractDictionaryKey.d.ts +2 -3
- package/dist/types/extractContent/utils/extractDictionaryKey.d.ts.map +1 -1
- package/dist/types/extractContent/utils/generateKey.d.ts +1 -2
- package/dist/types/extractContent/utils/generateKey.d.ts.map +1 -1
- package/dist/types/extractContent/utils/getComponentName.d.ts +1 -2
- package/dist/types/extractContent/utils/getComponentName.d.ts.map +1 -1
- package/dist/types/extractContent/utils/getExistingIntlayerInfo.d.ts +2 -3
- package/dist/types/extractContent/utils/getExistingIntlayerInfo.d.ts.map +1 -1
- package/dist/types/extractContent/utils/getOrGenerateKey.d.ts +1 -2
- package/dist/types/extractContent/utils/getOrGenerateKey.d.ts.map +1 -1
- package/dist/types/extractContent/utils/resolveDictionaryKey.d.ts +1 -2
- package/dist/types/extractContent/utils/resolveDictionaryKey.d.ts.map +1 -1
- package/dist/types/extractScriptBlocks.d.ts +3 -4
- package/dist/types/extractScriptBlocks.d.ts.map +1 -1
- package/dist/types/getExtractPluginOptions.d.ts +2 -3
- package/dist/types/getExtractPluginOptions.d.ts.map +1 -1
- package/dist/types/getOptimizePluginOptions.d.ts +1 -2
- package/dist/types/getOptimizePluginOptions.d.ts.map +1 -1
- package/dist/types/getPurgePluginOptions.d.ts +2 -3
- package/dist/types/getPurgePluginOptions.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -2
- package/dist/types/nativeCallers.d.ts +33 -0
- package/dist/types/nativeCallers.d.ts.map +1 -0
- package/dist/types/normalizedFilesList.d.ts +1 -2
- package/dist/types/normalizedFilesList.d.ts.map +1 -1
- package/dist/types/pruneContext.d.ts +152 -0
- package/dist/types/pruneContext.d.ts.map +1 -0
- package/dist/types/staticAstReaders.d.ts +84 -0
- package/dist/types/staticAstReaders.d.ts.map +1 -0
- package/dist/types/transformers.d.ts +11 -11
- package/dist/types/transformers.d.ts.map +1 -1
- package/package.json +12 -12
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* `contentEndOffset` – Byte offset one past the last byte of `content` in the
|
|
9
9
|
* full source string (i.e. `source.slice(start, end) === content`).
|
|
10
10
|
*/
|
|
11
|
-
type ScriptBlock = {
|
|
11
|
+
export type ScriptBlock = {
|
|
12
12
|
content: string;
|
|
13
13
|
contentStartOffset: number;
|
|
14
14
|
contentEndOffset: number;
|
|
@@ -27,7 +27,7 @@ type ScriptBlock = {
|
|
|
27
27
|
* - everything else → treats the whole file as a single script block and
|
|
28
28
|
* returns it wrapped in a single-element array.
|
|
29
29
|
*/
|
|
30
|
-
declare const extractScriptBlocks: (filePath: string, code: string) => ScriptBlock[];
|
|
30
|
+
export declare const extractScriptBlocks: (filePath: string, code: string) => ScriptBlock[];
|
|
31
31
|
/**
|
|
32
32
|
* Applies modified script block content back into the original source string.
|
|
33
33
|
*
|
|
@@ -38,10 +38,9 @@ declare const extractScriptBlocks: (filePath: string, code: string) => ScriptBlo
|
|
|
38
38
|
*
|
|
39
39
|
* Returns `originalCode` unchanged when `modifications` is empty.
|
|
40
40
|
*/
|
|
41
|
-
declare const injectScriptBlocks: (originalCode: string, modifications: ReadonlyArray<{
|
|
41
|
+
export declare const injectScriptBlocks: (originalCode: string, modifications: ReadonlyArray<{
|
|
42
42
|
block: ScriptBlock;
|
|
43
43
|
modifiedContent: string;
|
|
44
44
|
}>) => string;
|
|
45
45
|
//#endregion
|
|
46
|
-
export { ScriptBlock, extractScriptBlocks, injectScriptBlocks };
|
|
47
46
|
//# sourceMappingURL=extractScriptBlocks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractScriptBlocks.d.ts","names":[],"sources":["../../src/extractScriptBlocks.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"extractScriptBlocks.d.ts","names":[],"sources":["../../src/extractScriptBlocks.ts"],"mappings":";;;;;;;;;;YAWY;EACV;EACA;EACA;;;;;;;;;;;;;;;;qBA8FW,sBAAmB,kBACd,iBAEf;;;;;;;;;;;qBA+BU,qBAAkB,sBACT,eACL;EACb,OAAO;EACP"}
|
|
@@ -6,13 +6,12 @@ import { IntlayerConfig } from "@intlayer/types/config";
|
|
|
6
6
|
* - 'dev': Development mode with HMR support
|
|
7
7
|
* - 'build': Production build mode
|
|
8
8
|
*/
|
|
9
|
-
type CompilerMode = 'dev' | 'build';
|
|
9
|
+
export type CompilerMode = 'dev' | 'build';
|
|
10
10
|
/**
|
|
11
11
|
* Get the options for the Intlayer Babel extraction plugin
|
|
12
12
|
* This function loads the Intlayer configuration and sets up the onExtract callback
|
|
13
13
|
* to write dictionaries to the filesystem.
|
|
14
14
|
*/
|
|
15
|
-
declare const getExtractPluginOptions: (configuration?: IntlayerConfig, isDev?: CompilerMode | string | undefined) => ExtractPluginOptions;
|
|
15
|
+
export declare const getExtractPluginOptions: (configuration?: IntlayerConfig, isDev?: CompilerMode | string | undefined) => ExtractPluginOptions;
|
|
16
16
|
//#endregion
|
|
17
|
-
export { CompilerMode, getExtractPluginOptions };
|
|
18
17
|
//# sourceMappingURL=getExtractPluginOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getExtractPluginOptions.d.ts","names":[],"sources":["../../src/getExtractPluginOptions.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"getExtractPluginOptions.d.ts","names":[],"sources":["../../src/getExtractPluginOptions.ts"],"mappings":";;;;;;;;YAcY;;;;;;qBAOC,0BAAuB,gBACnB,gBAAc,QACtB,sCACN"}
|
|
@@ -27,7 +27,6 @@ type GetOptimizePluginOptionsParams = {
|
|
|
27
27
|
* This function loads the Intlayer configuration and returns the paths
|
|
28
28
|
* needed for dictionary optimization and import rewriting.
|
|
29
29
|
*/
|
|
30
|
-
declare const getOptimizePluginOptions: (params?: GetOptimizePluginOptionsParams) => OptimizePluginOptions;
|
|
30
|
+
export declare const getOptimizePluginOptions: (params?: GetOptimizePluginOptionsParams) => OptimizePluginOptions;
|
|
31
31
|
//#endregion
|
|
32
|
-
export { getOptimizePluginOptions };
|
|
33
32
|
//# sourceMappingURL=getOptimizePluginOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOptimizePluginOptions.d.ts","names":[],"sources":["../../src/getOptimizePluginOptions.ts"],"mappings":";;;;KAWK;;;;EAIH,gBAAgB;;;;EAIhB,eAAe;;;;;;EAMf;;;;EAIA,YAAY,QAAQ;;;;;;;
|
|
1
|
+
{"version":3,"file":"getOptimizePluginOptions.d.ts","names":[],"sources":["../../src/getOptimizePluginOptions.ts"],"mappings":";;;;KAWK;;;;EAIH,gBAAgB;;;;EAIhB,eAAe;;;;;;EAMf;;;;EAIA,YAAY,QAAQ;;;;;;;qBAyBT,2BAAwB,SAC1B,mCACR"}
|
|
@@ -44,7 +44,7 @@ type GetPurgePluginOptionsParams = {
|
|
|
44
44
|
* };
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
|
-
declare const getPurgePluginOptions: (params?: GetPurgePluginOptionsParams) => PurgePluginOptions;
|
|
47
|
+
export declare const getPurgePluginOptions: (params?: GetPurgePluginOptionsParams) => PurgePluginOptions;
|
|
48
48
|
type GetMinifyPluginOptionsParams = {
|
|
49
49
|
/**
|
|
50
50
|
* Options forwarded to the intlayer configuration loader.
|
|
@@ -76,7 +76,6 @@ type GetMinifyPluginOptionsParams = {
|
|
|
76
76
|
* };
|
|
77
77
|
* ```
|
|
78
78
|
*/
|
|
79
|
-
declare const getMinifyPluginOptions: (params?: GetMinifyPluginOptionsParams) => MinifyPluginOptions;
|
|
79
|
+
export declare const getMinifyPluginOptions: (params?: GetMinifyPluginOptionsParams) => MinifyPluginOptions;
|
|
80
80
|
//#endregion
|
|
81
|
-
export { getMinifyPluginOptions, getPurgePluginOptions };
|
|
82
81
|
//# sourceMappingURL=getPurgePluginOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPurgePluginOptions.d.ts","names":[],"sources":["../../src/getPurgePluginOptions.ts"],"mappings":";;;;;KAmCK;;;;;;EAMH,gBAAgB;;;;;;EAOhB,eAAe;;;;EAKf,YAAY,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"getPurgePluginOptions.d.ts","names":[],"sources":["../../src/getPurgePluginOptions.ts"],"mappings":";;;;;KAmCK;;;;;;EAMH,gBAAgB;;;;;;EAOhB,eAAe;;;;EAKf,YAAY,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;qBA0BT,wBAAqB,SACvB,gCACR;KA8CE;;;;EAIH,gBAAgB;;;;EAKhB,YAAY,QAAQ;;;;;;;;;;;;;;;;;;;;;;;qBAwBT,yBAAsB,SACxB,iCACR"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { DictionaryFieldUsage, NestedRenameEntry, NestedRenameMap, OpaqueFieldOccurrence, PruneContext, createPruneContext, preserveNestedDictionaryFields } from "./pruneContext.js";
|
|
1
2
|
import { PackageName, SERVER_CAPABLE_PACKAGES, packageList } from "./extractContent/utils/constants.js";
|
|
2
3
|
import { ExtractPluginOptions, ExtractResult, intlayerExtractBabelPlugin } from "./babel-plugin-intlayer-extract.js";
|
|
3
|
-
import { CHAINABLE_RUNTIME_METHOD_NAMES,
|
|
4
|
+
import { CHAINABLE_RUNTIME_METHOD_NAMES, INTLAYER_CALLER_NAMES, IntlayerCallerName, NATIVE_CALLER_NAME_SET } from "./nativeCallers.js";
|
|
5
|
+
import { unwrapAwait } from "./staticAstReaders.js";
|
|
6
|
+
import { CallerDescriptor, CallerResultShape, CallerValueSource, CompatCallerConfig, DEFAULT_COMPAT_CALLERS, makeUsageAnalyzerBabelPlugin } from "./babel-plugin-intlayer-usage-analyzer.js";
|
|
4
7
|
import { SerializedFieldRenameEntry, SerializedFieldRenameMap, buildNestedRenameMapFromContent, generateShortFieldName, getNestedRenameEntryAtPath, makeFieldRenameBabelPlugin, renameIntlayerFieldAccesses, serializeFieldRenameMap } from "./babel-plugin-intlayer-field-rename.js";
|
|
5
8
|
import { MinifyPluginOptions, intlayerMinifyBabelPlugin } from "./babel-plugin-intlayer-minify.js";
|
|
6
9
|
import { OptimizePluginOptions, intlayerOptimizeBabelPlugin } from "./babel-plugin-intlayer-optimize.js";
|
|
@@ -18,4 +21,4 @@ import { CompilerMode, getExtractPluginOptions } from "./getExtractPluginOptions
|
|
|
18
21
|
import { getOptimizePluginOptions } from "./getOptimizePluginOptions.js";
|
|
19
22
|
import { getMinifyPluginOptions, getPurgePluginOptions } from "./getPurgePluginOptions.js";
|
|
20
23
|
import { BABEL_PARSER_OPTIONS, INTLAYER_USAGE_REGEX, SOURCE_FILE_REGEX, analyzeFieldUsageInFile, buildUsageCheckRegex, getUsageCheckRegex, optimizeSourceFile, renameFieldsInCode, renameFieldsInSourceFile } from "./transformers.js";
|
|
21
|
-
export { BABEL_PARSER_OPTIONS, CHAINABLE_RUNTIME_METHOD_NAMES, type CallerDescriptor, type CallerResultShape, type CallerValueSource, CompatCallerConfig, CompilerMode, DEFAULT_COMPAT_CALLERS, DictionaryFieldUsage, ExtractDictionaryInfoOptions, ExtractIntlayerOptions, ExtractPluginOptions, ExtractResult, INTLAYER_CALLER_NAMES, INTLAYER_USAGE_REGEX, IntlayerCallerName, MinifyPluginOptions, NestedRenameEntry, NestedRenameMap, OpaqueFieldOccurrence, OptimizePluginOptions, PackageName, PruneContext, PurgePluginOptions, ResolveContentFilePaths, SERVER_CAPABLE_PACKAGES, SOURCE_FILE_REGEX, ScriptBlock, SerializedFieldRenameEntry, SerializedFieldRenameMap, analyzeFieldUsageInFile, buildNestedRenameMapFromContent, buildUsageCheckRegex, createPruneContext, detectPackageName, extractContent, extractContentSync, extractDictionaryInfo, extractDictionaryKey, extractDictionaryKeyFromPath, extractScriptBlocks, generateKey, generateShortFieldName, getComponentName, getExtractPluginOptions, getMinifyPluginOptions, getNestedRenameEntryAtPath, getOptimizePluginOptions, getOutput, getPurgePluginOptions, getSharedPruneContext, getUsageCheckRegex, injectScriptBlocks, intlayerExtractBabelPlugin, intlayerMinifyBabelPlugin, intlayerOptimizeBabelPlugin, intlayerPurgeBabelPlugin, makeFieldRenameBabelPlugin, makeUsageAnalyzerBabelPlugin, mergeWithExistingMultilingualDictionary, mergeWithExistingPerLocaleDictionary, optimizeSourceFile, packageList, preserveNestedDictionaryFields, renameFieldsInCode, renameFieldsInSourceFile, renameIntlayerFieldAccesses, resolveContentFilePaths, runIntlayerPurgePipeline, serializeFieldRenameMap, unwrapAwait, writeContentHelper };
|
|
24
|
+
export { BABEL_PARSER_OPTIONS, CHAINABLE_RUNTIME_METHOD_NAMES, type CallerDescriptor, type CallerResultShape, type CallerValueSource, CompatCallerConfig, CompilerMode, DEFAULT_COMPAT_CALLERS, type DictionaryFieldUsage, ExtractDictionaryInfoOptions, ExtractIntlayerOptions, ExtractPluginOptions, ExtractResult, INTLAYER_CALLER_NAMES, INTLAYER_USAGE_REGEX, type IntlayerCallerName, MinifyPluginOptions, NATIVE_CALLER_NAME_SET, type NestedRenameEntry, type NestedRenameMap, type OpaqueFieldOccurrence, OptimizePluginOptions, PackageName, type PruneContext, PurgePluginOptions, ResolveContentFilePaths, SERVER_CAPABLE_PACKAGES, SOURCE_FILE_REGEX, ScriptBlock, SerializedFieldRenameEntry, SerializedFieldRenameMap, analyzeFieldUsageInFile, buildNestedRenameMapFromContent, buildUsageCheckRegex, createPruneContext, detectPackageName, extractContent, extractContentSync, extractDictionaryInfo, extractDictionaryKey, extractDictionaryKeyFromPath, extractScriptBlocks, generateKey, generateShortFieldName, getComponentName, getExtractPluginOptions, getMinifyPluginOptions, getNestedRenameEntryAtPath, getOptimizePluginOptions, getOutput, getPurgePluginOptions, getSharedPruneContext, getUsageCheckRegex, injectScriptBlocks, intlayerExtractBabelPlugin, intlayerMinifyBabelPlugin, intlayerOptimizeBabelPlugin, intlayerPurgeBabelPlugin, makeFieldRenameBabelPlugin, makeUsageAnalyzerBabelPlugin, mergeWithExistingMultilingualDictionary, mergeWithExistingPerLocaleDictionary, optimizeSourceFile, packageList, preserveNestedDictionaryFields, renameFieldsInCode, renameFieldsInSourceFile, renameIntlayerFieldAccesses, resolveContentFilePaths, runIntlayerPurgePipeline, serializeFieldRenameMap, unwrapAwait, writeContentHelper };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/nativeCallers.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The intlayer getters the build pipeline recognises without any adapter, and
|
|
4
|
+
* the runtime methods their result carries.
|
|
5
|
+
*
|
|
6
|
+
* Kept apart from the compat registry (`@intlayer/config/callers`) so the
|
|
7
|
+
* native passes never have to reason about adapter descriptors.
|
|
8
|
+
*/
|
|
9
|
+
/** Canonical intlayer caller names that trigger usage analysis. */
|
|
10
|
+
export declare const INTLAYER_CALLER_NAMES: readonly ['useIntlayer', 'getIntlayer', 'getIntlayerAsync'];
|
|
11
|
+
export type IntlayerCallerName = (typeof INTLAYER_CALLER_NAMES)[number];
|
|
12
|
+
/**
|
|
13
|
+
* {@link INTLAYER_CALLER_NAMES} as a set — the import scan tests every
|
|
14
|
+
* specifier of every file against it, so membership must not be a linear scan.
|
|
15
|
+
*/
|
|
16
|
+
export declare const NATIVE_CALLER_NAME_SET: ReadonlySet<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Methods the runtime attaches to a resolved content object rather than fields
|
|
19
|
+
* declared in a `.content` file.
|
|
20
|
+
*
|
|
21
|
+
* `vanilla-intlayer`'s `useIntlayer` / `useDictionary` assign `onChange` onto
|
|
22
|
+
* the content they return, so `useIntlayer('app').onChange(cb)` is a
|
|
23
|
+
* subscription — not a read of a field named `onChange`. Without this list the
|
|
24
|
+
* analyser records `onChange` as the only consumed field and the purge pass
|
|
25
|
+
* strips every real field from the compiled dictionary.
|
|
26
|
+
*
|
|
27
|
+
* The analyser looks *through* these calls: the callback parameter is analysed
|
|
28
|
+
* as a fresh content root, and the call result is analysed again because the
|
|
29
|
+
* helpers return the content object for chaining.
|
|
30
|
+
*/
|
|
31
|
+
export declare const CHAINABLE_RUNTIME_METHOD_NAMES: Set<string>;
|
|
32
|
+
//#endregion
|
|
33
|
+
//# sourceMappingURL=nativeCallers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeCallers.d.ts","names":[],"sources":["../../src/nativeCallers.ts"],"mappings":";;;;;;;;;qBASa;YAMD,6BAA6B;;;;;qBAM5B,wBAAwB;;;;;;;;;;;;;;;qBAkBxB,gCAA8B"}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* @param filesList - The plugin's `filesList` option (absolute file paths).
|
|
7
7
|
* @returns A set of the same paths normalized via `normalizePath`.
|
|
8
8
|
*/
|
|
9
|
-
declare const getNormalizedFilesListSet: (filesList: readonly string[]) => Set<string>;
|
|
9
|
+
export declare const getNormalizedFilesListSet: (filesList: readonly string[]) => Set<string>;
|
|
10
10
|
//#endregion
|
|
11
|
-
export { getNormalizedFilesListSet };
|
|
12
11
|
//# sourceMappingURL=normalizedFilesList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizedFilesList.d.ts","names":[],"sources":["../../src/normalizedFilesList.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"normalizedFilesList.d.ts","names":[],"sources":["../../src/normalizedFilesList.ts"],"mappings":";;;;;;;;qBAiBa,4BAAyB,iCAEnC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { NestedFieldReferences } from "@intlayer/core/dictionaryManipulator";
|
|
2
|
+
//#region src/pruneContext.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Dictionary field usage result for a single dictionary key.
|
|
5
|
+
*
|
|
6
|
+
* 'all' → could not determine statically which fields are used;
|
|
7
|
+
* keep every field (no pruning possible).
|
|
8
|
+
* Set<string> → the exact top-level content field names that were accessed.
|
|
9
|
+
*/
|
|
10
|
+
export type DictionaryFieldUsage = Set<string> | 'all';
|
|
11
|
+
/**
|
|
12
|
+
* One node in the nested field-rename tree.
|
|
13
|
+
*
|
|
14
|
+
* shortName – the compact alias assigned to this field name.
|
|
15
|
+
* children – rename table for the next level of user-defined keys inside
|
|
16
|
+
* this field's value (empty when the value is a leaf / primitive).
|
|
17
|
+
*/
|
|
18
|
+
export type NestedRenameEntry = {
|
|
19
|
+
shortName: string;
|
|
20
|
+
children: NestedRenameMap;
|
|
21
|
+
};
|
|
22
|
+
/** A level of the field-rename tree, mapping original field names to entries. */
|
|
23
|
+
export type NestedRenameMap = Map<string, NestedRenameEntry>;
|
|
24
|
+
/**
|
|
25
|
+
* One opaque consumption of a dictionary content value: the value at
|
|
26
|
+
* `fieldPath` escapes static analysis (passed as-is to a child component or a
|
|
27
|
+
* function argument), so its children must keep their original key names in
|
|
28
|
+
* the compiled JSON.
|
|
29
|
+
*/
|
|
30
|
+
export type OpaqueFieldOccurrence = {
|
|
31
|
+
/**
|
|
32
|
+
* Original (pre-rename) user-defined field names from the content root to
|
|
33
|
+
* the escaping value, e.g. `['sections', 'hero']` for
|
|
34
|
+
* `<Card data={content.sections.hero} />`.
|
|
35
|
+
*/
|
|
36
|
+
fieldPath: string[];
|
|
37
|
+
/** Source locations (`filePath:line`) where the value escapes. */
|
|
38
|
+
locations: string[];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Shared mutable state created once by the vite plugin and passed by reference
|
|
42
|
+
* to the usage-analyzer (writer) and the prune/minify plugins (readers).
|
|
43
|
+
*
|
|
44
|
+
* All mutations happen during the usage-analysis `buildStart` phase; readers
|
|
45
|
+
* only access this state during the subsequent `transform` phase.
|
|
46
|
+
*/
|
|
47
|
+
export type PruneContext = {
|
|
48
|
+
/**
|
|
49
|
+
* Maps every dictionary key seen in source files to the set of top-level
|
|
50
|
+
* content fields statically accessed, or `'all'` when the access pattern
|
|
51
|
+
* could not be determined.
|
|
52
|
+
*/
|
|
53
|
+
dictionaryKeyToFieldUsageMap: Map<string, DictionaryFieldUsage>;
|
|
54
|
+
/**
|
|
55
|
+
* Dictionary keys for which the prune/minify step must be skipped entirely
|
|
56
|
+
* because an edge case was detected during analysis or structure recognition.
|
|
57
|
+
*/
|
|
58
|
+
dictionariesWithEdgeCases: Set<string>;
|
|
59
|
+
/**
|
|
60
|
+
* True if at least one source file failed to parse during the analysis phase.
|
|
61
|
+
* The prune plugin uses this flag conservatively: any dictionary key without
|
|
62
|
+
* a usage entry might have been referenced by the unparsable file.
|
|
63
|
+
*/
|
|
64
|
+
hasUnparsableSourceFiles: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Maps dictionary keys to the source file paths where the result of
|
|
67
|
+
* `useIntlayer` / `getIntlayer` was assigned to a plain variable, making
|
|
68
|
+
* static field analysis impossible.
|
|
69
|
+
*/
|
|
70
|
+
dictionaryKeysWithUntrackedBindings: Map<string, string[]>;
|
|
71
|
+
/**
|
|
72
|
+
* Maps each dictionary key to a nested field-rename tree built after the
|
|
73
|
+
* usage analysis phase (only populated when `build.minify` is active and
|
|
74
|
+
* the field usage for that dictionary is a finite `Set<string>`).
|
|
75
|
+
*/
|
|
76
|
+
dictionaryKeyToFieldRenameMap: Map<string, NestedRenameMap>;
|
|
77
|
+
/**
|
|
78
|
+
* Maps each dictionary key to the content field paths whose values are
|
|
79
|
+
* consumed "opaquely" (passed as-is to a child component or function
|
|
80
|
+
* argument). When an opaque value has nested user-defined structure, its
|
|
81
|
+
* children must not be renamed.
|
|
82
|
+
*
|
|
83
|
+
* The inner map is keyed by the dot-joined field path for de-duplication
|
|
84
|
+
* only; the authoritative path is {@link OpaqueFieldOccurrence.fieldPath}.
|
|
85
|
+
*
|
|
86
|
+
* Structure: dictionaryKey → joinedFieldPath → { fieldPath, locations }
|
|
87
|
+
*/
|
|
88
|
+
dictionaryKeysWithOpaqueFields: Map<string, Map<string, OpaqueFieldOccurrence>>;
|
|
89
|
+
/**
|
|
90
|
+
* Dictionary keys for which field-key renaming must be skipped even if a
|
|
91
|
+
* finite field-usage set was determined.
|
|
92
|
+
*
|
|
93
|
+
* Populated for dictionaries whose plain-variable bindings were resolved by
|
|
94
|
+
* the framework-specific extractor (Vue / Svelte SFCs), because the Babel
|
|
95
|
+
* rename plugin cannot update the source-code property accesses for those
|
|
96
|
+
* indirect patterns (Vue `.value.field` / Svelte `$store.field`).
|
|
97
|
+
*
|
|
98
|
+
* Pruning and basic minification still apply; only field-key renaming is
|
|
99
|
+
* suppressed.
|
|
100
|
+
*/
|
|
101
|
+
dictionariesSkippingFieldRename: Set<string>;
|
|
102
|
+
/**
|
|
103
|
+
* Plain variable bindings that require a framework-specific secondary pass.
|
|
104
|
+
*
|
|
105
|
+
* Populated during the Babel analysis phase for `.vue` and `.svelte` source
|
|
106
|
+
* files where direct field access is not visible to Babel scope analysis:
|
|
107
|
+
* - Vue: `content.value.fieldName` – the `.value` ref-accessor is hidden
|
|
108
|
+
* - Svelte: `$varName.fieldName` – the `$` prefix creates a new identifier
|
|
109
|
+
*
|
|
110
|
+
* Structure: filePath → [{variableName, dictionaryKey}, …]
|
|
111
|
+
*/
|
|
112
|
+
pendingFrameworkAnalysis: Map<string, {
|
|
113
|
+
variableName: string;
|
|
114
|
+
dictionaryKey: string;
|
|
115
|
+
}[]>;
|
|
116
|
+
};
|
|
117
|
+
export declare const createPruneContext: () => PruneContext;
|
|
118
|
+
/**
|
|
119
|
+
* Records `nest()` references in a prune context so nest targets stay
|
|
120
|
+
* resolvable — and no larger than they need to be — after purge and minify.
|
|
121
|
+
*
|
|
122
|
+
* A nested node stores the ORIGINAL dot path of the field it reads
|
|
123
|
+
* (`nest('common', 'period')` → `'period'`) and `getNesting` resolves it at
|
|
124
|
+
* runtime against the compiled JSON. That drives three adjustments:
|
|
125
|
+
*
|
|
126
|
+
* - Nest targets never take part in field renaming, since the stored path
|
|
127
|
+
* would no longer match the renamed keys.
|
|
128
|
+
* - A target already consumed by a call site keeps its analysed fields plus
|
|
129
|
+
* the nested ones, so neither consumer loses content.
|
|
130
|
+
* - A target reached *only* through `nest()` is given a usage entry holding
|
|
131
|
+
* exactly the nested fields. Without one, the purge pass leaves the whole
|
|
132
|
+
* dictionary untouched; with one, it trims the dictionary down to what the
|
|
133
|
+
* nest references actually read. This matters most for `dynamic` / `fetch`
|
|
134
|
+
* dictionaries, whose full static snapshot would otherwise be pulled into
|
|
135
|
+
* the eager bundle just to satisfy a single nested field.
|
|
136
|
+
*
|
|
137
|
+
* Seeding is skipped when a source file failed to parse: that file could
|
|
138
|
+
* reference the dictionary in a way the analysis never saw, which is the same
|
|
139
|
+
* guard the purge pass applies to keys with no usage entry.
|
|
140
|
+
*
|
|
141
|
+
* @param pruneContext - Shared analysis state to update in place.
|
|
142
|
+
* @param nestedDictionaryReferences - Nest-target key → referenced top-level
|
|
143
|
+
* fields, as returned by `getNestedDictionaryReferences`.
|
|
144
|
+
*/
|
|
145
|
+
export declare const preserveNestedDictionaryFields: (pruneContext: PruneContext, nestedDictionaryReferences: Map<string, NestedFieldReferences>) => void;
|
|
146
|
+
/**
|
|
147
|
+
* Records the usage of a specific dictionary key's fields into `pruneContext`.
|
|
148
|
+
* Merges with any previously recorded usage for the same key.
|
|
149
|
+
*/
|
|
150
|
+
export declare const recordFieldUsage: (pruneContext: PruneContext, dictionaryKey: string, fieldUsage: DictionaryFieldUsage) => void;
|
|
151
|
+
//#endregion
|
|
152
|
+
//# sourceMappingURL=pruneContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pruneContext.d.ts","names":[],"sources":["../../src/pruneContext.ts"],"mappings":";;;;;;;;;YASY,uBAAuB;;;;;;;;YASvB;EACV;EACA,UAAU;;;YAIA,kBAAkB,YAAY;;;;;;;YAQ9B;;;;;;EAMV;;EAGA;;;;;;;;;YAUU;;;;;;EAMV,8BAA8B,YAAY;;;;;EAM1C,2BAA2B;;;;;;EAO3B;;;;;;EAOA,qCAAqC;;;;;;EAOrC,+BAA+B,YAAY;;;;;;;;;;;;EAa3C,gCAAgC,YAE9B,YAAY;;;;;;;;;;;;;EAed,iCAAiC;;;;;;;;;;;EAYjC,0BAA0B;IAEtB;IAAsB;;;qBAIf,0BAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAyCzB,iCAA8B,cAC3B,cAAY,4BACE,YAAY;;;;;qBAyC7B,mBAAgB,cACb,cAAY,uBACL,YACT"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { NodePath } from "@babel/core";
|
|
2
|
+
import * as BabelTypes from "@babel/types";
|
|
3
|
+
//#region src/staticAstReaders.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Static-value readers shared by every pass that has to decide, at build time,
|
|
6
|
+
* which dictionary a call site reads.
|
|
7
|
+
*
|
|
8
|
+
* They were previously duplicated — with small behavioural drifts — between
|
|
9
|
+
* `babel-plugin-intlayer-optimize` and `babel-plugin-intlayer-usage-analyzer`.
|
|
10
|
+
* Both now read through this module so a call site the analyser can attribute
|
|
11
|
+
* is exactly the one the optimizer can rewrite.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Reads a fully-static string from an AST node. Returns `undefined` for
|
|
15
|
+
* dynamic values (identifiers, expressions, template literals with
|
|
16
|
+
* interpolations, …).
|
|
17
|
+
*/
|
|
18
|
+
export declare const readStaticString: (babelTypes: typeof BabelTypes, node: BabelTypes.Node | null | undefined) => string | undefined;
|
|
19
|
+
/** Returns the first dot-path segment of a key, e.g. `'a.b.c'` → `'a'`. */
|
|
20
|
+
export declare const firstPathSegment: (path: string) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Reads the static first dot-path segment from a message-id node.
|
|
23
|
+
*
|
|
24
|
+
* t('counter.label') → 'counter'
|
|
25
|
+
* t(`counter.${x}`) → 'counter' (static prefix before the first dot)
|
|
26
|
+
* t(`${x}.label`) → undefined (dynamic first segment)
|
|
27
|
+
* t(someVariable) → undefined
|
|
28
|
+
*/
|
|
29
|
+
export declare const readStaticFirstSegment: (babelTypes: typeof BabelTypes, node: BabelTypes.Node | null | undefined) => string | undefined;
|
|
30
|
+
/** Whether an object-property key (identifier or string literal) reads as `name`. */
|
|
31
|
+
export declare const propertyKeyMatches: (babelTypes: typeof BabelTypes, property: BabelTypes.ObjectProperty, name: string) => boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the `ObjectProperty` named `propertyName`, or `undefined` when the
|
|
34
|
+
* object has no such property. Callers that need to mutate the property in
|
|
35
|
+
* place (rewriting or deleting it) use this rather than a value reader.
|
|
36
|
+
*/
|
|
37
|
+
export declare const findObjectProperty: (babelTypes: typeof BabelTypes, objectExpression: BabelTypes.ObjectExpression, propertyName: string) => BabelTypes.ObjectProperty | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Marker returned by the reader helpers when the requested property or
|
|
40
|
+
* argument is simply absent — distinct from present-but-dynamic, which the
|
|
41
|
+
* callers must treat conservatively.
|
|
42
|
+
*/
|
|
43
|
+
export declare const ABSENT_VALUE: '__default__';
|
|
44
|
+
/** Either a statically-known value, {@link ABSENT_VALUE}, or `undefined` (dynamic). */
|
|
45
|
+
export type StaticOrAbsent<T> = T | typeof ABSENT_VALUE | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Reads a static string property from an object expression. Returns
|
|
48
|
+
* {@link ABSENT_VALUE} when the property is absent and `undefined` when
|
|
49
|
+
* present but dynamic.
|
|
50
|
+
*/
|
|
51
|
+
export declare const readObjectProperty: (babelTypes: typeof BabelTypes, objectExpression: BabelTypes.ObjectExpression, propertyName: string) => StaticOrAbsent<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Returns the value *node* of a named property, so callers can apply their own
|
|
54
|
+
* reader to it (a full static string, or just its leading path segment).
|
|
55
|
+
* Returns {@link ABSENT_VALUE} when the property is absent.
|
|
56
|
+
*/
|
|
57
|
+
export declare const readObjectPropertyNode: (babelTypes: typeof BabelTypes, objectExpression: BabelTypes.ObjectExpression, propertyName: string) => StaticOrAbsent<BabelTypes.Node>;
|
|
58
|
+
/**
|
|
59
|
+
* Reads a named JSX attribute as a static string and returns it wrapped in a
|
|
60
|
+
* `StringLiteral` node so the result can be fed to the same namespace resolver
|
|
61
|
+
* as a call argument. Handles both `id="home.title"` and `id={'home.title'}`.
|
|
62
|
+
* Returns `undefined` when the attribute is absent or dynamic (`id={expr}`).
|
|
63
|
+
*/
|
|
64
|
+
export declare const readJsxAttributeString: (babelTypes: typeof BabelTypes, openingElement: BabelTypes.JSXOpeningElement, attributeName: string) => BabelTypes.StringLiteral | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Splits a compat namespace at the first `.` to separate the dictionary key
|
|
67
|
+
* from an optional key prefix, mirroring the SWC plugin's `split_namespace`.
|
|
68
|
+
*
|
|
69
|
+
* `'about'` → `{ dictionaryKey: 'about', keyPrefix: '' }`
|
|
70
|
+
* `'about.counter'` → `{ dictionaryKey: 'about', keyPrefix: 'counter' }`
|
|
71
|
+
*/
|
|
72
|
+
export declare const splitNamespace: (namespace: string) => {
|
|
73
|
+
dictionaryKey: string;
|
|
74
|
+
keyPrefix: string;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Climbs past an enclosing `await` expression so that
|
|
78
|
+
* `const t = await getTranslations('ns')` — or `await getIntlayerAsync('key')`
|
|
79
|
+
* — is resolved to its variable declarator the same way the synchronous form
|
|
80
|
+
* is.
|
|
81
|
+
*/
|
|
82
|
+
export declare const unwrapAwait: (babelTypes: typeof BabelTypes, path: NodePath<BabelTypes.Node>) => NodePath<BabelTypes.Node>;
|
|
83
|
+
//#endregion
|
|
84
|
+
//# sourceMappingURL=staticAstReaders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staticAstReaders.d.ts","names":[],"sources":["../../src/staticAstReaders.ts"],"mappings":";;;;;;;;;;;;;;;;;qBAkBa,mBAAgB,mBACR,YAAU,MACvB,WAAW;;qBAeN,mBAAgB;;;;;;;;;qBAWhB,yBAAsB,mBACd,YAAU,MACvB,WAAW;;qBAkBN,qBAAkB,mBACV,YAAU,UACnB,WAAW,gBAAc;;;;;;qBAWxB,qBAAkB,mBACV,YAAU,kBACX,WAAW,kBAAgB,yBAE5C,WAAW;;;;;;qBAaD;;YAGD,eAAe,KAAK,WAAW;;;;;;qBAO9B,qBAAkB,mBACV,YAAU,kBACX,WAAW,kBAAgB,yBAE5C;;;;;;qBAeU,yBAAsB,mBACd,YAAU,kBACX,WAAW,kBAAgB,yBAE5C,eAAe,WAAW;;;;;;;qBAgBhB,yBAAsB,mBACd,YAAU,gBACb,WAAW,mBAAiB,0BAE3C,WAAW;;;;;;;;qBAgCD,iBAAc;EAEtB;EAAuB;;;;;;;;qBAef,cAAW,mBACH,YAAU,MACvB,SAAS,WAAW,UACzB,SAAS,WAAW"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PruneContext } from "./pruneContext.js";
|
|
2
|
+
import { CompatCallerConfig } from "./babel-plugin-intlayer-usage-analyzer.js";
|
|
2
3
|
import { OptimizePluginOptions } from "./babel-plugin-intlayer-optimize.js";
|
|
3
4
|
import { ParserOptions } from "@babel/parser";
|
|
4
5
|
//#region src/transformers.d.ts
|
|
@@ -6,7 +7,7 @@ import { ParserOptions } from "@babel/parser";
|
|
|
6
7
|
* Babel parser options covering the superset of syntaxes used across all
|
|
7
8
|
* supported frameworks (React / Vue / Svelte / Angular / …).
|
|
8
9
|
*/
|
|
9
|
-
declare const BABEL_PARSER_OPTIONS: ParserOptions;
|
|
10
|
+
export declare const BABEL_PARSER_OPTIONS: ParserOptions;
|
|
10
11
|
/**
|
|
11
12
|
* Builds a fast pre-check regex that matches files potentially containing
|
|
12
13
|
* native intlayer calls and/or the given compat namespace caller names.
|
|
@@ -26,25 +27,25 @@ declare const BABEL_PARSER_OPTIONS: ParserOptions;
|
|
|
26
27
|
* (e.g. `['useTranslation', 'getFixedT']` from `@intlayer/react-i18next`).
|
|
27
28
|
* @returns A `RegExp` matching any of the native or provided caller names.
|
|
28
29
|
*/
|
|
29
|
-
declare const buildUsageCheckRegex: (extraCallerNames?: string[]) => RegExp;
|
|
30
|
+
export declare const buildUsageCheckRegex: (extraCallerNames?: string[]) => RegExp;
|
|
30
31
|
/**
|
|
31
32
|
* Fast pre-check: matches files that could contain native intlayer calls
|
|
32
33
|
* (`useIntlayer` / `getIntlayer` / `getIntlayerAsync`). Used by the
|
|
33
34
|
* optimize/transform pass, which only rewrites native calls.
|
|
34
35
|
*/
|
|
35
|
-
declare const INTLAYER_USAGE_REGEX: RegExp;
|
|
36
|
+
export declare const INTLAYER_USAGE_REGEX: RegExp;
|
|
36
37
|
/**
|
|
37
38
|
* Returns the usage-check regex for the given compat callers, memoised by the
|
|
38
39
|
* array reference. Plugins pass the same options array for every analysed
|
|
39
40
|
* file, so the regex is built once per build instead of once per file.
|
|
40
41
|
*/
|
|
41
|
-
declare const getUsageCheckRegex: (compatCallers?: readonly CompatCallerConfig[]) => RegExp;
|
|
42
|
+
export declare const getUsageCheckRegex: (compatCallers?: readonly CompatCallerConfig[]) => RegExp;
|
|
42
43
|
/**
|
|
43
44
|
* Matches source files that are valid targets for usage analysis and Babel
|
|
44
45
|
* transformation. Excludes sourcemap files, declaration files, and other
|
|
45
46
|
* non-source extensions.
|
|
46
47
|
*/
|
|
47
|
-
declare const SOURCE_FILE_REGEX: RegExp;
|
|
48
|
+
export declare const SOURCE_FILE_REGEX: RegExp;
|
|
48
49
|
/**
|
|
49
50
|
* Runs the usage-analysis Babel plugin on a source file, accumulating
|
|
50
51
|
* field-usage data into `pruneContext`.
|
|
@@ -57,14 +58,14 @@ declare const SOURCE_FILE_REGEX: RegExp;
|
|
|
57
58
|
* Throws if Babel cannot parse the file (caller should handle and flag
|
|
58
59
|
* `pruneContext.hasUnparsableSourceFiles`).
|
|
59
60
|
*/
|
|
60
|
-
declare const analyzeFieldUsageInFile: (sourceFilePath: string, code: string, pruneContext: PruneContext, compatCallers?: CompatCallerConfig[]) => Promise<void>;
|
|
61
|
+
export declare const analyzeFieldUsageInFile: (sourceFilePath: string, code: string, pruneContext: PruneContext, compatCallers?: CompatCallerConfig[]) => Promise<void>;
|
|
61
62
|
/**
|
|
62
63
|
* Applies field-renaming to a single JS/TS code string (not an SFC).
|
|
63
64
|
*
|
|
64
65
|
* Returns the renamed code string, or `null` if nothing changed or if
|
|
65
66
|
* Babel failed to parse the input (caller should fall back to original code).
|
|
66
67
|
*/
|
|
67
|
-
declare const renameFieldsInCode: (code: string, sourceFilePath: string, pruneContext: PruneContext) => Promise<string | null>;
|
|
68
|
+
export declare const renameFieldsInCode: (code: string, sourceFilePath: string, pruneContext: PruneContext) => Promise<string | null>;
|
|
68
69
|
/**
|
|
69
70
|
* Applies field-renaming to a source file, correctly handling both plain
|
|
70
71
|
* JS/TS files and SFC files (Vue / Svelte) by operating on each script block
|
|
@@ -72,7 +73,7 @@ declare const renameFieldsInCode: (code: string, sourceFilePath: string, pruneCo
|
|
|
72
73
|
*
|
|
73
74
|
* Returns the renamed code string, or `null` if nothing changed.
|
|
74
75
|
*/
|
|
75
|
-
declare const renameFieldsInSourceFile: (sourceFilePath: string, code: string, pruneContext: PruneContext) => Promise<string | null>;
|
|
76
|
+
export declare const renameFieldsInSourceFile: (sourceFilePath: string, code: string, pruneContext: PruneContext) => Promise<string | null>;
|
|
76
77
|
/**
|
|
77
78
|
* Runs the intlayer optimize Babel plugin on a source file, transforming
|
|
78
79
|
* `useIntlayer('key')` / `getIntlayer('key')` calls into `useDictionary(_hash)`
|
|
@@ -81,10 +82,9 @@ declare const renameFieldsInSourceFile: (sourceFilePath: string, code: string, p
|
|
|
81
82
|
* Returns `{ code, map }` on success, or `null` if the transformation produced
|
|
82
83
|
* no output.
|
|
83
84
|
*/
|
|
84
|
-
declare const optimizeSourceFile: (code: string, sourceFilePath: string, options: OptimizePluginOptions) => Promise<{
|
|
85
|
+
export declare const optimizeSourceFile: (code: string, sourceFilePath: string, options: OptimizePluginOptions) => Promise<{
|
|
85
86
|
code: string;
|
|
86
87
|
map: string | object | null | undefined;
|
|
87
88
|
} | null>;
|
|
88
89
|
//#endregion
|
|
89
|
-
export { BABEL_PARSER_OPTIONS, INTLAYER_USAGE_REGEX, SOURCE_FILE_REGEX, analyzeFieldUsageInFile, buildUsageCheckRegex, getUsageCheckRegex, optimizeSourceFile, renameFieldsInCode, renameFieldsInSourceFile };
|
|
90
90
|
//# sourceMappingURL=transformers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformers.d.ts","names":[],"sources":["../../src/transformers.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"transformers.d.ts","names":[],"sources":["../../src/transformers.ts"],"mappings":";;;;;;;;;qBA0Ba,sBAAsB;;;;;;;;;;;;;;;;;;;;qBAsCtB,uBAAoB,gCAAkC;;;;;;qBAWtD,sBAAoB;;;;;;qBAgBpB,qBAAkB,yBACJ,yBACxB;;;;;;qBAoBU,mBAAiB;;;;;;;;;;;;;qBAqCjB,0BAAuB,wBACZ,cACV,cACE,cAAY,gBACV,yBACf;;;;;;;qBAyBU,qBAAkB,cACjB,wBACU,cACR,iBACb;;;;;;;;qBAqBU,2BAAwB,wBACb,cACV,cACE,iBACb;;;;;;;;;qBA8CU,qBAAkB,cACjB,wBACU,SACb,0BACR;EACD;EACA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/babel",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.5.0",
|
|
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": [
|
|
@@ -89,31 +89,31 @@
|
|
|
89
89
|
"@babel/plugin-syntax-jsx": "8.0.1",
|
|
90
90
|
"@babel/traverse": "8.0.4",
|
|
91
91
|
"@babel/types": "8.0.4",
|
|
92
|
-
"@intlayer/config": "9.
|
|
93
|
-
"@intlayer/core": "9.
|
|
94
|
-
"@intlayer/dictionaries-entry": "9.
|
|
95
|
-
"@intlayer/engine": "9.
|
|
96
|
-
"@intlayer/types": "9.
|
|
97
|
-
"@intlayer/unmerged-dictionaries-entry": "9.
|
|
92
|
+
"@intlayer/config": "9.5.0",
|
|
93
|
+
"@intlayer/core": "9.5.0",
|
|
94
|
+
"@intlayer/dictionaries-entry": "9.5.0",
|
|
95
|
+
"@intlayer/engine": "9.5.0",
|
|
96
|
+
"@intlayer/types": "9.5.0",
|
|
97
|
+
"@intlayer/unmerged-dictionaries-entry": "9.5.0"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
100
|
"@babel/plugin-syntax-jsx": "8.0.1",
|
|
101
101
|
"@types/babel__core": "7.20.5",
|
|
102
102
|
"@types/babel__generator": "7.27.0",
|
|
103
103
|
"@types/babel__traverse": "7.28.0",
|
|
104
|
-
"@types/node": "26.
|
|
104
|
+
"@types/node": "26.5.0",
|
|
105
105
|
"@utils/ts-config": "1.0.4",
|
|
106
106
|
"@utils/ts-config-types": "1.0.4",
|
|
107
107
|
"@utils/tsdown-config": "1.0.4",
|
|
108
108
|
"@vitejs/plugin-react": "6.1.1",
|
|
109
109
|
"rimraf": "6.1.3",
|
|
110
|
-
"tsdown": "0.
|
|
110
|
+
"tsdown": "0.23.0",
|
|
111
111
|
"typescript": "7.0.2",
|
|
112
|
-
"vitest": "
|
|
112
|
+
"vitest": "5.0.0"
|
|
113
113
|
},
|
|
114
114
|
"peerDependencies": {
|
|
115
|
-
"@intlayer/svelte-compiler": "9.
|
|
116
|
-
"@intlayer/vue-compiler": "9.
|
|
115
|
+
"@intlayer/svelte-compiler": "9.5.0",
|
|
116
|
+
"@intlayer/vue-compiler": "9.5.0"
|
|
117
117
|
},
|
|
118
118
|
"peerDependenciesMeta": {
|
|
119
119
|
"@intlayer/svelte-compiler": {
|