@intlayer/babel 8.6.10 → 8.7.0-canary.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/dist/cjs/babel-plugin-intlayer-extract.cjs +1 -1
- package/dist/cjs/babel-plugin-intlayer-field-rename.cjs +172 -0
- package/dist/cjs/babel-plugin-intlayer-field-rename.cjs.map +1 -0
- package/dist/cjs/babel-plugin-intlayer-optimize.cjs +1 -1
- package/dist/cjs/babel-plugin-intlayer-usage-analyzer.cjs +171 -0
- package/dist/cjs/babel-plugin-intlayer-usage-analyzer.cjs.map +1 -0
- package/dist/cjs/extractContent/contentWriter.cjs +1 -1
- package/dist/cjs/extractContent/extractContent.cjs +1 -1
- package/dist/cjs/extractContent/utils/extractDictionaryInfo.cjs +1 -1
- package/dist/cjs/extractContent/utils/resolveDictionaryKey.cjs +1 -1
- package/dist/cjs/extractScriptBlocks.cjs +80 -0
- package/dist/cjs/extractScriptBlocks.cjs.map +1 -0
- package/dist/cjs/getOptimizePluginOptions.cjs +1 -1
- package/dist/cjs/index.cjs +19 -0
- package/dist/cjs/transformers.cjs +150 -0
- package/dist/cjs/transformers.cjs.map +1 -0
- package/dist/esm/babel-plugin-intlayer-extract.mjs +1 -1
- package/dist/esm/babel-plugin-intlayer-field-rename.mjs +169 -0
- package/dist/esm/babel-plugin-intlayer-field-rename.mjs.map +1 -0
- package/dist/esm/babel-plugin-intlayer-optimize.mjs +1 -1
- package/dist/esm/babel-plugin-intlayer-usage-analyzer.mjs +167 -0
- package/dist/esm/babel-plugin-intlayer-usage-analyzer.mjs.map +1 -0
- package/dist/esm/extractContent/contentWriter.mjs +1 -1
- package/dist/esm/extractContent/extractContent.mjs +1 -1
- package/dist/esm/extractContent/utils/extractDictionaryInfo.mjs +1 -1
- package/dist/esm/extractContent/utils/resolveDictionaryKey.mjs +1 -1
- package/dist/esm/extractScriptBlocks.mjs +77 -0
- package/dist/esm/extractScriptBlocks.mjs.map +1 -0
- package/dist/esm/getOptimizePluginOptions.mjs +1 -1
- package/dist/esm/index.mjs +5 -1
- package/dist/esm/transformers.mjs +142 -0
- package/dist/esm/transformers.mjs.map +1 -0
- package/dist/types/babel-plugin-intlayer-field-rename.d.ts +57 -0
- package/dist/types/babel-plugin-intlayer-field-rename.d.ts.map +1 -0
- package/dist/types/babel-plugin-intlayer-usage-analyzer.d.ts +119 -0
- package/dist/types/babel-plugin-intlayer-usage-analyzer.d.ts.map +1 -0
- package/dist/types/extractScriptBlocks.d.ts +45 -0
- package/dist/types/extractScriptBlocks.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -1
- package/dist/types/transformers.d.ts +64 -0
- package/dist/types/transformers.d.ts.map +1 -0
- package/package.json +10 -10
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
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 { DictionaryFieldUsage, INTLAYER_CALLER_NAMES, IntlayerCallerName, NestedRenameEntry, NestedRenameMap, PruneContext, createPruneContext, makeUsageAnalyzerBabelPlugin } from "./babel-plugin-intlayer-usage-analyzer.js";
|
|
4
|
+
import { buildNestedRenameMapFromContent, generateShortFieldName, makeFieldRenameBabelPlugin } from "./babel-plugin-intlayer-field-rename.js";
|
|
3
5
|
import { OptimizePluginOptions, intlayerOptimizeBabelPlugin } from "./babel-plugin-intlayer-optimize.js";
|
|
4
6
|
import { mergeWithExistingMultilingualDictionary, mergeWithExistingPerLocaleDictionary, writeContentHelper } from "./extractContent/contentWriter.js";
|
|
5
7
|
import { detectPackageName } from "./extractContent/utils/detectPackageName.js";
|
|
@@ -8,6 +10,8 @@ import { extractDictionaryKey, extractDictionaryKeyFromPath } from "./extractCon
|
|
|
8
10
|
import { generateKey } from "./extractContent/utils/generateKey.js";
|
|
9
11
|
import { getComponentName } from "./extractContent/utils/getComponentName.js";
|
|
10
12
|
import { ExtractIntlayerOptions, extractContent, extractContentSync } from "./extractContent/extractContent.js";
|
|
13
|
+
import { ScriptBlock, extractScriptBlocks, injectScriptBlocks } from "./extractScriptBlocks.js";
|
|
11
14
|
import { CompilerMode, getExtractPluginOptions } from "./getExtractPluginOptions.js";
|
|
12
15
|
import { getOptimizePluginOptions } from "./getOptimizePluginOptions.js";
|
|
13
|
-
|
|
16
|
+
import { BABEL_PARSER_OPTIONS, INTLAYER_USAGE_REGEX, SOURCE_FILE_REGEX, analyzeFieldUsageInFile, optimizeSourceFile, renameFieldsInCode, renameFieldsInSourceFile } from "./transformers.js";
|
|
17
|
+
export { ATTRIBUTES_TO_EXTRACT, BABEL_PARSER_OPTIONS, type CompilerMode, DictionaryFieldUsage, ExtractDictionaryInfoOptions, ExtractIntlayerOptions, ExtractPluginOptions, ExtractResult, INTLAYER_CALLER_NAMES, INTLAYER_USAGE_REGEX, IntlayerCallerName, NestedRenameEntry, NestedRenameMap, OptimizePluginOptions, PackageName, PruneContext, ResolveContentFilePaths, SERVER_CAPABLE_PACKAGES, SOURCE_FILE_REGEX, ScriptBlock, analyzeFieldUsageInFile, buildNestedRenameMapFromContent, createPruneContext, detectPackageName, extractContent, extractContentSync, extractDictionaryInfo, extractDictionaryKey, extractDictionaryKeyFromPath, extractScriptBlocks, generateKey, generateShortFieldName, getComponentName, getExtractPluginOptions, getOptimizePluginOptions, getOutput, injectScriptBlocks, intlayerExtractBabelPlugin, intlayerOptimizeBabelPlugin, makeFieldRenameBabelPlugin, makeUsageAnalyzerBabelPlugin, mergeWithExistingMultilingualDictionary, mergeWithExistingPerLocaleDictionary, optimizeSourceFile, packageList, renameFieldsInCode, renameFieldsInSourceFile, resolveContentFilePaths, writeContentHelper };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { PruneContext } from "./babel-plugin-intlayer-usage-analyzer.js";
|
|
2
|
+
import { OptimizePluginOptions } from "./babel-plugin-intlayer-optimize.js";
|
|
3
|
+
import { TransformOptions } from "@babel/core";
|
|
4
|
+
|
|
5
|
+
//#region src/transformers.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Babel parser options covering the superset of syntaxes used across all
|
|
8
|
+
* supported frameworks (React / Vue / Svelte / Angular / …).
|
|
9
|
+
*/
|
|
10
|
+
declare const BABEL_PARSER_OPTIONS: NonNullable<TransformOptions['parserOpts']>;
|
|
11
|
+
/**
|
|
12
|
+
* Fast pre-check: matches files that could contain intlayer calls.
|
|
13
|
+
* Avoids running Babel on files with no relevant identifiers.
|
|
14
|
+
*/
|
|
15
|
+
declare const INTLAYER_USAGE_REGEX: RegExp;
|
|
16
|
+
/**
|
|
17
|
+
* Matches source files that are valid targets for usage analysis and Babel
|
|
18
|
+
* transformation. Excludes sourcemap files, declaration files, and other
|
|
19
|
+
* non-source extensions.
|
|
20
|
+
*/
|
|
21
|
+
declare const SOURCE_FILE_REGEX: RegExp;
|
|
22
|
+
/**
|
|
23
|
+
* Runs the usage-analysis Babel plugin on a source file, accumulating
|
|
24
|
+
* field-usage data into `pruneContext`.
|
|
25
|
+
*
|
|
26
|
+
* For Vue / Svelte SFC files, script blocks are extracted before analysis so
|
|
27
|
+
* Babel does not attempt to parse the full SFC syntax (templates, styles, …).
|
|
28
|
+
* For plain JS/TS files, the whole file content is analysed directly.
|
|
29
|
+
*
|
|
30
|
+
* This is analysis-only: the transformed code output is discarded.
|
|
31
|
+
* Throws if Babel cannot parse the file (caller should handle and flag
|
|
32
|
+
* `pruneContext.hasUnparsableSourceFiles`).
|
|
33
|
+
*/
|
|
34
|
+
declare const analyzeFieldUsageInFile: (sourceFilePath: string, code: string, pruneContext: PruneContext) => Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Applies field-renaming to a single JS/TS code string (not an SFC).
|
|
37
|
+
*
|
|
38
|
+
* Returns the renamed code string, or `null` if nothing changed or if
|
|
39
|
+
* Babel failed to parse the input (caller should fall back to original code).
|
|
40
|
+
*/
|
|
41
|
+
declare const renameFieldsInCode: (code: string, sourceFilePath: string, pruneContext: PruneContext) => Promise<string | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Applies field-renaming to a source file, correctly handling both plain
|
|
44
|
+
* JS/TS files and SFC files (Vue / Svelte) by operating on each script block
|
|
45
|
+
* individually and injecting the results back into the original source.
|
|
46
|
+
*
|
|
47
|
+
* Returns the renamed code string, or `null` if nothing changed.
|
|
48
|
+
*/
|
|
49
|
+
declare const renameFieldsInSourceFile: (sourceFilePath: string, code: string, pruneContext: PruneContext) => Promise<string | null>;
|
|
50
|
+
/**
|
|
51
|
+
* Runs the intlayer optimize Babel plugin on a source file, transforming
|
|
52
|
+
* `useIntlayer('key')` / `getIntlayer('key')` calls into `useDictionary(_hash)`
|
|
53
|
+
* / `getDictionary(_hash)` and injecting the corresponding dictionary imports.
|
|
54
|
+
*
|
|
55
|
+
* Returns `{ code, map }` on success, or `null` if the transformation produced
|
|
56
|
+
* no output.
|
|
57
|
+
*/
|
|
58
|
+
declare const optimizeSourceFile: (code: string, sourceFilePath: string, options: OptimizePluginOptions) => Promise<{
|
|
59
|
+
code: string;
|
|
60
|
+
map: string | object | null | undefined;
|
|
61
|
+
} | null>;
|
|
62
|
+
//#endregion
|
|
63
|
+
export { BABEL_PARSER_OPTIONS, INTLAYER_USAGE_REGEX, SOURCE_FILE_REGEX, analyzeFieldUsageInFile, optimizeSourceFile, renameFieldsInCode, renameFieldsInSourceFile };
|
|
64
|
+
//# sourceMappingURL=transformers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformers.d.ts","names":[],"sources":["../../src/transformers.ts"],"mappings":";;;;;;;AAkBA;;cAAa,oBAAA,EAAsB,WAAA,CAAY,gBAAA;;;AAwB/C;;cAAa,oBAAA,EAAoB,MAAA;;;AAOjC;;;cAAa,iBAAA,EAAiB,MAAA;;AAoC9B;;;;;;;;;;;cAAa,uBAAA,GACX,cAAA,UACA,IAAA,UACA,YAAA,EAAc,YAAA,KACb,OAAA;;;;;;;cAmBU,kBAAA,GACX,IAAA,UACA,cAAA,UACA,YAAA,EAAc,YAAA,KACb,OAAA;;;;AAqBH;;;;cAAa,wBAAA,GACX,cAAA,UACA,IAAA,UACA,YAAA,EAAc,YAAA,KACb,OAAA;;;;;;;AA8CH;;cAAa,kBAAA,GACX,IAAA,UACA,cAAA,UACA,OAAA,EAAS,qBAAA,KACR,OAAA;EACD,IAAA;EACA,GAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/babel",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.7.0-canary.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": [
|
|
@@ -81,12 +81,12 @@
|
|
|
81
81
|
"@babel/plugin-syntax-jsx": "7.28.6",
|
|
82
82
|
"@babel/traverse": "7.29.0",
|
|
83
83
|
"@babel/types": "7.29.0",
|
|
84
|
-
"@intlayer/chokidar": "8.
|
|
85
|
-
"@intlayer/config": "8.
|
|
86
|
-
"@intlayer/core": "8.
|
|
87
|
-
"@intlayer/dictionaries-entry": "8.
|
|
88
|
-
"@intlayer/types": "8.
|
|
89
|
-
"@intlayer/unmerged-dictionaries-entry": "8.
|
|
84
|
+
"@intlayer/chokidar": "8.7.0-canary.0",
|
|
85
|
+
"@intlayer/config": "8.7.0-canary.0",
|
|
86
|
+
"@intlayer/core": "8.7.0-canary.0",
|
|
87
|
+
"@intlayer/dictionaries-entry": "8.7.0-canary.0",
|
|
88
|
+
"@intlayer/types": "8.7.0-canary.0",
|
|
89
|
+
"@intlayer/unmerged-dictionaries-entry": "8.7.0-canary.0",
|
|
90
90
|
"@types/babel__core": "7.20.5",
|
|
91
91
|
"@types/babel__generator": "7.27.0",
|
|
92
92
|
"@types/babel__traverse": "7.28.0"
|
|
@@ -101,11 +101,11 @@
|
|
|
101
101
|
"rimraf": "6.1.3",
|
|
102
102
|
"tsdown": "0.21.7",
|
|
103
103
|
"typescript": "6.0.2",
|
|
104
|
-
"vitest": "4.1.
|
|
104
|
+
"vitest": "4.1.3"
|
|
105
105
|
},
|
|
106
106
|
"peerDependencies": {
|
|
107
|
-
"@intlayer/svelte-compiler": "8.
|
|
108
|
-
"@intlayer/vue-compiler": "8.
|
|
107
|
+
"@intlayer/svelte-compiler": "8.7.0-canary.0",
|
|
108
|
+
"@intlayer/vue-compiler": "8.7.0-canary.0"
|
|
109
109
|
},
|
|
110
110
|
"peerDependenciesMeta": {
|
|
111
111
|
"@intlayer/svelte-compiler": {
|