@lingui/vite-plugin 5.9.0 → 6.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/dist/index.d.mts CHANGED
@@ -15,4 +15,5 @@ type LinguiPluginOpts = {
15
15
  };
16
16
  declare function lingui({ failOnMissing, failOnCompileError, ...linguiConfig }?: LinguiPluginOpts): Plugin[];
17
17
 
18
- export { type LinguiPluginOpts, lingui as default, lingui };
18
+ export { lingui as default, lingui };
19
+ export type { LinguiPluginOpts };
package/dist/index.mjs CHANGED
@@ -17,14 +17,6 @@ function lingui({
17
17
  {
18
18
  name: "vite-plugin-lingui-report-macro-error",
19
19
  enforce: "pre",
20
- resolveId(id) {
21
- if (macroIds.has(id)) {
22
- throw new Error(
23
- `The macro you imported from "${id}" is being executed outside the context of compilation.
24
- This indicates that you don't configured correctly one of the "babel-plugin-macros" / "@lingui/swc-plugin" / "babel-plugin-lingui-macro"Please see the documentation for how to configure Vite with Lingui correctly: https://lingui.dev/tutorials/setup-vite`
25
- );
26
- }
27
- },
28
20
  resolveDynamicImport(id, importer) {
29
21
  if (macroIds.has(id)) {
30
22
  throw new Error(
@@ -37,15 +29,6 @@ Please see the documentation for how to configure Vite with Lingui correctly: ht
37
29
  },
38
30
  {
39
31
  name: "vite-plugin-lingui",
40
- config: (config2) => {
41
- if (!config2.optimizeDeps) {
42
- config2.optimizeDeps = {};
43
- }
44
- config2.optimizeDeps.exclude = config2.optimizeDeps.exclude || [];
45
- for (const macroId of macroIds) {
46
- config2.optimizeDeps.exclude.push(macroId);
47
- }
48
- },
49
32
  async transform(src, id) {
50
33
  if (fileRegex.test(id)) {
51
34
  id = id.split("?")[0];
@@ -99,7 +82,7 @@ You see this error because \`failOnMissing=true\` in Vite Plugin configuration.`
99
82
  message + `These errors fail build because \`failOnCompileError=true\` in Lingui Vite plugin configuration.`
100
83
  );
101
84
  } else {
102
- console.warn(
85
+ this.warn(
103
86
  message + `You can fail the build on these errors by setting \`failOnCompileError=true\` in Lingui Vite Plugin configuration.`
104
87
  );
105
88
  }
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@lingui/vite-plugin",
3
- "version": "5.9.0",
3
+ "version": "6.0.0-next.0",
4
4
  "description": "Vite plugin for Lingui message catalogs",
5
- "main": "./dist/index.cjs",
6
- "module": "./dist/index.mjs",
7
- "types": "./dist/index.d.ts",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": "./dist/index.mjs"
8
+ },
8
9
  "sideEffects": false,
9
10
  "license": "MIT",
10
11
  "keywords": [
@@ -20,8 +21,8 @@
20
21
  "multilingual"
21
22
  ],
22
23
  "scripts": {
23
- "build": "rimraf ./dist && unbuild",
24
- "stub": "unbuild --stub"
24
+ "build": "unbuild",
25
+ "check-types": "tsc --noEmit"
25
26
  },
26
27
  "homepage": "https://lingui.dev",
27
28
  "repository": {
@@ -33,7 +34,7 @@
33
34
  "url": "https://github.com/lingui/js-lingui/issues"
34
35
  },
35
36
  "engines": {
36
- "node": ">=20.0.0"
37
+ "node": ">=22.19.0"
37
38
  },
38
39
  "files": [
39
40
  "LICENSE",
@@ -41,18 +42,23 @@
41
42
  "dist/"
42
43
  ],
43
44
  "dependencies": {
44
- "@lingui/cli": "5.9.0",
45
- "@lingui/conf": "5.9.0"
45
+ "@lingui/cli": "6.0.0-next.0",
46
+ "@lingui/conf": "6.0.0-next.0"
46
47
  },
47
48
  "peerDependencies": {
48
49
  "vite": "^3 || ^4 || ^5.0.9 || ^6 || ^7"
49
50
  },
50
51
  "devDependencies": {
51
- "@lingui/core": "^5.9.0",
52
- "@lingui/format-json": "^5.9.0",
53
- "unbuild": "2.0.0",
52
+ "@lingui/core": "^6.0.0-next.0",
53
+ "@lingui/format-json": "^6.0.0-next.0",
54
+ "@lingui/react": "^6.0.0-next.0",
55
+ "unbuild": "3.6.1",
54
56
  "vite": "6.0.2",
55
- "vite-plugin-babel-macros": "^1.0.6"
57
+ "vite-plugin-babel-macros": "^1.0.6",
58
+ "vitest": "4.0.18"
59
+ },
60
+ "unbuild": {
61
+ "declaration": "node16"
56
62
  },
57
- "gitHead": "491d4c17651c3f76116fe7f63f6bb8a554bef8da"
63
+ "gitHead": "a9576050487a4f7dfbc88db20814d5a1bb861c8c"
58
64
  }
package/dist/index.cjs DELETED
@@ -1,127 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const conf = require('@lingui/conf');
6
- const api = require('@lingui/cli/api');
7
- const path = require('path');
8
-
9
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
10
-
11
- const path__default = /*#__PURE__*/_interopDefaultCompat(path);
12
-
13
- const fileRegex = /(\.po|\?lingui)$/;
14
- function lingui({
15
- failOnMissing,
16
- failOnCompileError,
17
- ...linguiConfig
18
- } = {}) {
19
- const config = conf.getConfig(linguiConfig);
20
- const macroIds = /* @__PURE__ */ new Set([
21
- ...config.macro.corePackage,
22
- ...config.macro.jsxPackage
23
- ]);
24
- return [
25
- {
26
- name: "vite-plugin-lingui-report-macro-error",
27
- enforce: "pre",
28
- resolveId(id) {
29
- if (macroIds.has(id)) {
30
- throw new Error(
31
- `The macro you imported from "${id}" is being executed outside the context of compilation.
32
- This indicates that you don't configured correctly one of the "babel-plugin-macros" / "@lingui/swc-plugin" / "babel-plugin-lingui-macro"Please see the documentation for how to configure Vite with Lingui correctly: https://lingui.dev/tutorials/setup-vite`
33
- );
34
- }
35
- },
36
- resolveDynamicImport(id, importer) {
37
- if (macroIds.has(id)) {
38
- throw new Error(
39
- `The macro you imported from "${id}" cannot be dynamically imported.
40
- Please check the import statement in file "${importer}".
41
- Please see the documentation for how to configure Vite with Lingui correctly: https://lingui.dev/tutorials/setup-vite`
42
- );
43
- }
44
- }
45
- },
46
- {
47
- name: "vite-plugin-lingui",
48
- config: (config2) => {
49
- if (!config2.optimizeDeps) {
50
- config2.optimizeDeps = {};
51
- }
52
- config2.optimizeDeps.exclude = config2.optimizeDeps.exclude || [];
53
- for (const macroId of macroIds) {
54
- config2.optimizeDeps.exclude.push(macroId);
55
- }
56
- },
57
- async transform(src, id) {
58
- if (fileRegex.test(id)) {
59
- id = id.split("?")[0];
60
- const catalogRelativePath = path__default.relative(config.rootDir, id);
61
- const fileCatalog = api.getCatalogForFile(
62
- catalogRelativePath,
63
- await api.getCatalogs(config)
64
- );
65
- if (!fileCatalog) {
66
- throw new Error(
67
- `Requested resource ${catalogRelativePath} is not matched to any of your catalogs paths specified in "lingui.config".
68
-
69
- Resource: ${id}
70
-
71
- Your catalogs:
72
- ${config.catalogs.map((c) => c.path).join("\n")}
73
- Please check that catalogs.path is filled properly.
74
- `
75
- );
76
- }
77
- const { locale, catalog } = fileCatalog;
78
- const dependency = await api.getCatalogDependentFiles(catalog, locale);
79
- dependency.forEach((file) => this.addWatchFile(file));
80
- const { messages, missing: missingMessages } = await catalog.getTranslations(locale, {
81
- fallbackLocales: config.fallbackLocales,
82
- sourceLocale: config.sourceLocale
83
- });
84
- if (failOnMissing && locale !== config.pseudoLocale && missingMessages.length > 0) {
85
- const message = api.createMissingErrorMessage(
86
- locale,
87
- missingMessages,
88
- "loader"
89
- );
90
- throw new Error(
91
- `${message}
92
- You see this error because \`failOnMissing=true\` in Vite Plugin configuration.`
93
- );
94
- }
95
- const { source: code, errors } = api.createCompiledCatalog(
96
- locale,
97
- messages,
98
- {
99
- namespace: "es",
100
- pseudoLocale: config.pseudoLocale
101
- }
102
- );
103
- if (errors.length) {
104
- const message = api.createCompilationErrorMessage(locale, errors);
105
- if (failOnCompileError) {
106
- throw new Error(
107
- message + `These errors fail build because \`failOnCompileError=true\` in Lingui Vite plugin configuration.`
108
- );
109
- } else {
110
- console.warn(
111
- message + `You can fail the build on these errors by setting \`failOnCompileError=true\` in Lingui Vite Plugin configuration.`
112
- );
113
- }
114
- }
115
- return {
116
- code,
117
- map: null
118
- // provide source map if available
119
- };
120
- }
121
- }
122
- }
123
- ];
124
- }
125
-
126
- exports.default = lingui;
127
- exports.lingui = lingui;
package/dist/index.d.cts DELETED
@@ -1,18 +0,0 @@
1
- import { Plugin } from 'vite';
2
-
3
- type LinguiPluginOpts = {
4
- cwd?: string;
5
- configPath?: string;
6
- skipValidation?: boolean;
7
- /**
8
- * If true would fail compilation on missing translations
9
- **/
10
- failOnMissing?: boolean;
11
- /**
12
- * If true would fail compilation on message compilation errors
13
- **/
14
- failOnCompileError?: boolean;
15
- };
16
- declare function lingui({ failOnMissing, failOnCompileError, ...linguiConfig }?: LinguiPluginOpts): Plugin[];
17
-
18
- export { type LinguiPluginOpts, lingui as default, lingui };
package/dist/index.d.ts DELETED
@@ -1,18 +0,0 @@
1
- import { Plugin } from 'vite';
2
-
3
- type LinguiPluginOpts = {
4
- cwd?: string;
5
- configPath?: string;
6
- skipValidation?: boolean;
7
- /**
8
- * If true would fail compilation on missing translations
9
- **/
10
- failOnMissing?: boolean;
11
- /**
12
- * If true would fail compilation on message compilation errors
13
- **/
14
- failOnCompileError?: boolean;
15
- };
16
- declare function lingui({ failOnMissing, failOnCompileError, ...linguiConfig }?: LinguiPluginOpts): Plugin[];
17
-
18
- export { type LinguiPluginOpts, lingui as default, lingui };