@lingui/conf 5.4.1 → 5.5.1
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/index.cjs +16 -10
- package/dist/index.d.cts +6 -5
- package/dist/index.d.mts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.mjs +16 -10
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -5,6 +5,7 @@ const jestValidate = require('jest-validate');
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const fs = require('fs');
|
|
7
7
|
const cosmiconfig = require('cosmiconfig');
|
|
8
|
+
const jiti = require('jiti');
|
|
8
9
|
|
|
9
10
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
10
11
|
|
|
@@ -13,6 +14,9 @@ const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
|
13
14
|
const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
14
15
|
|
|
15
16
|
function replaceRootDir(config, rootDir) {
|
|
17
|
+
if (!rootDir) {
|
|
18
|
+
return config;
|
|
19
|
+
}
|
|
16
20
|
return function replaceDeep(value, rootDir2) {
|
|
17
21
|
const replace = (s) => s.replace("<rootDir>", rootDir2);
|
|
18
22
|
if (value == null) {
|
|
@@ -40,7 +44,7 @@ function setCldrParentLocales(config) {
|
|
|
40
44
|
fallbackLocales: {}
|
|
41
45
|
};
|
|
42
46
|
}
|
|
43
|
-
if (!config.fallbackLocales
|
|
47
|
+
if (!config.fallbackLocales?.default) {
|
|
44
48
|
config.locales.forEach((locale) => {
|
|
45
49
|
const fl = getCldrParentLocale(locale.toLowerCase());
|
|
46
50
|
if (fl && !config.fallbackLocales[locale]) {
|
|
@@ -283,10 +287,14 @@ function makeConfig(userConfig, opts = {}) {
|
|
|
283
287
|
}
|
|
284
288
|
config = setCldrParentLocales(config);
|
|
285
289
|
config = normalizeRuntimeConfigModule(config);
|
|
286
|
-
|
|
290
|
+
const out = replaceRootDir(
|
|
287
291
|
config,
|
|
288
292
|
config.rootDir
|
|
289
293
|
);
|
|
294
|
+
return {
|
|
295
|
+
...out,
|
|
296
|
+
resolvedConfigPath: opts.resolvedConfigPath
|
|
297
|
+
};
|
|
290
298
|
}
|
|
291
299
|
const defaultConfig = {
|
|
292
300
|
catalogs: [
|
|
@@ -375,15 +383,13 @@ function defineConfig(config) {
|
|
|
375
383
|
}
|
|
376
384
|
|
|
377
385
|
function configExists(path2) {
|
|
378
|
-
return path2 && fs__default.existsSync(path2);
|
|
386
|
+
return !!path2 && fs__default.existsSync(path2);
|
|
379
387
|
}
|
|
380
388
|
function JitiLoader() {
|
|
381
|
-
return (filepath
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
const jiti = require("jiti")(__filename, opts);
|
|
386
|
-
return jiti(filepath);
|
|
389
|
+
return (filepath) => {
|
|
390
|
+
const jiti$1 = jiti.createJiti(__filename);
|
|
391
|
+
const mod = jiti$1(filepath);
|
|
392
|
+
return mod?.default ?? mod;
|
|
387
393
|
};
|
|
388
394
|
}
|
|
389
395
|
const moduleName = "lingui";
|
|
@@ -432,7 +438,7 @@ function getConfig({
|
|
|
432
438
|
rootDir: result ? path__default.dirname(result.filepath) : defaultRootDir,
|
|
433
439
|
...userConfig
|
|
434
440
|
},
|
|
435
|
-
{ skipValidation }
|
|
441
|
+
{ skipValidation, resolvedConfigPath: result.filepath }
|
|
436
442
|
);
|
|
437
443
|
}
|
|
438
444
|
|
package/dist/index.d.cts
CHANGED
|
@@ -88,10 +88,9 @@ type CatalogConfig = {
|
|
|
88
88
|
include: string[];
|
|
89
89
|
exclude?: string[];
|
|
90
90
|
};
|
|
91
|
-
type LocaleObject = {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
};
|
|
91
|
+
type LocaleObject = Record<string, string[] | string> | (Record<string, string[] | string> & {
|
|
92
|
+
default: string;
|
|
93
|
+
});
|
|
95
94
|
type FallbackLocales = LocaleObject;
|
|
96
95
|
type ModuleSource = readonly [module: string, specifier?: string];
|
|
97
96
|
type CatalogService = {
|
|
@@ -229,7 +228,7 @@ type LinguiConfig = {
|
|
|
229
228
|
*
|
|
230
229
|
* Note that using <rootDir> as a string token in any other path-based config settings will refer back to this value.
|
|
231
230
|
*
|
|
232
|
-
* @
|
|
231
|
+
* @default: The root of the directory containing your Lingui configuration file or the package.json.
|
|
233
232
|
*/
|
|
234
233
|
rootDir?: string;
|
|
235
234
|
/**
|
|
@@ -310,6 +309,7 @@ type LinguiConfig = {
|
|
|
310
309
|
};
|
|
311
310
|
type ModuleSourceNormalized = readonly [module: string, specifier: string];
|
|
312
311
|
type LinguiConfigNormalized = Omit<LinguiConfig, "runtimeConfigModule"> & {
|
|
312
|
+
resolvedConfigPath?: string;
|
|
313
313
|
fallbackLocales?: FallbackLocales;
|
|
314
314
|
runtimeConfigModule: {
|
|
315
315
|
i18n: ModuleSourceNormalized;
|
|
@@ -320,6 +320,7 @@ type LinguiConfigNormalized = Omit<LinguiConfig, "runtimeConfigModule"> & {
|
|
|
320
320
|
|
|
321
321
|
declare function makeConfig(userConfig: Partial<LinguiConfig>, opts?: {
|
|
322
322
|
skipValidation?: boolean;
|
|
323
|
+
resolvedConfigPath?: string;
|
|
323
324
|
}): LinguiConfigNormalized;
|
|
324
325
|
|
|
325
326
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -88,10 +88,9 @@ type CatalogConfig = {
|
|
|
88
88
|
include: string[];
|
|
89
89
|
exclude?: string[];
|
|
90
90
|
};
|
|
91
|
-
type LocaleObject = {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
};
|
|
91
|
+
type LocaleObject = Record<string, string[] | string> | (Record<string, string[] | string> & {
|
|
92
|
+
default: string;
|
|
93
|
+
});
|
|
95
94
|
type FallbackLocales = LocaleObject;
|
|
96
95
|
type ModuleSource = readonly [module: string, specifier?: string];
|
|
97
96
|
type CatalogService = {
|
|
@@ -229,7 +228,7 @@ type LinguiConfig = {
|
|
|
229
228
|
*
|
|
230
229
|
* Note that using <rootDir> as a string token in any other path-based config settings will refer back to this value.
|
|
231
230
|
*
|
|
232
|
-
* @
|
|
231
|
+
* @default: The root of the directory containing your Lingui configuration file or the package.json.
|
|
233
232
|
*/
|
|
234
233
|
rootDir?: string;
|
|
235
234
|
/**
|
|
@@ -310,6 +309,7 @@ type LinguiConfig = {
|
|
|
310
309
|
};
|
|
311
310
|
type ModuleSourceNormalized = readonly [module: string, specifier: string];
|
|
312
311
|
type LinguiConfigNormalized = Omit<LinguiConfig, "runtimeConfigModule"> & {
|
|
312
|
+
resolvedConfigPath?: string;
|
|
313
313
|
fallbackLocales?: FallbackLocales;
|
|
314
314
|
runtimeConfigModule: {
|
|
315
315
|
i18n: ModuleSourceNormalized;
|
|
@@ -320,6 +320,7 @@ type LinguiConfigNormalized = Omit<LinguiConfig, "runtimeConfigModule"> & {
|
|
|
320
320
|
|
|
321
321
|
declare function makeConfig(userConfig: Partial<LinguiConfig>, opts?: {
|
|
322
322
|
skipValidation?: boolean;
|
|
323
|
+
resolvedConfigPath?: string;
|
|
323
324
|
}): LinguiConfigNormalized;
|
|
324
325
|
|
|
325
326
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -88,10 +88,9 @@ type CatalogConfig = {
|
|
|
88
88
|
include: string[];
|
|
89
89
|
exclude?: string[];
|
|
90
90
|
};
|
|
91
|
-
type LocaleObject = {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
};
|
|
91
|
+
type LocaleObject = Record<string, string[] | string> | (Record<string, string[] | string> & {
|
|
92
|
+
default: string;
|
|
93
|
+
});
|
|
95
94
|
type FallbackLocales = LocaleObject;
|
|
96
95
|
type ModuleSource = readonly [module: string, specifier?: string];
|
|
97
96
|
type CatalogService = {
|
|
@@ -229,7 +228,7 @@ type LinguiConfig = {
|
|
|
229
228
|
*
|
|
230
229
|
* Note that using <rootDir> as a string token in any other path-based config settings will refer back to this value.
|
|
231
230
|
*
|
|
232
|
-
* @
|
|
231
|
+
* @default: The root of the directory containing your Lingui configuration file or the package.json.
|
|
233
232
|
*/
|
|
234
233
|
rootDir?: string;
|
|
235
234
|
/**
|
|
@@ -310,6 +309,7 @@ type LinguiConfig = {
|
|
|
310
309
|
};
|
|
311
310
|
type ModuleSourceNormalized = readonly [module: string, specifier: string];
|
|
312
311
|
type LinguiConfigNormalized = Omit<LinguiConfig, "runtimeConfigModule"> & {
|
|
312
|
+
resolvedConfigPath?: string;
|
|
313
313
|
fallbackLocales?: FallbackLocales;
|
|
314
314
|
runtimeConfigModule: {
|
|
315
315
|
i18n: ModuleSourceNormalized;
|
|
@@ -320,6 +320,7 @@ type LinguiConfigNormalized = Omit<LinguiConfig, "runtimeConfigModule"> & {
|
|
|
320
320
|
|
|
321
321
|
declare function makeConfig(userConfig: Partial<LinguiConfig>, opts?: {
|
|
322
322
|
skipValidation?: boolean;
|
|
323
|
+
resolvedConfigPath?: string;
|
|
323
324
|
}): LinguiConfigNormalized;
|
|
324
325
|
|
|
325
326
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -3,8 +3,12 @@ import { validate, multipleValidOptions } from 'jest-validate';
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
import { cosmiconfigSync } from 'cosmiconfig';
|
|
6
|
+
import { createJiti } from 'jiti';
|
|
6
7
|
|
|
7
8
|
function replaceRootDir(config, rootDir) {
|
|
9
|
+
if (!rootDir) {
|
|
10
|
+
return config;
|
|
11
|
+
}
|
|
8
12
|
return function replaceDeep(value, rootDir2) {
|
|
9
13
|
const replace = (s) => s.replace("<rootDir>", rootDir2);
|
|
10
14
|
if (value == null) {
|
|
@@ -32,7 +36,7 @@ function setCldrParentLocales(config) {
|
|
|
32
36
|
fallbackLocales: {}
|
|
33
37
|
};
|
|
34
38
|
}
|
|
35
|
-
if (!config.fallbackLocales
|
|
39
|
+
if (!config.fallbackLocales?.default) {
|
|
36
40
|
config.locales.forEach((locale) => {
|
|
37
41
|
const fl = getCldrParentLocale(locale.toLowerCase());
|
|
38
42
|
if (fl && !config.fallbackLocales[locale]) {
|
|
@@ -275,10 +279,14 @@ function makeConfig(userConfig, opts = {}) {
|
|
|
275
279
|
}
|
|
276
280
|
config = setCldrParentLocales(config);
|
|
277
281
|
config = normalizeRuntimeConfigModule(config);
|
|
278
|
-
|
|
282
|
+
const out = replaceRootDir(
|
|
279
283
|
config,
|
|
280
284
|
config.rootDir
|
|
281
285
|
);
|
|
286
|
+
return {
|
|
287
|
+
...out,
|
|
288
|
+
resolvedConfigPath: opts.resolvedConfigPath
|
|
289
|
+
};
|
|
282
290
|
}
|
|
283
291
|
const defaultConfig = {
|
|
284
292
|
catalogs: [
|
|
@@ -367,15 +375,13 @@ function defineConfig(config) {
|
|
|
367
375
|
}
|
|
368
376
|
|
|
369
377
|
function configExists(path2) {
|
|
370
|
-
return path2 && fs.existsSync(path2);
|
|
378
|
+
return !!path2 && fs.existsSync(path2);
|
|
371
379
|
}
|
|
372
380
|
function JitiLoader() {
|
|
373
|
-
return (filepath
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
const jiti = require("jiti")(__filename, opts);
|
|
378
|
-
return jiti(filepath);
|
|
381
|
+
return (filepath) => {
|
|
382
|
+
const jiti = createJiti(__filename);
|
|
383
|
+
const mod = jiti(filepath);
|
|
384
|
+
return mod?.default ?? mod;
|
|
379
385
|
};
|
|
380
386
|
}
|
|
381
387
|
const moduleName = "lingui";
|
|
@@ -424,7 +430,7 @@ function getConfig({
|
|
|
424
430
|
rootDir: result ? path.dirname(result.filepath) : defaultRootDir,
|
|
425
431
|
...userConfig
|
|
426
432
|
},
|
|
427
|
-
{ skipValidation }
|
|
433
|
+
{ skipValidation, resolvedConfigPath: result.filepath }
|
|
428
434
|
);
|
|
429
435
|
}
|
|
430
436
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/conf",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"description": "Get lingui configuration from package.json",
|
|
6
6
|
"keywords": [
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@babel/runtime": "^7.20.13",
|
|
34
34
|
"cosmiconfig": "^8.0.0",
|
|
35
35
|
"jest-validate": "^29.4.3",
|
|
36
|
-
"jiti": "^
|
|
36
|
+
"jiti": "^2.5.1",
|
|
37
37
|
"picocolors": "^1.1.1"
|
|
38
38
|
},
|
|
39
39
|
"files": [
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"@lingui/jest-mocks": "*",
|
|
46
46
|
"unbuild": "^2.0.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "3bd1384568848e15e60fb40324e9e0476ca152e6"
|
|
49
49
|
}
|