@lingui/loader 4.0.0-next.3 → 4.0.0-next.5

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 ADDED
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const conf = require('@lingui/conf');
5
+ const api = require('@lingui/cli/api');
6
+
7
+ const loader = async function(source) {
8
+ const options = this.getOptions() || {};
9
+ const config = conf.getConfig({
10
+ configPath: options.config,
11
+ cwd: path.dirname(this.resourcePath)
12
+ });
13
+ const catalogRelativePath = path.relative(config.rootDir, this.resourcePath);
14
+ const { locale, catalog } = api.getCatalogForFile(
15
+ catalogRelativePath,
16
+ await api.getCatalogs(config)
17
+ );
18
+ const messages = await catalog.getTranslations(locale, {
19
+ fallbackLocales: config.fallbackLocales,
20
+ sourceLocale: config.sourceLocale
21
+ });
22
+ const strict = process.env.NODE_ENV !== "production";
23
+ return api.createCompiledCatalog(locale, messages, {
24
+ strict,
25
+ namespace: this._module.type === "json" ? "json" : "es",
26
+ pseudoLocale: config.pseudoLocale
27
+ });
28
+ };
29
+ const loader$1 = loader;
30
+
31
+ module.exports = loader$1;
@@ -0,0 +1,8 @@
1
+ import { LoaderDefinitionFunction } from 'webpack';
2
+
3
+ type LinguiLoaderOptions = {
4
+ config?: string;
5
+ };
6
+ declare const loader: LoaderDefinitionFunction<LinguiLoaderOptions>;
7
+
8
+ export { loader as default };
package/dist/index.mjs ADDED
@@ -0,0 +1,29 @@
1
+ import path from 'path';
2
+ import { getConfig } from '@lingui/conf';
3
+ import { getCatalogForFile, getCatalogs, createCompiledCatalog } from '@lingui/cli/api';
4
+
5
+ const loader = async function(source) {
6
+ const options = this.getOptions() || {};
7
+ const config = getConfig({
8
+ configPath: options.config,
9
+ cwd: path.dirname(this.resourcePath)
10
+ });
11
+ const catalogRelativePath = path.relative(config.rootDir, this.resourcePath);
12
+ const { locale, catalog } = getCatalogForFile(
13
+ catalogRelativePath,
14
+ await getCatalogs(config)
15
+ );
16
+ const messages = await catalog.getTranslations(locale, {
17
+ fallbackLocales: config.fallbackLocales,
18
+ sourceLocale: config.sourceLocale
19
+ });
20
+ const strict = process.env.NODE_ENV !== "production";
21
+ return createCompiledCatalog(locale, messages, {
22
+ strict,
23
+ namespace: this._module.type === "json" ? "json" : "es",
24
+ pseudoLocale: config.pseudoLocale
25
+ });
26
+ };
27
+ const loader$1 = loader;
28
+
29
+ export { loader$1 as default };
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "@lingui/loader",
3
- "version": "4.0.0-next.3",
3
+ "version": "4.0.0-next.5",
4
4
  "description": "webpack loader for lingui message catalogs",
5
- "types": "./build/index.d.ts",
6
- "main": "./build/index.js",
5
+ "types": "./dist/index.d.ts",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.mjs",
8
+ "sideEffects": false,
7
9
  "author": {
8
10
  "name": "Tomáš Ehrlich",
9
11
  "email": "tomas.ehrlich@gmail.com"
@@ -19,6 +21,10 @@
19
21
  "i9n",
20
22
  "translation"
21
23
  ],
24
+ "scripts": {
25
+ "build": "rimraf ./dist && unbuild",
26
+ "stub": "unbuild --stub"
27
+ },
22
28
  "repository": {
23
29
  "type": "git",
24
30
  "url": "https://github.com/lingui/js-lingui.git"
@@ -32,19 +38,20 @@
32
38
  "files": [
33
39
  "LICENSE",
34
40
  "README.md",
35
- "build/"
41
+ "dist/"
36
42
  ],
37
43
  "dependencies": {
38
44
  "@babel/runtime": "^7.20.13",
39
- "@lingui/cli": "^4.0.0-next.3",
40
- "@lingui/conf": "^4.0.0-next.3"
45
+ "@lingui/cli": "^4.0.0-next.5",
46
+ "@lingui/conf": "^4.0.0-next.5"
41
47
  },
42
48
  "devDependencies": {
43
- "@lingui/format-json": "^4.0.0-next.3",
49
+ "@lingui/format-json": "^4.0.0-next.5",
50
+ "unbuild": "^1.1.2",
44
51
  "webpack": "^5.76.1"
45
52
  },
46
53
  "peerDependencies": {
47
54
  "webpack": "^5.0.0"
48
55
  },
49
- "gitHead": "29cad1bdcc781994ac4d496e5c4937795423d405"
56
+ "gitHead": "bdbd6cf310cbcf09e1fe288f20ef530c28de481d"
50
57
  }
package/build/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2017-2022 Tomáš Ehrlich, (c) 2022-2023 Crowdin.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
package/build/index.d.ts DELETED
File without changes
package/build/index.js DELETED
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "default", {
7
- enumerable: true,
8
- get: function () {
9
- return _webpackLoader.default;
10
- }
11
- });
12
- exports.remoteLoader = remoteLoader;
13
- var _webpackLoader = _interopRequireDefault(require("./webpackLoader"));
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
- function remoteLoader() {
16
- console.error(`
17
- DEPRECATED: { remoteLoader } from "@lingui/loader"
18
- Use instead: { remoteLoader } from "@lingui/remote-loader"
19
- `);
20
- }
@@ -1,40 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _path = _interopRequireDefault(require("path"));
8
- var _conf = require("@lingui/conf");
9
- var _api = require("@lingui/cli/api");
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- const loader = async function (source) {
12
- const options = this.getOptions() || {};
13
- const config = (0, _conf.getConfig)({
14
- configPath: options.config,
15
- cwd: _path.default.dirname(this.resourcePath)
16
- });
17
- const catalogRelativePath = _path.default.relative(config.rootDir, this.resourcePath);
18
- const {
19
- locale,
20
- catalog
21
- } = (0, _api.getCatalogForFile)(catalogRelativePath, await (0, _api.getCatalogs)(config));
22
- const messages = await catalog.getTranslations(locale, {
23
- fallbackLocales: config.fallbackLocales,
24
- sourceLocale: config.sourceLocale
25
- });
26
-
27
- // In production we don't want untranslated strings. It's better to use message
28
- // keys as a last resort.
29
- // In development, however, we want to catch missing strings with `missing` parameter
30
- // of I18nProvider (React) or setupI18n (core) and therefore we need to get
31
- // empty translations if missing.
32
- const strict = process.env.NODE_ENV !== "production";
33
- return (0, _api.createCompiledCatalog)(locale, messages, {
34
- strict,
35
- namespace: this._module.type === "json" ? "json" : "es",
36
- pseudoLocale: config.pseudoLocale
37
- });
38
- };
39
- var _default = loader;
40
- exports.default = _default;