@lingui/conf 3.17.2 → 4.0.0-next.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/build/index.js CHANGED
@@ -1,467 +1,23 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.catalogMigration = catalogMigration;
7
- exports.defaultConfig = exports.configValidation = void 0;
8
- exports.fallbackLanguageMigration = fallbackLanguageMigration;
9
- exports.getConfig = getConfig;
10
- exports.makeConfig = makeConfig;
11
- exports.replaceRootDir = replaceRootDir;
12
- var _path = _interopRequireDefault(require("path"));
13
- var _fs = _interopRequireDefault(require("fs"));
14
- var _chalk = _interopRequireDefault(require("chalk"));
15
- var _cosmiconfig = require("cosmiconfig");
16
- var _jestValidate = require("jest-validate");
17
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
- // Enforce posix path delimiters internally
19
- const pathJoinPosix = (...values) => _path.default
20
- // normalize double slashes
21
- .join(...values)
22
- // convert platform specific path.sep to posix
23
- .split(_path.default.sep).join("/");
24
- const defaultConfig = {
25
- catalogs: [{
26
- path: pathJoinPosix("<rootDir>", "locale", "{locale}", "messages"),
27
- include: ["<rootDir>"],
28
- exclude: ["*/node_modules/*"]
29
- }],
30
- catalogsMergePath: "",
31
- compileNamespace: "cjs",
32
- compilerBabelOptions: {
33
- minified: true,
34
- jsescOption: {
35
- minimal: true
36
- }
37
- },
38
- extractBabelOptions: {
39
- plugins: [],
40
- presets: []
41
- },
42
- fallbackLocales: {},
43
- format: "po",
44
- formatOptions: {
45
- origins: true,
46
- lineNumbers: true
47
- },
48
- locales: [],
49
- orderBy: "messageId",
50
- pseudoLocale: "",
51
- rootDir: ".",
52
- runtimeConfigModule: ["@lingui/core", "i18n"],
53
- sourceLocale: "",
54
- service: {
55
- name: "",
56
- apiKey: ""
57
- }
58
- };
59
- exports.defaultConfig = defaultConfig;
60
- function configExists(path) {
61
- return path && _fs.default.existsSync(path);
62
- }
63
- function TypeScriptLoader() {
64
- let loaderInstance;
65
- return (filepath, content) => {
66
- if (!loaderInstance) {
67
- const {
68
- TypeScriptLoader
69
- } = require("cosmiconfig-typescript-loader");
70
- loaderInstance = TypeScriptLoader();
71
- }
72
- return loaderInstance(filepath, content);
73
- };
74
- }
75
- function getConfig({
76
- cwd,
77
- configPath,
78
- skipValidation = false
79
- } = {}) {
80
- const defaultRootDir = cwd || process.cwd();
81
- const moduleName = "lingui";
82
- const configExplorer = (0, _cosmiconfig.cosmiconfigSync)(moduleName, {
83
- searchPlaces: ["package.json", `.${moduleName}rc`, `.${moduleName}rc.json`, `.${moduleName}rc.yaml`, `.${moduleName}rc.yml`, `.${moduleName}rc.ts`, `.${moduleName}rc.js`, `${moduleName}.config.ts`, `${moduleName}.config.js`],
84
- loaders: {
85
- ".ts": TypeScriptLoader()
86
- }
87
- });
88
- const result = configExists(configPath) ? configExplorer.load(configPath) : configExplorer.search(defaultRootDir);
89
- const userConfig = result ? result.config : {};
90
- return makeConfig({
91
- rootDir: result ? _path.default.dirname(result.filepath) : defaultRootDir,
92
- ...userConfig
93
- }, {
94
- skipValidation
95
- });
96
- }
97
- function makeConfig(userConfig, opts = {}) {
98
- const config = {
99
- ...defaultConfig,
100
- ...userConfig
101
- };
102
- if (!opts.skipValidation) {
103
- (0, _jestValidate.validate)(config, configValidation);
104
- return pipe(
105
- // List config migrations from oldest to newest
106
- fallbackLanguageMigration, catalogMigration,
107
- // Custom validation
108
- validateLocales,
109
- // `replaceRootDir` should always be the last
110
- config => replaceRootDir(config, config.rootDir))(config);
111
- } else {
112
- return replaceRootDir(config, config.rootDir);
113
- }
114
- }
115
- const exampleConfig = {
116
- ...defaultConfig,
117
- extractors: (0, _jestValidate.multipleValidOptions)([], ["babel"], [{
118
- match: fileName => false,
119
- extract: (filename, targetDir, options) => {}
120
- }]),
121
- runtimeConfigModule: (0, _jestValidate.multipleValidOptions)({
122
- i18n: ["@lingui/core", "i18n"],
123
- Trans: ["@lingui/react", "Trans"]
124
- }, ["@lingui/core", "i18n"]),
125
- fallbackLocales: (0, _jestValidate.multipleValidOptions)({}, {
126
- "en-US": "en"
127
- }, {
128
- "en-US": ["en"]
129
- }, {
130
- default: "en"
131
- }, false),
132
- extractBabelOptions: {
133
- extends: "babelconfig.js",
134
- rootMode: "rootmode",
135
- plugins: ["plugin"],
136
- presets: ["preset"],
137
- targets: (0, _jestValidate.multipleValidOptions)({}, "> 0.5%", ["> 0.5%", "not dead"], undefined),
138
- assumptions: (0, _jestValidate.multipleValidOptions)({}, undefined),
139
- browserslistConfigFile: (0, _jestValidate.multipleValidOptions)(true, undefined),
140
- browserslistEnv: (0, _jestValidate.multipleValidOptions)(".browserslistrc", undefined)
141
- }
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
142
15
  };
143
- const deprecatedConfig = {
144
- fallbackLocale: config => ` Option ${_chalk.default.bold("fallbackLocale")} was replaced by ${_chalk.default.bold("fallbackLocales")}
145
-
146
- You can find more information here: https://github.com/lingui/js-lingui/issues/791
147
-
148
- @lingui/cli now treats your current configuration as:
149
- {
150
- ${_chalk.default.bold('"fallbackLocales"')}: {
151
- default: ${_chalk.default.bold(`"${config.fallbackLocale}"`)}
152
- }
153
- }
154
-
155
- Please update your configuration.
156
- `,
157
- localeDir: config => ` Option ${_chalk.default.bold("localeDir")} is deprecated. Configure source paths using ${_chalk.default.bold("catalogs")} instead.
158
-
159
- @lingui/cli now treats your current configuration as:
160
-
161
- {
162
- ${_chalk.default.bold('"catalogs"')}: ${JSON.stringify(catalogMigration(config).catalogs, null, 2)}
163
- }
164
-
165
- Please update your configuration.
166
- `,
167
- srcPathDirs: config => ` Option ${_chalk.default.bold("srcPathDirs")} is deprecated. Configure source paths using ${_chalk.default.bold("catalogs")} instead.
168
-
169
- @lingui/cli now treats your current configuration as:
170
-
171
- {
172
- ${_chalk.default.bold('"catalogs"')}: ${JSON.stringify(catalogMigration(config).catalogs, null, 2)}
173
- }
174
-
175
- Please update your configuration.
176
- `,
177
- srcPathIgnorePatterns: config => ` Option ${_chalk.default.bold("srcPathIgnorePatterns")} is deprecated. Configure excluded source paths using ${_chalk.default.bold("catalogs")} instead.
178
-
179
- @lingui/cli now treats your current configuration as:
180
-
181
- {
182
- ${_chalk.default.bold('"catalogs"')}: ${JSON.stringify(catalogMigration(config).catalogs, null, 2)}
183
- }
184
-
185
- Please update your configuration.
186
- `
187
- };
188
- const configValidation = {
189
- exampleConfig,
190
- deprecatedConfig,
191
- comment: "Documentation: https://lingui.dev/ref/conf"
192
- };
193
- exports.configValidation = configValidation;
194
- function validateLocales(config) {
195
- if (!Array.isArray(config.locales) || !config.locales.length) {
196
- console.error("No locales defined!\n");
197
- console.error(`Add ${_chalk.default.yellow("'locales'")} to your configuration. See ${_chalk.default.underline("https://lingui.dev/ref/conf#locales")}`);
198
- }
199
- return config;
200
- }
201
- function replaceRootDir(config, rootDir) {
202
- return function replaceDeep(value, rootDir) {
203
- const replace = s => s.replace("<rootDir>", rootDir);
204
- if (value == null) {
205
- return value;
206
- } else if (typeof value === "string") {
207
- return replace(value);
208
- } else if (Array.isArray(value)) {
209
- return value.map(item => replaceDeep(item, rootDir));
210
- } else if (typeof value === "object") {
211
- Object.keys(value).forEach(key => {
212
- const newKey = replaceDeep(key, rootDir);
213
- value[newKey] = replaceDeep(value[key], rootDir);
214
- if (key !== newKey) delete value[key];
215
- });
216
- }
217
- return value;
218
- }(config, rootDir);
219
- }
220
-
221
- /**
222
- * Replace fallbackLocale, by the new standard fallbackLocales
223
- * - https://github.com/lingui/js-lingui/issues/791
224
- * - Remove anytime after 4.x
225
- */
226
-
227
- function fallbackLanguageMigration(config) {
228
- const {
229
- fallbackLocale,
230
- fallbackLocales
231
- } = config;
232
- if (fallbackLocales === false) return {
233
- ...config,
234
- fallbackLocales: null
235
- };
236
- const DEFAULT_FALLBACK = (fallbackLocales === null || fallbackLocales === void 0 ? void 0 : fallbackLocales.default) || fallbackLocale;
237
- if (DEFAULT_FALLBACK) {
238
- if (!config.fallbackLocales) config.fallbackLocales = {};
239
- config.fallbackLocales.default = DEFAULT_FALLBACK;
240
- }
241
- if (config.fallbackLocales !== false && !config.fallbackLocales.default) {
242
- config.locales.forEach(locale => {
243
- const fl = getCldrParentLocale(locale.toLowerCase());
244
- if (fl && !config.fallbackLocales[locale]) {
245
- config.fallbackLocales = {
246
- ...config.fallbackLocales,
247
- [locale]: fl
248
- };
249
- }
250
- });
251
- }
252
- return config;
253
- }
254
- function getCldrParentLocale(sourceLocale) {
255
- return {
256
- "en-ag": "en",
257
- "en-ai": "en",
258
- "en-au": "en",
259
- "en-bb": "en",
260
- "en-bm": "en",
261
- "en-bs": "en",
262
- "en-bw": "en",
263
- "en-bz": "en",
264
- "en-ca": "en",
265
- "en-cc": "en",
266
- "en-ck": "en",
267
- "en-cm": "en",
268
- "en-cx": "en",
269
- "en-cy": "en",
270
- "en-dg": "en",
271
- "en-dm": "en",
272
- "en-er": "en",
273
- "en-fj": "en",
274
- "en-fk": "en",
275
- "en-fm": "en",
276
- "en-gb": "en",
277
- "en-gd": "en",
278
- "en-gg": "en",
279
- "en-gh": "en",
280
- "en-gi": "en",
281
- "en-gm": "en",
282
- "en-gy": "en",
283
- "en-hk": "en",
284
- "en-ie": "en",
285
- "en-il": "en",
286
- "en-im": "en",
287
- "en-in": "en",
288
- "en-io": "en",
289
- "en-je": "en",
290
- "en-jm": "en",
291
- "en-ke": "en",
292
- "en-ki": "en",
293
- "en-kn": "en",
294
- "en-ky": "en",
295
- "en-lc": "en",
296
- "en-lr": "en",
297
- "en-ls": "en",
298
- "en-mg": "en",
299
- "en-mo": "en",
300
- "en-ms": "en",
301
- "en-mt": "en",
302
- "en-mu": "en",
303
- "en-mw": "en",
304
- "en-my": "en",
305
- "en-na": "en",
306
- "en-nf": "en",
307
- "en-ng": "en",
308
- "en-nr": "en",
309
- "en-nu": "en",
310
- "en-nz": "en",
311
- "en-pg": "en",
312
- "en-ph": "en",
313
- "en-pk": "en",
314
- "en-pn": "en",
315
- "en-pw": "en",
316
- "en-rw": "en",
317
- "en-sb": "en",
318
- "en-sc": "en",
319
- "en-sd": "en",
320
- "en-sg": "en",
321
- "en-sh": "en",
322
- "en-sl": "en",
323
- "en-ss": "en",
324
- "en-sx": "en",
325
- "en-sz": "en",
326
- "en-tc": "en",
327
- "en-tk": "en",
328
- "en-to": "en",
329
- "en-tt": "en",
330
- "en-tv": "en",
331
- "en-tz": "en",
332
- "en-ug": "en",
333
- "en-us": "en",
334
- "en-vc": "en",
335
- "en-vg": "en",
336
- "en-vu": "en",
337
- "en-ws": "en",
338
- "en-za": "en",
339
- "en-zm": "en",
340
- "en-zw": "en",
341
- "en-at": "en",
342
- "en-be": "en",
343
- "en-ch": "en",
344
- "en-de": "en",
345
- "en-dk": "en",
346
- "en-fi": "en",
347
- "en-nl": "en",
348
- "en-se": "en",
349
- "en-si": "en",
350
- "es-ar": "es",
351
- "es-bo": "es",
352
- "es-br": "es",
353
- "es-bz": "es",
354
- "es-cl": "es",
355
- "es-co": "es",
356
- "es-cr": "es",
357
- "es-cu": "es",
358
- "es-do": "es",
359
- "es-ec": "es",
360
- "es-es": "es",
361
- "es-gt": "es",
362
- "es-hn": "es",
363
- "es-mx": "es",
364
- "es-ni": "es",
365
- "es-pa": "es",
366
- "es-pe": "es",
367
- "es-pr": "es",
368
- "es-py": "es",
369
- "es-sv": "es",
370
- "es-us": "es",
371
- "es-uy": "es",
372
- "es-ve": "es",
373
- "pt-ao": "pt",
374
- "pt-ch": "pt",
375
- "pt-cv": "pt",
376
- "pt-fr": "pt",
377
- "pt-gq": "pt",
378
- "pt-gw": "pt",
379
- "pt-lu": "pt",
380
- "pt-mo": "pt",
381
- "pt-mz": "pt",
382
- "pt-pt": "pt",
383
- "pt-st": "pt",
384
- "pt-tl": "pt",
385
- "az-arab": "az",
386
- "az-cyrl": "az",
387
- "blt-latn": "blt",
388
- "bm-nkoo": "bm",
389
- "bs-cyrl": "bs",
390
- "byn-latn": "byn",
391
- "cu-glag": "cu",
392
- "dje-arab": "dje",
393
- "dyo-arab": "dyo",
394
- "en-dsrt": "en",
395
- "en-shaw": "en",
396
- "ff-adlm": "ff",
397
- "ff-arab": "ff",
398
- "ha-arab": "ha",
399
- "hi-latn": "hi",
400
- "iu-latn": "iu",
401
- "kk-arab": "kk",
402
- "ks-deva": "ks",
403
- "ku-arab": "ku",
404
- "ky-arab": "ky",
405
- "ky-latn": "ky",
406
- "ml-arab": "ml",
407
- "mn-mong": "mn",
408
- "mni-mtei": "mni",
409
- "ms-arab": "ms",
410
- "pa-arab": "pa",
411
- "sat-deva": "sat",
412
- "sd-deva": "sd",
413
- "sd-khoj": "sd",
414
- "sd-sind": "sd",
415
- "shi-latn": "shi",
416
- "so-arab": "so",
417
- "sr-latn": "sr",
418
- "sw-arab": "sw",
419
- "tg-arab": "tg",
420
- "ug-cyrl": "ug",
421
- "uz-arab": "uz",
422
- "uz-cyrl": "uz",
423
- "vai-latn": "vai",
424
- "wo-arab": "wo",
425
- "yo-arab": "yo",
426
- "yue-hans": "yue",
427
- "zh-hant": "zh",
428
- "zh-hant-hk": "zh",
429
- "zh-hant-mo": "zh-hant-hk"
430
- }[sourceLocale];
431
- }
432
-
433
- /**
434
- * Replace localeDir, srcPathDirs and srcPathIgnorePatterns with catalogs
435
- *
436
- * Released in @lingui/conf 3.0
437
- * Remove anytime after 4.x
438
- */
439
-
440
- function catalogMigration(config) {
441
- let {
442
- localeDir,
443
- srcPathDirs,
444
- srcPathIgnorePatterns,
445
- ...newConfig
446
- } = config;
447
- if (localeDir || srcPathDirs || srcPathIgnorePatterns) {
448
- // Replace missing values with default ones
449
- if (localeDir === undefined) localeDir = pathJoinPosix("<rootDir>", "locale", "{locale}", "messages");
450
- if (srcPathDirs === undefined) srcPathDirs = ["<rootDir>"];
451
- if (srcPathIgnorePatterns === undefined) srcPathIgnorePatterns = ["**/node_modules/**"];
452
- let newLocaleDir = localeDir.split(_path.default.sep).join("/");
453
- if (newLocaleDir.slice(-1) !== _path.default.sep) {
454
- newLocaleDir += "/";
455
- }
456
- if (!Array.isArray(newConfig.catalogs)) {
457
- newConfig.catalogs = [];
458
- }
459
- newConfig.catalogs.push({
460
- path: pathJoinPosix(newLocaleDir, "{locale}", "messages"),
461
- include: srcPathDirs,
462
- exclude: srcPathIgnorePatterns
463
- });
464
- }
465
- return newConfig;
466
- }
467
- const pipe = (...functions) => args => functions.reduce((arg, fn) => fn(arg), args);
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.getConfig = exports.makeConfig = void 0;
18
+ var makeConfig_1 = require("./makeConfig");
19
+ Object.defineProperty(exports, "makeConfig", { enumerable: true, get: function () { return makeConfig_1.makeConfig; } });
20
+ var getConfig_1 = require("./getConfig");
21
+ Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return getConfig_1.getConfig; } });
22
+ __exportStar(require("./types"), exports);
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAyC;AAAhC,wGAAA,UAAU,OAAA;AACnB,yCAAuC;AAA9B,sGAAA,SAAS,OAAA;AAClB,0CAAuB"}
@@ -0,0 +1,40 @@
1
+ import { ExtractorType, LinguiConfig, LinguiConfigNormalized } from "./types";
2
+ export declare function makeConfig(userConfig: Partial<LinguiConfig>, opts?: {
3
+ skipValidation?: boolean;
4
+ }): LinguiConfigNormalized;
5
+ export declare const defaultConfig: LinguiConfig;
6
+ export declare const exampleConfig: {
7
+ extractors: any[] | string[] | ExtractorType[];
8
+ runtimeConfigModule: string[] | {
9
+ i18n: string[];
10
+ Trans: string[];
11
+ };
12
+ fallbackLocales: boolean | {} | {
13
+ "en-US": string;
14
+ } | {
15
+ "en-US": string[];
16
+ } | {
17
+ default: string;
18
+ };
19
+ extractorParserOptions: {
20
+ flow: boolean;
21
+ decoratorsBeforeExport: boolean;
22
+ };
23
+ catalogs: import("./types").CatalogConfig[];
24
+ compileNamespace: string;
25
+ compilerBabelOptions: import("@babel/generator").GeneratorOptions;
26
+ prevFormat?: import("./types").CatalogFormat;
27
+ localeDir?: string;
28
+ format: import("./types").CatalogFormat;
29
+ formatOptions: import("./types").CatalogFormatOptions;
30
+ locales: string[];
31
+ catalogsMergePath: string;
32
+ orderBy: import("./types").OrderBy;
33
+ pseudoLocale: string;
34
+ rootDir: string;
35
+ sourceLocale: string;
36
+ service: {
37
+ name: string;
38
+ apiKey: string;
39
+ };
40
+ };
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.exampleConfig = exports.defaultConfig = exports.makeConfig = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const replaceRootDir_1 = require("./utils/replaceRootDir");
9
+ const jest_validate_1 = require("jest-validate");
10
+ const setCldrParentLocales_1 = require("./migrations/setCldrParentLocales");
11
+ const pathJoinPosix_1 = require("./utils/pathJoinPosix");
12
+ const normalizeRuntimeConfigModule_1 = require("./migrations/normalizeRuntimeConfigModule");
13
+ function makeConfig(userConfig, opts = {}) {
14
+ let config = {
15
+ ...exports.defaultConfig,
16
+ ...userConfig,
17
+ };
18
+ if (!opts.skipValidation) {
19
+ (0, jest_validate_1.validate)(config, configValidation);
20
+ validateLocales(config);
21
+ }
22
+ config = pipe(
23
+ // List config migrations from oldest to newest
24
+ setCldrParentLocales_1.setCldrParentLocales, normalizeRuntimeConfigModule_1.normalizeRuntimeConfigModule)(config);
25
+ // `replaceRootDir` should always be the last
26
+ return (0, replaceRootDir_1.replaceRootDir)(config, config.rootDir);
27
+ }
28
+ exports.makeConfig = makeConfig;
29
+ exports.defaultConfig = {
30
+ catalogs: [
31
+ {
32
+ path: (0, pathJoinPosix_1.pathJoinPosix)("<rootDir>", "locale", "{locale}", "messages"),
33
+ include: ["<rootDir>"],
34
+ exclude: ["*/node_modules/*"],
35
+ },
36
+ ],
37
+ catalogsMergePath: "",
38
+ compileNamespace: "cjs",
39
+ compilerBabelOptions: {
40
+ minified: true,
41
+ jsescOption: {
42
+ minimal: true,
43
+ },
44
+ },
45
+ extractorParserOptions: {
46
+ flow: false,
47
+ decoratorsBeforeExport: false,
48
+ },
49
+ fallbackLocales: {},
50
+ format: "po",
51
+ formatOptions: { origins: true, lineNumbers: true },
52
+ locales: [],
53
+ orderBy: "messageId",
54
+ pseudoLocale: "",
55
+ rootDir: ".",
56
+ runtimeConfigModule: ["@lingui/core", "i18n"],
57
+ sourceLocale: "",
58
+ service: { name: "", apiKey: "" },
59
+ };
60
+ exports.exampleConfig = {
61
+ ...exports.defaultConfig,
62
+ extractors: (0, jest_validate_1.multipleValidOptions)([], ["babel"], [
63
+ {
64
+ match: (fileName) => false,
65
+ extract: (filename, code, onMessageExtracted, ctx) => { },
66
+ },
67
+ ]),
68
+ runtimeConfigModule: (0, jest_validate_1.multipleValidOptions)({ i18n: ["@lingui/core", "i18n"], Trans: ["@lingui/react", "Trans"] }, ["@lingui/core", "i18n"]),
69
+ fallbackLocales: (0, jest_validate_1.multipleValidOptions)({}, { "en-US": "en" }, { "en-US": ["en"] }, { default: "en" }, false),
70
+ extractorParserOptions: {
71
+ flow: false,
72
+ decoratorsBeforeExport: false,
73
+ },
74
+ };
75
+ /**
76
+ * Introduced in v4, remove in v5
77
+ */
78
+ const extractBabelOptionsDeprecations = {
79
+ extractBabelOptions: () => ` Option ${chalk_1.default.bold("extractBabelOptions")} was removed.
80
+
81
+ Please remove it from your config file.
82
+
83
+ You can find more information here: https://lingui.dev/releases/migration-4
84
+ `,
85
+ };
86
+ const configValidation = {
87
+ exampleConfig: exports.exampleConfig,
88
+ deprecatedConfig: {
89
+ ...extractBabelOptionsDeprecations,
90
+ },
91
+ comment: "Documentation: https://lingui.dev/ref/conf",
92
+ };
93
+ function validateLocales(config) {
94
+ if (!Array.isArray(config.locales) || !config.locales.length) {
95
+ console.error("No locales defined!\n");
96
+ console.error(`Add ${chalk_1.default.yellow("'locales'")} to your configuration. See ${chalk_1.default.underline("https://lingui.dev/ref/conf#locales")}`);
97
+ }
98
+ }
99
+ const pipe = (...functions) => (args) => functions.reduce((arg, fn) => fn(arg), args);
100
+ //# sourceMappingURL=makeConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"makeConfig.js","sourceRoot":"","sources":["../src/makeConfig.ts"],"names":[],"mappings":";;;;;;AAQA,kDAAyB;AACzB,2DAAuD;AACvD,iDAA8D;AAC9D,4EAAwE;AACxE,yDAAqD;AACrD,4FAAwF;AAExF,SAAgB,UAAU,CACxB,UAAiC,EACjC,OAEI,EAAE;IAEN,IAAI,MAAM,GAAiB;QACzB,GAAG,qBAAa;QAChB,GAAG,UAAU;KACd,CAAA;IAED,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;QACxB,IAAA,wBAAQ,EAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;QAClC,eAAe,CAAC,MAAM,CAAC,CAAA;KACxB;IAED,MAAM,GAAG,IAAI;IACX,+CAA+C;IAC/C,2CAAoB,EACpB,2DAA4B,CAC7B,CAAC,MAAM,CAAC,CAAA;IAET,6CAA6C;IAC7C,OAAO,IAAA,+BAAc,EACnB,MAAM,EACN,MAAM,CAAC,OA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fig } from "../types";
2
+ export declare function normalizeRuntimeConfigModule(config: Pick<LinguiConfig, "runtimeConfigModule">): {
3
+ runtimeConfigModule: {
4
+ i18nImportModule: string;
5
+ i18nImportName: string;
6
+ TransImportModule: string;
7
+ TransImportName: string;
8
+ };
9
+ };
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeRuntimeConfigModule = void 0;
4
+ const getSymbolSource = (defaults, config) => {
5
+ const name = defaults[1];
6
+ if (Array.isArray(config)) {
7
+ if (name === "i18n") {
8
+ return config;
9
+ }
10
+ return defaults;
11
+ }
12
+ return config[name] || defaults;
13
+ };
14
+ function normalizeRuntimeConfigModule(config) {
15
+ const [i18nImportModule, i18nImportName] = getSymbolSource(["@lingui/core", "i18n"], config.runtimeConfigModule);
16
+ const [TransImportModule, TransImportName] = getSymbolSource(["@lingui/react", "Trans"], config.runtimeConfigModule);
17
+ return {
18
+ ...config,
19
+ runtimeConfigModule: {
20
+ i18nImportModule,
21
+ i18nImportName,
22
+ TransImportModule,
23
+ TransImportName,
24
+ },
25
+ };
26
+ }
27
+ exports.normalizeRuntimeConfigModule = normalizeRuntimeConfigModule;
28
+ //# sourceMappingURL=normalizeRuntimeConfigModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeRuntimeConfigModule.js","sourceRoot":"","sources":["../../src/migrations/normalizeRuntimeConfigModule.ts"],"names":[],"mappings":";;;AAIA,MAAM,eAAe,GAAG,CACtB,QAAmB,EACnB,MAA2C,EAChC,EAAE;IACb,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IACxB,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACzB,IAAI,IAAI,KAAK,MAAM,EAAE;YACnB,OAAO,MAAM,CAAA;SACd;QACD,OAAO,QAAQ,CAAA;KAChB;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAA;AACjC,CAAC,CAAA;AAED,SAAgB,4BAA4B,CAC1C,MAAiD;IAEjD,MAAM,CAAC,gBAAgB,EAAE,cAAc,CAAC,GAAG,eAAe,CACxD,CAAC,cAAc,EAAE,MAAM,CAAC,EACxB,MAAM,CAAC,mBAAmB,CAC3B,CAAA;IACD,MAAM,CAAC,iBAAiB,EAAE,eAAe,CAAC,GAAG,eAAe,CAC1D,CAAC,eAAe,EAAE,OAAO,CAAC,EAC1B,MAAM,CAAC,mBAAmB,CAC3B,CAAA;IAED,OAAO;QACL,GAAG,MAAM;QACT,mBAAmB,EAAE;YACnB,gBAAgB;YAChB,cAAc;YACd,iBAAiB;YACjB,eAAe;SACwC;KAC1D,CAAA;AACH,CAAC;AArBD,oEAqBC"}