@lingui/loader 5.2.0 → 5.3.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/index.cjs +30 -5
- package/dist/index.d.cts +8 -0
- package/dist/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.mjs +31 -6
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -38,16 +38,41 @@ Please check that \`catalogs.path\` is filled properly.
|
|
|
38
38
|
const { locale, catalog } = fileCatalog;
|
|
39
39
|
const dependency = await api.getCatalogDependentFiles(catalog, locale);
|
|
40
40
|
dependency.forEach((file) => this.addDependency(path__default.normalize(file)));
|
|
41
|
-
const messages = await catalog.getTranslations(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
const { messages, missing: missingMessages } = await catalog.getTranslations(
|
|
42
|
+
locale,
|
|
43
|
+
{
|
|
44
|
+
fallbackLocales: config.fallbackLocales,
|
|
45
|
+
sourceLocale: config.sourceLocale
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
if (options.failOnMissing && locale !== config.pseudoLocale && missingMessages.length > 0) {
|
|
49
|
+
const message = api.createMissingErrorMessage(locale, missingMessages, "loader");
|
|
50
|
+
throw new Error(
|
|
51
|
+
`${message}
|
|
52
|
+
You see this error because \`failOnMissing=true\` in Lingui Loader configuration.`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
45
55
|
const strict = process.env.NODE_ENV !== "production";
|
|
46
|
-
|
|
56
|
+
const { source: code, errors } = api.createCompiledCatalog(locale, messages, {
|
|
47
57
|
strict,
|
|
48
58
|
namespace: this._module.type === "json" ? "json" : "es",
|
|
49
59
|
pseudoLocale: config.pseudoLocale
|
|
50
60
|
});
|
|
61
|
+
if (errors.length) {
|
|
62
|
+
const message = api.createCompilationErrorMessage(locale, errors);
|
|
63
|
+
if (options.failOnCompileError) {
|
|
64
|
+
throw new Error(
|
|
65
|
+
`${message} These errors fail build because \`failOnCompileError=true\` in Lingui Loader configuration.`
|
|
66
|
+
);
|
|
67
|
+
} else {
|
|
68
|
+
this.emitWarning(
|
|
69
|
+
new Error(
|
|
70
|
+
`${message} You can fail the build on these errors by setting \`failOnCompileError=true\` in Lingui Loader configuration.`
|
|
71
|
+
)
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return code;
|
|
51
76
|
};
|
|
52
77
|
const loader$1 = loader;
|
|
53
78
|
|
package/dist/index.d.cts
CHANGED
|
@@ -2,6 +2,14 @@ import { LoaderDefinitionFunction } from 'webpack';
|
|
|
2
2
|
|
|
3
3
|
type LinguiLoaderOptions = {
|
|
4
4
|
config?: string;
|
|
5
|
+
/**
|
|
6
|
+
* If true would fail compilation on missing translations
|
|
7
|
+
**/
|
|
8
|
+
failOnMissing?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* If true would fail compilation on message compilation errors
|
|
11
|
+
**/
|
|
12
|
+
failOnCompileError?: boolean;
|
|
5
13
|
};
|
|
6
14
|
declare const loader: LoaderDefinitionFunction<LinguiLoaderOptions>;
|
|
7
15
|
|
package/dist/index.d.mts
CHANGED
|
@@ -2,6 +2,14 @@ import { LoaderDefinitionFunction } from 'webpack';
|
|
|
2
2
|
|
|
3
3
|
type LinguiLoaderOptions = {
|
|
4
4
|
config?: string;
|
|
5
|
+
/**
|
|
6
|
+
* If true would fail compilation on missing translations
|
|
7
|
+
**/
|
|
8
|
+
failOnMissing?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* If true would fail compilation on message compilation errors
|
|
11
|
+
**/
|
|
12
|
+
failOnCompileError?: boolean;
|
|
5
13
|
};
|
|
6
14
|
declare const loader: LoaderDefinitionFunction<LinguiLoaderOptions>;
|
|
7
15
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,14 @@ import { LoaderDefinitionFunction } from 'webpack';
|
|
|
2
2
|
|
|
3
3
|
type LinguiLoaderOptions = {
|
|
4
4
|
config?: string;
|
|
5
|
+
/**
|
|
6
|
+
* If true would fail compilation on missing translations
|
|
7
|
+
**/
|
|
8
|
+
failOnMissing?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* If true would fail compilation on message compilation errors
|
|
11
|
+
**/
|
|
12
|
+
failOnCompileError?: boolean;
|
|
5
13
|
};
|
|
6
14
|
declare const loader: LoaderDefinitionFunction<LinguiLoaderOptions>;
|
|
7
15
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import { getConfig } from '@lingui/conf';
|
|
3
|
-
import { getCatalogForFile, getCatalogs, getCatalogDependentFiles, createCompiledCatalog } from '@lingui/cli/api';
|
|
3
|
+
import { getCatalogForFile, getCatalogs, getCatalogDependentFiles, createMissingErrorMessage, createCompiledCatalog, createCompilationErrorMessage } from '@lingui/cli/api';
|
|
4
4
|
|
|
5
5
|
const loader = async function(source) {
|
|
6
6
|
const options = this.getOptions() || {};
|
|
@@ -32,16 +32,41 @@ Please check that \`catalogs.path\` is filled properly.
|
|
|
32
32
|
const { locale, catalog } = fileCatalog;
|
|
33
33
|
const dependency = await getCatalogDependentFiles(catalog, locale);
|
|
34
34
|
dependency.forEach((file) => this.addDependency(path.normalize(file)));
|
|
35
|
-
const messages = await catalog.getTranslations(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
const { messages, missing: missingMessages } = await catalog.getTranslations(
|
|
36
|
+
locale,
|
|
37
|
+
{
|
|
38
|
+
fallbackLocales: config.fallbackLocales,
|
|
39
|
+
sourceLocale: config.sourceLocale
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
if (options.failOnMissing && locale !== config.pseudoLocale && missingMessages.length > 0) {
|
|
43
|
+
const message = createMissingErrorMessage(locale, missingMessages, "loader");
|
|
44
|
+
throw new Error(
|
|
45
|
+
`${message}
|
|
46
|
+
You see this error because \`failOnMissing=true\` in Lingui Loader configuration.`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
39
49
|
const strict = process.env.NODE_ENV !== "production";
|
|
40
|
-
|
|
50
|
+
const { source: code, errors } = createCompiledCatalog(locale, messages, {
|
|
41
51
|
strict,
|
|
42
52
|
namespace: this._module.type === "json" ? "json" : "es",
|
|
43
53
|
pseudoLocale: config.pseudoLocale
|
|
44
54
|
});
|
|
55
|
+
if (errors.length) {
|
|
56
|
+
const message = createCompilationErrorMessage(locale, errors);
|
|
57
|
+
if (options.failOnCompileError) {
|
|
58
|
+
throw new Error(
|
|
59
|
+
`${message} These errors fail build because \`failOnCompileError=true\` in Lingui Loader configuration.`
|
|
60
|
+
);
|
|
61
|
+
} else {
|
|
62
|
+
this.emitWarning(
|
|
63
|
+
new Error(
|
|
64
|
+
`${message} You can fail the build on these errors by setting \`failOnCompileError=true\` in Lingui Loader configuration.`
|
|
65
|
+
)
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return code;
|
|
45
70
|
};
|
|
46
71
|
const loader$1 = loader;
|
|
47
72
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/loader",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"description": "webpack loader for lingui message catalogs",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -43,16 +43,16 @@
|
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@babel/runtime": "^7.20.13",
|
|
46
|
-
"@lingui/cli": "5.
|
|
47
|
-
"@lingui/conf": "5.
|
|
46
|
+
"@lingui/cli": "5.3.0",
|
|
47
|
+
"@lingui/conf": "5.3.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@lingui/format-json": "5.
|
|
50
|
+
"@lingui/format-json": "5.3.0",
|
|
51
51
|
"unbuild": "2.0.0",
|
|
52
52
|
"webpack": "^5.76.1"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"webpack": "^5.0.0"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "ed491cce7e5209378922327e0e7b802fb7b5873d"
|
|
58
58
|
}
|