@intlayer/babel 9.5.10 → 9.5.12

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.
Files changed (44) hide show
  1. package/dist/cjs/analyzeContentUsage.cjs +54 -26
  2. package/dist/cjs/analyzeContentUsage.cjs.map +1 -1
  3. package/dist/cjs/babel-plugin-intlayer-extract.cjs +11 -1
  4. package/dist/cjs/babel-plugin-intlayer-extract.cjs.map +1 -1
  5. package/dist/cjs/babel-plugin-intlayer-field-rename.cjs +39 -18
  6. package/dist/cjs/babel-plugin-intlayer-field-rename.cjs.map +1 -1
  7. package/dist/cjs/babel-plugin-intlayer-optimize.cjs +11 -1
  8. package/dist/cjs/babel-plugin-intlayer-optimize.cjs.map +1 -1
  9. package/dist/cjs/babel-plugin-intlayer-purge.cjs +2 -0
  10. package/dist/cjs/babel-plugin-intlayer-purge.cjs.map +1 -1
  11. package/dist/cjs/getExtractPluginOptions.cjs.map +1 -1
  12. package/dist/cjs/staticAstReaders.cjs +96 -0
  13. package/dist/cjs/staticAstReaders.cjs.map +1 -1
  14. package/dist/cjs/transformers.cjs +36 -7
  15. package/dist/cjs/transformers.cjs.map +1 -1
  16. package/dist/esm/analyzeContentUsage.mjs +55 -27
  17. package/dist/esm/analyzeContentUsage.mjs.map +1 -1
  18. package/dist/esm/babel-plugin-intlayer-extract.mjs +11 -1
  19. package/dist/esm/babel-plugin-intlayer-extract.mjs.map +1 -1
  20. package/dist/esm/babel-plugin-intlayer-field-rename.mjs +40 -19
  21. package/dist/esm/babel-plugin-intlayer-field-rename.mjs.map +1 -1
  22. package/dist/esm/babel-plugin-intlayer-optimize.mjs +11 -1
  23. package/dist/esm/babel-plugin-intlayer-optimize.mjs.map +1 -1
  24. package/dist/esm/babel-plugin-intlayer-purge.mjs +2 -0
  25. package/dist/esm/babel-plugin-intlayer-purge.mjs.map +1 -1
  26. package/dist/esm/getExtractPluginOptions.mjs +1 -1
  27. package/dist/esm/getExtractPluginOptions.mjs.map +1 -1
  28. package/dist/esm/staticAstReaders.mjs +94 -1
  29. package/dist/esm/staticAstReaders.mjs.map +1 -1
  30. package/dist/esm/transformers.mjs +36 -7
  31. package/dist/esm/transformers.mjs.map +1 -1
  32. package/dist/types/analyzeContentUsage.d.ts +6 -1
  33. package/dist/types/analyzeContentUsage.d.ts.map +1 -1
  34. package/dist/types/babel-plugin-intlayer-extract.d.ts +8 -22
  35. package/dist/types/babel-plugin-intlayer-extract.d.ts.map +1 -1
  36. package/dist/types/babel-plugin-intlayer-field-rename.d.ts.map +1 -1
  37. package/dist/types/babel-plugin-intlayer-optimize.d.ts +8 -112
  38. package/dist/types/babel-plugin-intlayer-optimize.d.ts.map +1 -1
  39. package/dist/types/babel-plugin-intlayer-purge.d.ts.map +1 -1
  40. package/dist/types/staticAstReaders.d.ts +41 -0
  41. package/dist/types/staticAstReaders.d.ts.map +1 -1
  42. package/dist/types/transformers.d.ts +8 -1
  43. package/dist/types/transformers.d.ts.map +1 -1
  44. package/package.json +8 -8
@@ -1,6 +1,5 @@
1
1
  import { PackageName } from "./extractContent/utils/constants.js";
2
- import { PluginObject, PluginPass } from "@babel/core";
3
- import * as BabelTypes from "@babel/types";
2
+ import { PluginTarget } from "@babel/core";
4
3
  import { Locale } from "@intlayer/types/allLocales";
5
4
  import { IntlayerConfig } from "@intlayer/types/config";
6
5
  import { FilePathPattern } from "@intlayer/types/filePathPattern";
@@ -28,28 +27,15 @@ export type ExtractPluginOptions = {
28
27
  */
29
28
  output?: FilePathPattern;
30
29
  };
31
- type State = PluginPass & {
32
- opts: ExtractPluginOptions;
33
- };
34
30
  /**
35
- * Babel plugin that extracts translatable content from source files and
36
- * injects Intlayer hooks (`useIntlayer` / `getIntlayer`) automatically.
37
- *
38
- * Designed for use with Babel-based build tools such as Next.js and Webpack.
31
+ * Intlayer extract Babel plugin (see `extractBabelPlugin`), typed as Babel's
32
+ * `PluginTarget`.
39
33
  *
40
- * @example babel.config.js
41
- * ```js
42
- * const { intlayerExtractBabelPlugin, getExtractPluginOptions } = require('@intlayer/babel');
43
- * module.exports = {
44
- * presets: ['next/babel'],
45
- * plugins: [
46
- * [intlayerExtractBabelPlugin, getExtractPluginOptions()],
47
- * ],
48
- * };
49
- * ```
34
+ * Babel types tuple options as `object` (`[PluginTarget<object>, object]`), so
35
+ * a plugin whose handlers read typed `this.opts` is rejected in
36
+ * `plugins: [[plugin, options]]` under `strict`. The options passed in the
37
+ * tuple are the typed options read by the handlers.
50
38
  */
51
- export declare const intlayerExtractBabelPlugin: (_babel: {
52
- types: typeof BabelTypes;
53
- }) => PluginObject<State>;
39
+ export declare const intlayerExtractBabelPlugin: PluginTarget;
54
40
  //#endregion
55
41
  //# sourceMappingURL=babel-plugin-intlayer-extract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"babel-plugin-intlayer-extract.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-extract.ts"],"mappings":";;;;;;;YAeY;EACV;EACA;EACA,SAAS;EACT,QAAQ;;YAGE;EACV,cAAc;EACd;EACA;EAEA,iBAAiB;EACjB,eAAe;;;;;;EAMf,aAAa,QAAQ,yBAAyB;;;;EAI9C,SAAS;;KAGN,QAAQ;EAAe,MAAM;;;;;;;;;;;;;;;;;;;qBAmBrB,6BAA0B;EACrC,cAAc;MACZ,aAAa"}
1
+ {"version":3,"file":"babel-plugin-intlayer-extract.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-extract.ts"],"mappings":";;;;;;YAeY;EACV;EACA;EACA,SAAS;EACT,QAAQ;;YAGE;EACV,cAAc;EACd;EACA;EAEA,iBAAiB;EACjB,eAAe;;;;;;EAMf,aAAa,QAAQ,yBAAyB;;;;EAI9C,SAAS;;;;;;;;;;;qBA6HE,4BAA4B"}
@@ -1 +1 @@
1
- {"version":3,"file":"babel-plugin-intlayer-field-rename.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-field-rename.ts"],"mappings":";;;;;;;;;qBA2Ba,yBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA0CtB,kCAA+B,0BAEzC;;;;;;;;;;;;qBA2EU,6BAA0B,WAC1B,iBAAe,iCAEzB;;;;;;;YAqBS;;EAEV;;EAEA,UAAU;;;YAIA,2BAA2B,eAErC;;;;;;;;;;;;;;qBAgCW,0BAAuB,cACpB,iBACb,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;qBA4aL,8BAA2B,mBACnB,YAAU,aAChB,SAAS,WAAW,UAAQ,cAC3B;;;;;;;;;;qBAsIH,6BAA0B,cACtB,oBAAY,OAAA;EACD,cAAc;MAAe"}
1
+ {"version":3,"file":"babel-plugin-intlayer-field-rename.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-field-rename.ts"],"mappings":";;;;;;;;;qBA8Ba,yBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA0CtB,kCAA+B,0BAEzC;;;;;;;;;;;;qBA2EU,6BAA0B,WAC1B,iBAAe,iCAEzB;;;;;;;YAqBS;;EAEV;;EAEA,UAAU;;;YAIA,2BAA2B,eAErC;;;;;;;;;;;;;;qBAgCW,0BAAuB,cACpB,iBACb,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;qBA8dL,8BAA2B,mBACnB,YAAU,aAChB,SAAS,WAAW,UAAQ,cAC3B;;;;;;;;;;qBAyIH,6BAA0B,cACtB,oBAAY,OAAA;EACD,cAAc;MAAe"}
@@ -1,5 +1,4 @@
1
- import { PluginObject, PluginPass } from "@babel/core";
2
- import * as BabelTypes from "@babel/types";
1
+ import { PluginTarget } from "@babel/core";
3
2
  import { CallerDescriptor } from "@intlayer/config/callers";
4
3
  //#region src/babel-plugin-intlayer-optimize.d.ts
5
4
  /**
@@ -93,117 +92,14 @@ export type OptimizePluginOptions = {
93
92
  compatCallers?: CallerDescriptor[];
94
93
  };
95
94
  /**
96
- * Per-file plugin state.
95
+ * Intlayer optimize Babel plugin (see `optimizeBabelPlugin`), typed as Babel's
96
+ * `PluginTarget`.
97
97
  *
98
- * Only the two flags that have to survive from `pre` / `Program.enter` into
99
- * `Program.exit` live here — the caller maps and the import registry are built
100
- * and consumed inside `exit`, so they stay local to it.
98
+ * Babel types tuple options as `object` (`[PluginTarget<object>, object]`), so
99
+ * a plugin whose handlers read typed `this.opts` is rejected in
100
+ * `plugins: [[plugin, options]]` under `strict`. The options passed in the
101
+ * tuple are the typed options read by the handlers.
101
102
  */
102
- type State = PluginPass & {
103
- opts: OptimizePluginOptions;
104
- /** Whether the current file *is* a generated dictionaries entry file. */
105
- _isDictEntry?: boolean;
106
- /** Whether the current file is covered by the `filesList` allowlist. */
107
- _isIncluded?: boolean;
108
- };
109
- /**
110
- * Babel plugin that transforms Intlayer function calls and auto-imports dictionaries.
111
- *
112
- * This plugin transforms calls to `useIntlayer()`, `getIntlayer()` and
113
- * `getIntlayerAsync()` from various Intlayer packages into optimized dictionary
114
- * access patterns, automatically importing the required dictionary files based
115
- * on the configured import mode.
116
- *
117
- * ## Supported Input Patterns
118
- *
119
- * The plugin recognizes these function calls:
120
- *
121
- * ```ts
122
- * // useIntlayer
123
- * import { useIntlayer } from 'react-intlayer';
124
- * import { useIntlayer } from 'next-intlayer';
125
- *
126
- * // getIntlayer / getIntlayerAsync
127
- * import { getIntlayer, getIntlayerAsync } from 'intlayer';
128
- *
129
- * // Usage
130
- * const content = useIntlayer('app');
131
- * const content = getIntlayer('app');
132
- * const content = await getIntlayerAsync('app', locale);
133
- * ```
134
- *
135
- * `getIntlayerAsync` is the exception to the mode table below: it always
136
- * resolves to the per-locale loader (`getDictionaryAsync`), in every import
137
- * mode, since loading a single locale is what it exists for.
138
- *
139
- * **Output (any mode):**
140
- * ```ts
141
- * import _dicHash_dyn from '../../.intlayer/dynamic_dictionaries/app.mjs';
142
- * import { getDictionaryAsync as getIntlayerAsync } from 'intlayer';
143
- *
144
- * const content = await getIntlayerAsync(_dicHash_dyn, 'app', locale);
145
- * ```
146
- *
147
- * ## Transformation Modes
148
- *
149
- * ### Static Mode (default: `importMode = "static"`)
150
- *
151
- * Imports JSON dictionaries directly and replaces function calls with dictionary access:
152
- *
153
- * **Output:**
154
- * ```ts
155
- * import _dicHash from '../../.intlayer/dictionaries/app.json' with { type: 'json' };
156
- * import { useDictionary as useIntlayer } from 'react-intlayer';
157
- * import { getDictionary as getIntlayer } from 'intlayer';
158
- *
159
- * const content1 = useIntlayer(_dicHash);
160
- * const content2 = getIntlayer(_dicHash);
161
- * ```
162
- *
163
- * ### Dynamic Mode (`importMode = "dynamic"`)
164
- *
165
- * Uses dynamic dictionary loading with Suspense support:
166
- *
167
- * **Output:**
168
- * ```ts
169
- * import _dicHash from '../../.intlayer/dictionaries/app.json' with { type: 'json' };
170
- * import _dicHash_dyn from '../../.intlayer/dynamic_dictionaries/app.mjs';
171
- * import { useDictionaryDynamic as useIntlayer } from 'react-intlayer';
172
- * import { getDictionary as getIntlayer } from 'intlayer';
173
- *
174
- * const content1 = useIntlayer(_dicHash_dyn, 'app');
175
- * const content2 = getIntlayer(_dicHash);
176
- * ```
177
- *
178
- * ### Fetch Mode (`importMode = "fetch"`)
179
- *
180
- * Uses fetch-based dictionary loading for remote dictionaries:
181
- *
182
- * **Output if `dictionaryModeMap` includes the key with "fetch" value:**
183
- * ```ts
184
- * import _dicHash from '../../.intlayer/dictionaries/app.json' with { type: 'json' };
185
- * import _dicHash_fetch from '../../.intlayer/fetch_dictionaries/app.mjs';
186
- * import { useDictionaryDynamic as useIntlayer } from 'react-intlayer';
187
- * import { getDictionary as getIntlayer } from 'intlayer';
188
- *
189
- * const content1 = useIntlayer(_dicHash_fetch, "app");
190
- * const content2 = getIntlayer(_dicHash);
191
- * ```
192
- *
193
- * > If `dictionaryModeMap` does not include the key with "fetch" value, the plugin will fallback to the dynamic import mode.
194
- *
195
- * ```ts
196
- * import _dicHash from '../../.intlayer/dictionaries/app.json' with { type: 'json' };
197
- * import _dicHash_dyn from '../../.intlayer/dynamic_dictionaries/app.mjs';
198
- * import { useDictionaryDynamic as useIntlayer } from 'react-intlayer';
199
- * import { getDictionary as getIntlayer } from 'intlayer';
200
- *
201
- * const content1 = useIntlayer(_dicHash_dyn, 'app');
202
- * const content2 = getIntlayer(_dicHash);
203
- * ```
204
- */
205
- export declare const intlayerOptimizeBabelPlugin: (babel: {
206
- types: typeof BabelTypes;
207
- }) => PluginObject<State>;
103
+ export declare const intlayerOptimizeBabelPlugin: PluginTarget;
208
104
  //#endregion
209
105
  //# sourceMappingURL=babel-plugin-intlayer-optimize.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"babel-plugin-intlayer-optimize.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-optimize.ts"],"mappings":";;;;;;;YAmGY;;;;EAIV;;;;EAIA;;;;EAIA;;;;EAIA;;;;EAIA;;;;EAIA;;;;EAIA;;;;EAIA;;;;EAIA;;;;EAIA;;;;;;;;;;;;;;;EAeA;;;;EAIA;;;;EAIA,oBAAoB;;;;EAOpB;;;;EAIA;;;;;;;;;;;;;;EAcA,gBAAgB;;;;;;;;;KAUb,QAAQ;EACX,MAAM;;EAEN;;EAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAgTW,8BAA2B;EACtC,cAAc;MACZ,aAAa"}
1
+ {"version":3,"file":"babel-plugin-intlayer-optimize.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-optimize.ts"],"mappings":";;;;;;YAmGY;;;;EAIV;;;;EAIA;;;;EAIA;;;;EAIA;;;;EAIA;;;;EAIA;;;;EAIA;;;;EAIA;;;;EAIA;;;;EAIA;;;;;;;;;;;;;;;EAeA;;;;EAIA;;;;EAIA,oBAAoB;;;;EAOpB;;;;EAIA;;;;;;;;;;;;;;EAcA,gBAAgB;;;;;;;;;;;qBAyyBL,6BAA6B"}
@@ -1 +1 @@
1
- {"version":3,"file":"babel-plugin-intlayer-purge.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-purge.ts"],"mappings":";;;;;;;;;;;;;;YA2CY;;;;;;EAMV;;;;;EAMA;;;;;;EAOA;;;;;;EAOA;;;;;;EAOA;;;;;EAMA;;;;;EAMA;;;;;;EAOA;;;;;;;;EASA,6BAA6B,YAAY;;;;;;EAOzC,8BAA8B;;;;;;;;;;;;EAgB9B,gBAAgB;;;;;;;EAQhB,YAAY,KAAK;;;;;;;;;;qBAwBN,wBAAqB,oBAAsB;;;;;;;;;;;;;;;;;;qBA0rB3C,2BAAwB,SAC1B,uBACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAmIU,2BAAwB;EACnC,cAAc;MACZ"}
1
+ {"version":3,"file":"babel-plugin-intlayer-purge.d.ts","names":[],"sources":["../../src/babel-plugin-intlayer-purge.ts"],"mappings":";;;;;;;;;;;;;;YA2CY;;;;;;EAMV;;;;;EAMA;;;;;;EAOA;;;;;;EAOA;;;;;;EAOA;;;;;EAMA;;;;;EAMA;;;;;;EAOA;;;;;;;;EASA,6BAA6B,YAAY;;;;;;EAOzC,8BAA8B;;;;;;;;;;;;EAgB9B,gBAAgB;;;;;;;EAQhB,YAAY,KAAK;;;;;;;;;;qBAwBN,wBAAqB,oBAAsB;;;;;;;;;;;;;;;;;;qBA4rB3C,2BAAwB,SAC1B,uBACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAmIU,2BAAwB;EACnC,cAAc;MACZ"}
@@ -80,5 +80,46 @@ export declare const splitNamespace: (namespace: string) => {
80
80
  * is.
81
81
  */
82
82
  export declare const unwrapAwait: (babelTypes: typeof BabelTypes, path: NodePath<BabelTypes.Node>) => NodePath<BabelTypes.Node>;
83
+ /**
84
+ * Climbs past every enclosing value-preserving wrapper (see
85
+ * {@link isTransparentWrapper}), so `(content.field as any).sub` is walked the
86
+ * same way as `content.field.sub`.
87
+ */
88
+ export declare const skipTransparentWrappers: (babelTypes: typeof BabelTypes, path: NodePath<BabelTypes.Node>) => NodePath<BabelTypes.Node>;
89
+ /** How the value of a content-producing expression is consumed. */
90
+ export type ContentRootResolution =
91
+ /** Consumed inline — inspect `rootPath.parent` (member access, argument…). */
92
+ {
93
+ kind: 'expression';
94
+ rootPath: NodePath<BabelTypes.Node>;
95
+ } |
96
+ /** Stored into a local binding (`const x = …` / `const { a } = …`). */
97
+ {
98
+ kind: 'binding';
99
+ rootPath: NodePath<BabelTypes.Node>;
100
+ bindingTarget: BabelTypes.Identifier | BabelTypes.ObjectPattern;
101
+ } |
102
+ /** Skipped by an array-pattern hole (`const [, b] = await Promise.all(…)`). */
103
+ {
104
+ kind: 'discarded';
105
+ };
106
+ /**
107
+ * Resolves where the content returned by `path` (a `useIntlayer('key')` call
108
+ * or any expression evaluating to the same content) ends up.
109
+ *
110
+ * Looks through TypeScript casts, parentheses and `await`, and through
111
+ * `const [a, { b }] = await Promise.all([getIntlayerAsync('x'), …])`, where the
112
+ * array-pattern element at the call's index is the binding target.
113
+ *
114
+ * Both the usage analyser and the field renamer resolve roots through this
115
+ * function, so every shape the analyser tracks is one the renamer rewrites.
116
+ */
117
+ export declare const resolveContentRoot: (babelTypes: typeof BabelTypes, path: NodePath<BabelTypes.Node>) => ContentRootResolution;
118
+ /**
119
+ * Returns `true` when the value at `path` is only tested, never read: `!x`,
120
+ * `typeof x`, `if (x)`, `x ? … : …`, `x && …`, `x === y`. Such uses expose no
121
+ * key names, so they neither block pruning nor make a field opaque.
122
+ */
123
+ export declare const isTestOnlyUse: (babelTypes: typeof BabelTypes, path: NodePath<BabelTypes.Node>) => boolean;
83
124
  //#endregion
84
125
  //# sourceMappingURL=staticAstReaders.d.ts.map
@@ -1 +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
+ {"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;;;;;;qBA6BV,0BAAuB,mBACf,YAAU,MACvB,SAAS,WAAW,UACzB,SAAS,WAAW;;YAwCX;;;EAEN;EAAoB,UAAU,SAAS,WAAW;;;;EAGlD;EACA,UAAU,SAAS,WAAW;EAC9B,eAAe,WAAW,aAAa,WAAW;;;;EAGlD;;;;;;;;;;;;;qBAaO,qBAAkB,mBACV,YAAU,MACvB,SAAS,WAAW,UACzB;;;;;;qBAwEU,gBAAa,mBACL,YAAU,MACvB,SAAS,WAAW"}
@@ -79,10 +79,17 @@ export declare const renameFieldsInSourceFile: (sourceFilePath: string, code: st
79
79
  * `useIntlayer('key')` / `getIntlayer('key')` calls into `useDictionary(_hash)`
80
80
  * / `getDictionary(_hash)` and injecting the corresponding dictionary imports.
81
81
  *
82
+ * When `fieldRenamePruneContext` is given, dictionary field accesses are
83
+ * renamed in the same Babel pass (see {@link renameFieldsInSourceFile}): the
84
+ * rename plugin is listed first, so its `Program.exit` sees the dictionary
85
+ * keys before the optimize plugin's `Program.exit` erases them — saving a
86
+ * full parse and code generation per file. `code` must be plain or compiled
87
+ * JS, as in a bundler's post-transform hook.
88
+ *
82
89
  * Returns `{ code, map }` on success, or `null` if the transformation produced
83
90
  * no output.
84
91
  */
85
- export declare const optimizeSourceFile: (code: string, sourceFilePath: string, options: OptimizePluginOptions) => Promise<{
92
+ export declare const optimizeSourceFile: (code: string, sourceFilePath: string, options: OptimizePluginOptions, fieldRenamePruneContext?: PruneContext) => Promise<{
86
93
  code: string;
87
94
  map: string | object | null | undefined;
88
95
  } | null>;
@@ -1 +1 @@
1
- {"version":3,"file":"transformers.d.ts","names":[],"sources":["../../src/transformers.ts"],"mappings":";;;;;;;;;qBA0Ba,sBAAsB;;;;;;;;;;;;;;;;;;;;qBAiCtB,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"}
1
+ {"version":3,"file":"transformers.d.ts","names":[],"sources":["../../src/transformers.ts"],"mappings":";;;;;;;;;qBA0Ba,sBAAsB;;;;;;;;;;;;;;;;;;;;qBAiCtB,uBAAoB,gCAAkC;;;;;;qBAWtD,sBAAoB;;;;;;qBAgBpB,qBAAkB,yBACJ,yBACxB;;;;;;qBAoBU,mBAAiB;;;;;;;;;;;;;qBA8DjB,0BAAuB,wBACZ,cACV,cACE,cAAY,gBACV,yBACf;;;;;;;qBAyBU,qBAAkB,cACjB,wBACU,cACR,iBACb;;;;;;;;qBAqBU,2BAAwB,wBACb,cACV,cACE,iBACb;;;;;;;;;;;;;;;;qBAiDU,qBAAkB,cACjB,wBACU,SACb,uBAAqB,0BACJ,iBACzB;EACD;EACA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/babel",
3
- "version": "9.5.10",
3
+ "version": "9.5.12",
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": [
@@ -90,11 +90,11 @@
90
90
  "@babel/plugin-syntax-jsx": "8.0.1",
91
91
  "@babel/traverse": "8.0.5",
92
92
  "@babel/types": "8.0.5",
93
- "@intlayer/config": "9.5.10",
94
- "@intlayer/core": "9.5.10",
95
- "@intlayer/dictionaries-entry": "9.5.10",
96
- "@intlayer/engine": "9.5.10",
97
- "@intlayer/types": "9.5.10"
93
+ "@intlayer/config": "9.5.12",
94
+ "@intlayer/core": "9.5.12",
95
+ "@intlayer/dictionaries-entry": "9.5.12",
96
+ "@intlayer/engine": "9.5.12",
97
+ "@intlayer/types": "9.5.12"
98
98
  },
99
99
  "devDependencies": {
100
100
  "@babel/plugin-syntax-jsx": "8.0.1",
@@ -112,8 +112,8 @@
112
112
  "vitest": "5.0.2"
113
113
  },
114
114
  "peerDependencies": {
115
- "@intlayer/svelte-compiler": "9.5.10",
116
- "@intlayer/vue-compiler": "9.5.10"
115
+ "@intlayer/svelte-compiler": "9.5.12",
116
+ "@intlayer/vue-compiler": "9.5.12"
117
117
  },
118
118
  "peerDependenciesMeta": {
119
119
  "@intlayer/svelte-compiler": {