|
1 | | -import type { PluginObj, Visitor, PluginPass } from "@babel/core" |
| 1 | +import type { PluginObj, PluginPass, Visitor } from "@babel/core" |
2 | 2 | import type * as babelTypes from "@babel/types" |
3 | | -import { Program, Identifier } from "@babel/types" |
| 3 | +import { Identifier, Program } from "@babel/types" |
4 | 4 | import { MacroJSX } from "./macroJsx" |
5 | 5 | import type { NodePath } from "@babel/traverse" |
6 | 6 | import { MacroJs } from "./macroJs" |
7 | 7 | import { JsMacroName } from "./constants" |
8 | 8 | import { |
9 | | - type LinguiConfigNormalized, |
10 | 9 | getConfig as loadConfig, |
11 | 10 | LinguiConfig, |
| 11 | + type LinguiConfigNormalized, |
12 | 12 | } from "@lingui/conf" |
| 13 | +import { ResolvedDescriptorFields } from "./messageDescriptorUtils" |
13 | 14 |
|
14 | 15 | let config: LinguiConfigNormalized |
15 | 16 |
|
16 | | -/** |
17 | | - * Controls which descriptor fields are preserved in the transformed code. |
18 | | - * |
19 | | - * - `"auto"` (default): In production (`NODE_ENV === "production"`), keeps only the `id`. |
20 | | - * Otherwise, behaves like `"all"`. |
21 | | - * - `"all"`: Keeps every field: `id`, `message`, `context`, and `comment`. |
22 | | - * Used by Lingui CLI during extraction. |
23 | | - * - `"id-only"`: Strips everything except the `id`. Most optimized for production. |
24 | | - * - `"message"`: Keeps `id`, `message`, and `context` (but not `comment`). |
25 | | - * Use when you need runtime access to message and context. |
26 | | - */ |
27 | | -export type DescriptorFields = "auto" | "all" | "id-only" | "message" |
28 | | - |
29 | | -/** |
30 | | - * The resolved mode after evaluating `"auto"` against the current environment. |
31 | | - */ |
32 | | -export type ResolvedDescriptorFields = "all" | "id-only" | "message" |
33 | | - |
34 | 17 | export type LinguiPluginOpts = { |
35 | 18 | /** |
36 | 19 | * Controls which descriptor fields are preserved in the transformed code. |
37 | 20 | * |
38 | | - * - `"auto"` (default): In production, keeps only the `id`. Otherwise, keeps all fields. |
39 | | - * - `"all"`: Keeps `id`, `message`, `context`, and `comment`. Used by CLI during extraction. |
40 | | - * - `"id-only"`: Strips everything except `id`. Most optimized for production. |
| 21 | + * - `"auto"` (default): In production (`NODE_ENV === "production"`), keeps only the `id`. |
| 22 | + * Otherwise, behaves like `"all"`. |
| 23 | + * - `"all"`: Keeps every field: `id`, `message`, `context`, and `comment`. |
| 24 | + * Used by Lingui CLI during extraction. |
| 25 | + * - `"id-only"`: Strips everything except the `id`. Most optimized for production. |
41 | 26 | * - `"message"`: Keeps `id`, `message`, and `context` (but not `comment`). |
| 27 | + * Use when you need runtime access to message and context. |
42 | 28 | * |
43 | 29 | * @default "auto" |
44 | 30 | */ |
45 | | - descriptorFields?: DescriptorFields |
| 31 | + descriptorFields?: "auto" | "all" | "id-only" | "message" |
46 | 32 |
|
47 | 33 | /** |
48 | 34 | * Resolved and normalized Lingui Configuration |
|
0 commit comments