@open-xchange/rolldown-plugin-i18next-gettext 1.4.2 → 1.4.3
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/CHANGELOG.md +17 -10
- package/README.md +1 -1
- package/dist/index.d.mts +30 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,44 +1,51 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## [1.4.3] - 2026-09-23
|
|
4
|
+
|
|
5
|
+
- fixed: option `srcFiles` is resolved against Vite's resolved `root` option when used as Vite plugin (Vite does not pass its `root` as `cwd` to rolldown); an explicit `build.rolldownOptions.cwd` option takes precedence
|
|
6
|
+
|
|
7
|
+
## [1.4.2] - 2026-09-20
|
|
4
8
|
|
|
5
9
|
- fixed: option `srcFiles` is now resolved against rolldown's resolved `cwd` option
|
|
6
10
|
|
|
7
|
-
##
|
|
11
|
+
## 1.4.1 - 2026-09-13
|
|
8
12
|
|
|
9
13
|
- chore: migrate to gitlab.com
|
|
10
14
|
|
|
11
|
-
##
|
|
15
|
+
## 1.4.0 - 2026-08-07
|
|
12
16
|
|
|
13
17
|
- removed: deprecated option `potFiles`
|
|
14
18
|
- chore: bump dependencies
|
|
15
19
|
|
|
16
|
-
##
|
|
20
|
+
## 1.3.0 - 2026-05-14
|
|
17
21
|
|
|
18
22
|
- changed: require NodeJS v22.18
|
|
19
23
|
|
|
20
|
-
##
|
|
24
|
+
## 1.2.1 - 2026-04-20
|
|
21
25
|
|
|
22
26
|
- fixed: name of option `potFile` for compatibility with old plugin
|
|
23
27
|
|
|
24
|
-
##
|
|
28
|
+
## 1.2.0 - 2026-04-15
|
|
25
29
|
|
|
26
30
|
- added: switched back to direct imports of PO files
|
|
27
31
|
- removed: virtual modules for namespaces
|
|
28
32
|
|
|
29
|
-
##
|
|
33
|
+
## 1.1.0 - 2026-04-15
|
|
30
34
|
|
|
31
35
|
- removed: direct imports of PO files
|
|
32
36
|
- added: allow to group PO files into different namespaces
|
|
33
37
|
|
|
34
|
-
##
|
|
38
|
+
## 1.0.1 - 2026-04-14
|
|
35
39
|
|
|
36
40
|
- fixed: removed debug output
|
|
37
41
|
|
|
38
|
-
##
|
|
42
|
+
## 1.0.0 - 2026-04-13
|
|
39
43
|
|
|
40
44
|
- added: hook filters for improved performance
|
|
41
45
|
|
|
42
|
-
##
|
|
46
|
+
## 0.0.1 - 2026-04-10
|
|
43
47
|
|
|
44
48
|
- initial release
|
|
49
|
+
|
|
50
|
+
[1.4.3]: https://gitlab.com/openxchange/appsuite/documents/commons/plugins/-/compare/rolldown-plugin-i18next-gettext-1.4.2...rolldown-plugin-i18next-gettext-1.4.3
|
|
51
|
+
[1.4.2]: https://gitlab.com/openxchange/appsuite/documents/commons/plugins/-/compare/rolldown-plugin-i18next-gettext-1.4.1...rolldown-plugin-i18next-gettext-1.4.2
|
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ export default defineConfig(() => {
|
|
|
43
43
|
| Name | Type | Default | Description |
|
|
44
44
|
| - | - | - | - |
|
|
45
45
|
| `poFiles` | `string\|string[]` | `**/*.po` | Glob pattern(s) for all PO files to be converted when imported in source code. |
|
|
46
|
-
| `srcFiles` | `string\|string[]` | `src/**/*.{js,jsx,ts,tsx}` | Glob pattern(s) for all source files to be scanned for UI strings for the POT file generator. Resolved against rolldown's resolved `cwd` option. |
|
|
46
|
+
| `srcFiles` | `string\|string[]` | `src/**/*.{js,jsx,ts,tsx}` | Glob pattern(s) for all source files to be scanned for UI strings for the POT file generator. Resolved against rolldown's resolved `cwd` option. When used as Vite plugin without an explicit `build.rolldownOptions.cwd` option, resolved against Vite's resolved `root` option instead. |
|
|
47
47
|
| `potFile` | `string` | `[NAMESPACE].pot` | Path to and filename of the generated POT files, relative to the build output directory. Must contain the placeholder `[NAMESPACE]` if the project contains translation strings in different i18next namespaces. |
|
|
48
48
|
| `projectName` | `string` | _required_ | The project name to be inserted into the POT file under the key 'Project-Id-Version'. May contain the placeholder `[NAMESPACE]` |
|
|
49
49
|
|
package/dist/index.d.mts
CHANGED
|
@@ -15,6 +15,8 @@ export interface PluginI18nextGettextOptions {
|
|
|
15
15
|
/**
|
|
16
16
|
* Glob pattern(s) for all source files to be scanned for UI strings for the
|
|
17
17
|
* POT file generator. Resolved against rolldown's resolved `cwd` option.
|
|
18
|
+
* When used as Vite plugin without an explicit `build.rolldownOptions.cwd`
|
|
19
|
+
* option, resolved against Vite's resolved `root` option instead.
|
|
18
20
|
*
|
|
19
21
|
* @default
|
|
20
22
|
* 'src/**\/*.{js,jsx,ts,tsx}'
|
|
@@ -35,6 +37,32 @@ export interface PluginI18nextGettextOptions {
|
|
|
35
37
|
*/
|
|
36
38
|
projectName: string;
|
|
37
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* The subset of Vite's plugin hooks used by this plugin in addition to the
|
|
42
|
+
* rolldown hooks (declared locally to avoid a dependency on Vite).
|
|
43
|
+
*/
|
|
44
|
+
export interface VitePluginHooks {
|
|
45
|
+
/**
|
|
46
|
+
* Vite hook receiving the resolved Vite configuration. Used to pick up the
|
|
47
|
+
* root directory of the Vite project, because Vite does not pass its `root`
|
|
48
|
+
* option as `cwd` option to rolldown.
|
|
49
|
+
*/
|
|
50
|
+
configResolved?: (config: ViteResolvedConfig) => void;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The subset of Vite's resolved configuration used by this plugin (declared
|
|
54
|
+
* locally to avoid a dependency on Vite).
|
|
55
|
+
*/
|
|
56
|
+
export interface ViteResolvedConfig {
|
|
57
|
+
/** The root directory of the Vite project. */
|
|
58
|
+
root: string;
|
|
59
|
+
/** Build options with the options passed to rolldown. */
|
|
60
|
+
build?: {
|
|
61
|
+
rolldownOptions?: {
|
|
62
|
+
cwd?: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
}
|
|
38
66
|
/**
|
|
39
67
|
* Identifier of this plugin.
|
|
40
68
|
*/
|
|
@@ -46,8 +74,8 @@ export declare const PROJECT_NAME = "@open-xchange/rolldown-plugin-i18next-gette
|
|
|
46
74
|
* Plugin configuration.
|
|
47
75
|
*
|
|
48
76
|
* @returns
|
|
49
|
-
* The rolldown plugin object.
|
|
77
|
+
* The rolldown plugin object (also usable as Vite plugin).
|
|
50
78
|
*/
|
|
51
|
-
export default function pluginI18nextGettext(options: PluginI18nextGettextOptions): Plugin;
|
|
79
|
+
export default function pluginI18nextGettext(options: PluginI18nextGettextOptions): Plugin & VitePluginHooks;
|
|
52
80
|
//#endregion
|
|
53
81
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;iBAWiB;;;;;;;;EASf
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;iBAWiB;;;;;;;;EASf;;;;;;;;;;EAWA;;;;;;;;;EAUA;;;;;EAMA;;;;;;iBAOe;;;;;;EAOf,kBAAkB,QAAQ;;;;;;iBAOX;;EAEf;;EAEA;IAAU;MAAoB;;;;;;;qBAQnB;;;;;;;;;;wBAaW,qBAAqB,SAAS,8BAA8B,SAAS"}
|
package/dist/index.mjs
CHANGED
|
@@ -12,7 +12,7 @@ const PROJECT_NAME = "@open-xchange/rolldown-plugin-i18next-gettext";
|
|
|
12
12
|
* Plugin configuration.
|
|
13
13
|
*
|
|
14
14
|
* @returns
|
|
15
|
-
* The rolldown plugin object.
|
|
15
|
+
* The rolldown plugin object (also usable as Vite plugin).
|
|
16
16
|
*/
|
|
17
17
|
function pluginI18nextGettext(options) {
|
|
18
18
|
const srcFiles = options.srcFiles ?? "src/**/*.{js,jsx,ts,tsx}";
|
|
@@ -21,8 +21,11 @@ function pluginI18nextGettext(options) {
|
|
|
21
21
|
let cwd;
|
|
22
22
|
return {
|
|
23
23
|
name: PROJECT_NAME,
|
|
24
|
+
configResolved(config) {
|
|
25
|
+
if (!config.build?.rolldownOptions?.cwd) cwd = config.root;
|
|
26
|
+
},
|
|
24
27
|
buildStart(inputOptions) {
|
|
25
|
-
cwd
|
|
28
|
+
cwd ??= inputOptions.cwd;
|
|
26
29
|
},
|
|
27
30
|
load: {
|
|
28
31
|
filter: { id: poFiles },
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["\nimport type { Plugin, GeneralHookFilter } from 'rolldown'\nimport { createJsonModule } from '@open-xchange/rolldown-utils'\n\nimport { parsePoFile, parseSourceFiles } from '@open-xchange/i18next-po-parser'\n\n// types ======================================================================\n\n/**\n * Configuration options for the plugin '@open-xchange/rolldown-plugin-i18next-gettext'.\n */\nexport interface PluginI18nextGettextOptions {\n\n /**\n * Glob pattern(s) for all PO files to be converted when imported in source\n * code.\n *\n * @default\n * '**\\/*.po'\n */\n poFiles?: string | readonly string[]\n\n /**\n * Glob pattern(s) for all source files to be scanned for UI strings for the\n * POT file generator. Resolved against rolldown's resolved `cwd` option.\n *\n * @default\n * 'src/**\\/*.{js,jsx,ts,tsx}'\n */\n srcFiles?: string | readonly string[]\n\n /**\n * Path to and filename of the generated POT files, relative to the build\n * output directory. Must contain the placeholder `[NAMESPACE]` if the\n * project contains translation strings in different i18next namespaces.\n *\n * @default\n * '[NAMESPACE].pot'\n */\n potFile?: string\n\n /**\n * The project name to be inserted into the POT files under the key\n * 'Project-Id-Version'. May contain the placeholder `[NAMESPACE]`.\n */\n projectName: string\n}\n\n// constants ==================================================================\n\n/**\n * Identifier of this plugin.\n */\nexport const PROJECT_NAME = '@open-xchange/rolldown-plugin-i18next-gettext'\n\n// plugin =====================================================================\n\n/**\n * Rolldown plugin for using i18next with gettext `.po` files under the hood.\n *\n * @param options\n * Plugin configuration.\n *\n * @returns\n * The rolldown plugin object.\n */\nexport default function pluginI18nextGettext(options: PluginI18nextGettextOptions): Plugin {\n\n // resolve default options\n const srcFiles = options.srcFiles ?? 'src/**/*.{js,jsx,ts,tsx}'\n const poFiles = options.poFiles ?? '**/*.po'\n const potFile = options.potFile ?? '[NAMESPACE].pot'\n\n // the resolved rolldown \"cwd\" option
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["\nimport type { Plugin, GeneralHookFilter } from 'rolldown'\nimport { createJsonModule } from '@open-xchange/rolldown-utils'\n\nimport { parsePoFile, parseSourceFiles } from '@open-xchange/i18next-po-parser'\n\n// types ======================================================================\n\n/**\n * Configuration options for the plugin '@open-xchange/rolldown-plugin-i18next-gettext'.\n */\nexport interface PluginI18nextGettextOptions {\n\n /**\n * Glob pattern(s) for all PO files to be converted when imported in source\n * code.\n *\n * @default\n * '**\\/*.po'\n */\n poFiles?: string | readonly string[]\n\n /**\n * Glob pattern(s) for all source files to be scanned for UI strings for the\n * POT file generator. Resolved against rolldown's resolved `cwd` option.\n * When used as Vite plugin without an explicit `build.rolldownOptions.cwd`\n * option, resolved against Vite's resolved `root` option instead.\n *\n * @default\n * 'src/**\\/*.{js,jsx,ts,tsx}'\n */\n srcFiles?: string | readonly string[]\n\n /**\n * Path to and filename of the generated POT files, relative to the build\n * output directory. Must contain the placeholder `[NAMESPACE]` if the\n * project contains translation strings in different i18next namespaces.\n *\n * @default\n * '[NAMESPACE].pot'\n */\n potFile?: string\n\n /**\n * The project name to be inserted into the POT files under the key\n * 'Project-Id-Version'. May contain the placeholder `[NAMESPACE]`.\n */\n projectName: string\n}\n\n/**\n * The subset of Vite's plugin hooks used by this plugin in addition to the\n * rolldown hooks (declared locally to avoid a dependency on Vite).\n */\nexport interface VitePluginHooks {\n\n /**\n * Vite hook receiving the resolved Vite configuration. Used to pick up the\n * root directory of the Vite project, because Vite does not pass its `root`\n * option as `cwd` option to rolldown.\n */\n configResolved?: (config: ViteResolvedConfig) => void\n}\n\n/**\n * The subset of Vite's resolved configuration used by this plugin (declared\n * locally to avoid a dependency on Vite).\n */\nexport interface ViteResolvedConfig {\n /** The root directory of the Vite project. */\n root: string\n /** Build options with the options passed to rolldown. */\n build?: { rolldownOptions?: { cwd?: string } }\n}\n\n// constants ==================================================================\n\n/**\n * Identifier of this plugin.\n */\nexport const PROJECT_NAME = '@open-xchange/rolldown-plugin-i18next-gettext'\n\n// plugin =====================================================================\n\n/**\n * Rolldown plugin for using i18next with gettext `.po` files under the hood.\n *\n * @param options\n * Plugin configuration.\n *\n * @returns\n * The rolldown plugin object (also usable as Vite plugin).\n */\nexport default function pluginI18nextGettext(options: PluginI18nextGettextOptions): Plugin & VitePluginHooks {\n\n // resolve default options\n const srcFiles = options.srcFiles ?? 'src/**/*.{js,jsx,ts,tsx}'\n const poFiles = options.poFiles ?? '**/*.po'\n const potFile = options.potFile ?? '[NAMESPACE].pot'\n\n // the root directory to resolve the source files against: Vite's resolved\n // \"root\" option (captured in \"configResolved\"), or rolldown's resolved \"cwd\"\n // option (captured in \"buildStart\")\n let cwd: string | undefined\n\n return {\n name: PROJECT_NAME,\n\n // fetch resolved \"root\" option (Vite only, called before \"buildStart\"); an\n // explicit rolldown \"cwd\" option takes precedence (received in \"buildStart\")\n configResolved(config) {\n if (!config.build?.rolldownOptions?.cwd) cwd = config.root\n },\n\n // fetch resolved \"cwd\" option (unless the Vite root is already known)\n buildStart(inputOptions) {\n cwd ??= inputOptions.cwd\n },\n\n // convert PO files to i18next namespace records\n load: {\n filter: { id: poFiles as GeneralHookFilter },\n handler: async id => createJsonModule(await parsePoFile(id)),\n },\n\n // parse source files and create POT files per namespace\n async generateBundle() {\n\n // parse all source files and extract translations\n const catalogs = await parseSourceFiles({ cwd, files: srcFiles, project: options.projectName })\n\n // warn when writing multiple POT files to same file location\n if ((catalogs.size > 1) && !potFile.includes('[NAMESPACE]')) {\n this.error('multiple POT files written to same file location (missing placeholder `[NAMESPACE]` in option potFile)')\n }\n\n // add all POT files as assets to the bundle\n for (const [namespace, source] of catalogs) {\n const fileName = potFile.replaceAll('[NAMESPACE]', namespace)\n this.emitFile({ type: 'asset', fileName, source })\n }\n },\n }\n}\n"],"mappings":";;;;;;AAgFA,MAAa,eAAe;;;;;;;;;;AAa5B,SAAwB,qBAAqB,SAAgE;CAG3G,MAAM,WAAW,QAAQ,YAAY;CACrC,MAAM,UAAU,QAAQ,WAAW;CACnC,MAAM,UAAU,QAAQ,WAAW;CAKnC,IAAI;CAEJ,OAAO;EACL,MAAM;EAIN,eAAe,QAAQ;GACrB,IAAI,CAAC,OAAO,OAAO,iBAAiB,KAAK,MAAM,OAAO;EACxD;EAGA,WAAW,cAAc;GACvB,QAAQ,aAAa;EACvB;EAGA,MAAM;GACJ,QAAQ,EAAE,IAAI,QAA6B;GAC3C,SAAS,OAAM,OAAM,iBAAiB,MAAM,YAAY,EAAE,CAAC;EAC7D;EAGA,MAAM,iBAAiB;GAGrB,MAAM,WAAW,MAAM,iBAAiB;IAAE;IAAK,OAAO;IAAU,SAAS,QAAQ;GAAY,CAAC;GAG9F,IAAK,SAAS,OAAO,KAAM,CAAC,QAAQ,SAAS,aAAa,GACxD,KAAK,MAAM,wGAAwG;GAIrH,KAAK,MAAM,CAAC,WAAW,WAAW,UAAU;IAC1C,MAAM,WAAW,QAAQ,WAAW,eAAe,SAAS;IAC5D,KAAK,SAAS;KAAE,MAAM;KAAS;KAAU;IAAO,CAAC;GACnD;EACF;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-xchange/rolldown-plugin-i18next-gettext",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "Rolldown integration of i18next using gettext PO files",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"CHANGELOG.*"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@open-xchange/i18next-po-parser": "^1.6.
|
|
30
|
+
"@open-xchange/i18next-po-parser": "^1.6.1",
|
|
31
31
|
"@open-xchange/rolldown-utils": "^1.2.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@open-xchange/bundler-testutils": "^2.0.
|
|
34
|
+
"@open-xchange/bundler-testutils": "^2.0.1",
|
|
35
35
|
"@open-xchange/linter-presets": "^1.30.4",
|
|
36
36
|
"@open-xchange/rolldown-plugin-dynamic-import-vars": "^1.3.1",
|
|
37
37
|
"@open-xchange/tsconfig": "^0.2.3",
|