vite-bundled-i18n 0.3.2 → 0.5.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/README.md +100 -14
- package/dist/cli/commands.d.ts +16 -0
- package/dist/cli/index.js +73 -20
- package/dist/cli/index.js.map +1 -1
- package/dist/{compiler-76bzcfdD.js → compiler-DFE3gpoU.js} +283 -21
- package/dist/compiler-DFE3gpoU.js.map +1 -0
- package/dist/core/config.d.ts +23 -0
- package/dist/core/services/key-tracker.d.ts +18 -1
- package/dist/core/types.d.ts +30 -0
- package/dist/{data-BQSxm6Hf.js → data-Yv_f3OCA.js} +53 -14
- package/dist/data-Yv_f3OCA.js.map +1 -0
- package/dist/devtools/panels/footprint.d.ts +1 -1
- package/dist/extractor/bundle-generator.d.ts +7 -0
- package/dist/extractor/cache-config.d.ts +58 -0
- package/dist/extractor/compiler.d.ts +7 -0
- package/dist/extractor/extraction-cache.d.ts +87 -0
- package/dist/extractor/scope-bundles.d.ts +18 -1
- package/dist/extractor/scope-map.d.ts +64 -0
- package/dist/extractor/type-generator.d.ts +2 -2
- package/dist/extractor/walker-types.d.ts +7 -0
- package/dist/extractor/walker.d.ts +2 -0
- package/dist/index.js +3 -3
- package/dist/{mountDevtools-C42c9yW2.js → mountDevtools-CtiMC5PM.js} +30 -8
- package/dist/mountDevtools-CtiMC5PM.js.map +1 -0
- package/dist/plugin/buildPlugin.d.ts +18 -0
- package/dist/plugin/devDiagnostics.d.ts +2 -0
- package/dist/plugin/devPlugin.d.ts +19 -0
- package/dist/plugin/version.d.ts +6 -0
- package/dist/plugin.js +375 -15
- package/dist/plugin.js.map +1 -1
- package/dist/react.js +2 -1
- package/dist/react.js.map +1 -1
- package/dist/{server-q6lgW4Dd.js → server-C0yDN0XT.js} +2 -2
- package/dist/{server-q6lgW4Dd.js.map → server-C0yDN0XT.js.map} +1 -1
- package/dist/server.js +2 -2
- package/dist/vanilla.js +7 -4
- package/dist/vanilla.js.map +1 -1
- package/dist/vue.js +3 -2
- package/dist/vue.js.map +1 -1
- package/package.json +1 -1
- package/dist/compiler-76bzcfdD.js.map +0 -1
- package/dist/data-BQSxm6Hf.js.map +0 -1
- package/dist/mountDevtools-C42c9yW2.js.map +0 -1
package/README.md
CHANGED
|
@@ -22,23 +22,46 @@ Layout.tsx ──→ Dictionary rules ──→ __i18n/en/_dict/glob
|
|
|
22
22
|
Type generation ──→ .i18n/i18n-generated.ts (full autocomplete)
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
1. **Build-time analysis** — AST extractor walks your import graph, finds every `t()`, `useI18n()`, `i18nKey()` call, and maps keys to routes. No code execution needed.
|
|
28
|
-
2. **Bundle generation** — keys are grouped into scope bundles (per-page) and dictionary bundles (shared/global). Each bundle is a static JSON asset or compiled JS module.
|
|
29
|
-
3. **Thin runtime** — minimal `t()` function that loads the right bundle on demand. React, Vue, and vanilla adapters are ~50 lines each.
|
|
25
|
+
The Vite plugin parses your import graph, maps every `t()` / `useI18n()` / `i18nKey()` call to the route that reached it, and emits per-route JSON plus optional compiled `Map` modules. The runtime is a thin `t()` that loads the right bundle on demand. React, Vue, and vanilla adapters all share a ~50-line core.
|
|
30
26
|
|
|
31
27
|
## Features
|
|
32
28
|
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
### What makes it different
|
|
30
|
+
|
|
31
|
+
- **Scope bundles** — each route loads only its own translations in one HTTP request
|
|
32
|
+
- **Page scope map** — framework-neutral `scope-map.json` + typed `PAGE_SCOPE_MAP` const, so any router can parallelize scope loads with component resolution ([router integration](#router-integration))
|
|
33
|
+
- **Cross-namespace packing** (opt-in) — inline a route's cross-namespace keys, tree-shaken, into its scope bundle. 1–3 foreign keys don't force a whole dictionary to load globally
|
|
34
|
+
- **Persistent extraction cache** — per-file AST results survive between runs. Warm dev starts in ~250 ms instead of 3–10 s; repeat builds skip the walk when nothing changed
|
|
35
35
|
- **Progressive autocomplete** — generated types let the IDE suggest one key segment at a time
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
- **
|
|
40
|
-
- **
|
|
41
|
-
- **
|
|
36
|
+
|
|
37
|
+
### Also included
|
|
38
|
+
|
|
39
|
+
- **Dictionary ownership** — named dictionaries claim keys by `include` / `exclude` / `priority`, pinned in memory
|
|
40
|
+
- **Placeholder validation** — `t('cart.total', { amount })` is type-checked against `{{amount}}` in the JSON
|
|
41
|
+
- **Compiled mode** — optional `Map`-based modules for O(1) lookups without JSON parsing
|
|
42
|
+
- **Multi-framework** — React, Vue, vanilla JS share a single core
|
|
43
|
+
- **SSR** — server rendering with automatic client hydration via `window.__I18N_RESOURCES__`
|
|
44
|
+
- **AST extraction** — `t()`, `useI18n()`, `i18nKey()`, `defineI18nData()`, configurable `keyFields`, `as const` objects, string enums, helper functions that receive `t` as a parameter
|
|
45
|
+
- **Dev toolbar** — scope-aware missing-key panel (filters by current route, resets on locale change and HMR), per-namespace bundle efficiency, live updates on navigation
|
|
46
|
+
|
|
47
|
+
## Performance
|
|
48
|
+
|
|
49
|
+
The library is a performance play end-to-end. Representative numbers for a 50-page admin panel with 3,000 translation keys:
|
|
50
|
+
|
|
51
|
+
| | Traditional i18n | vite-bundled-i18n |
|
|
52
|
+
|---|---|---|
|
|
53
|
+
| Keys per page load | 3,000 (all) | 25–40 (route-extracted) |
|
|
54
|
+
| Bundle size per scope | N/A (monolithic) | ~97% smaller than the source namespace |
|
|
55
|
+
| HTTP requests per route | many (or one huge) | 1 scope bundle + cached dictionaries |
|
|
56
|
+
| Cold dev start | — | ~200 ms |
|
|
57
|
+
| Warm dev start | — | ~250 ms (extraction cache keeps prior AST parses) |
|
|
58
|
+
| Repeat `vite build`, unchanged code | full walk | near-zero parse (cache-hit, stat-only) |
|
|
59
|
+
| HMR key edit → browser refetch | full re-walk | ~30 ms (surgical cache update) |
|
|
60
|
+
| Compiled-mode `t('key')` | JSON parse + path traversal | O(1) `Map.get` |
|
|
61
|
+
|
|
62
|
+
The extraction cache persists to `.i18n/cache/` and auto-invalidates on plugin upgrade, config change, or Node major version change. Disable with `cache: false` or `VITE_I18N_NO_CACHE=1`. See [API docs — Extraction cache](./docs/api.md#extraction-cache-cache).
|
|
63
|
+
|
|
64
|
+
Compiled mode replaces JSON parsing with pre-resolved flat `Map` modules. Faster than JSON at the browser level (no parse on first lookup), smaller gzipped (shared string pool), cacheable by the browser's module loader. Falls back to JSON automatically when compiled modules aren't available.
|
|
42
65
|
|
|
43
66
|
## Setup
|
|
44
67
|
|
|
@@ -152,6 +175,56 @@ function ProductsPage() {
|
|
|
152
175
|
|
|
153
176
|
**Navigation lifecycle:** The provider persists across page navigations (Inertia, React Router, Next.js). Dictionaries load once. Each page scope loads on mount — only the page content waits, not the layout.
|
|
154
177
|
|
|
178
|
+
## Router Integration
|
|
179
|
+
|
|
180
|
+
`useI18n('products.show')` triggers the scope load on mount — but mount only happens *after* the router has resolved the matched component. On slow connections this serializes the scope fetch behind the component chunk. `PAGE_SCOPE_MAP` unblocks this: the scope list for every page is a build-time constant, fully typed, importable anywhere.
|
|
181
|
+
|
|
182
|
+
Combine it with your router's async page-resolve hook and `Promise.all` so both promises race in parallel:
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
import {
|
|
186
|
+
PAGE_SCOPE_MAP,
|
|
187
|
+
type I18nPageIdentifier,
|
|
188
|
+
} from 'vite-bundled-i18n/generated'
|
|
189
|
+
import { i18n } from './i18n'
|
|
190
|
+
|
|
191
|
+
// Sketch — adapt to your router's resolve API
|
|
192
|
+
async function resolvePage(
|
|
193
|
+
pageId: I18nPageIdentifier,
|
|
194
|
+
loadComponent: () => Promise<unknown>,
|
|
195
|
+
) {
|
|
196
|
+
const scopes = PAGE_SCOPE_MAP[pageId]
|
|
197
|
+
const locale = i18n.getLocale()
|
|
198
|
+
await Promise.all([
|
|
199
|
+
loadComponent(),
|
|
200
|
+
...scopes.map((scope) => i18n.loadScope(locale, scope)),
|
|
201
|
+
])
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Calling `loadScope` is safe from concurrent paths. The runtime deduplicates by `(locale, scope)` — 100 parallel calls fire exactly one fetch, share the same promise, and resolve together. On fetch failure the in-flight entry clears, so a retry starts fresh. Side effects (cache writes, devbar state, dependent scope flags) run once per logical load, not once per caller.
|
|
206
|
+
|
|
207
|
+
**Page identifiers.** The default strips `src/pages/` and common `.tsx` / `.page.tsx` suffixes:
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
src/pages/giftcards/show.tsx → 'giftcards/show'
|
|
211
|
+
src/pages/products/show.page.tsx → 'products/show'
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
When your router exposes a different token at runtime, override:
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
i18nPlugin(config, {
|
|
218
|
+
pages: ['admin/**/pages/*.tsx'],
|
|
219
|
+
locales: ['en'],
|
|
220
|
+
defaultLocale: 'en',
|
|
221
|
+
pageIdentifier: (abs) =>
|
|
222
|
+
abs.replace(/^.*?\/admin\//, 'admin/').replace(/\.tsx$/, ''),
|
|
223
|
+
})
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Whatever your function returns becomes the key in `scope-map.json` (served at `/__i18n/scope-map.json` in dev, emitted at build under `assetsDir`) and the `I18nPageIdentifier` union in generated types. Routers that want the data without types can fetch the JSON directly.
|
|
227
|
+
|
|
155
228
|
## Vue
|
|
156
229
|
|
|
157
230
|
```ts
|
|
@@ -231,6 +304,8 @@ Traditional i18n ships every translation key to every page. `vite-bundled-i18n`
|
|
|
231
304
|
|
|
232
305
|
4. **Dictionary bundles are not tree-shaken** — they include all keys matching the `include`/`exclude` patterns. Dictionaries are the "always available" layer for shared UI (nav, actions, validation). Tree-shaking only applies to scope bundles.
|
|
233
306
|
|
|
307
|
+
5. **Cross-namespace packing** (opt-in via `bundling.crossNamespacePacking: true`) — when a route references a handful of keys from a foreign namespace (e.g. `giftcards.show` uses `vendors.compact.name` once), those keys are tree-shaken and inlined into the scope bundle. One HTTP request covers everything the route needs. Keys already owned by a dictionary are skipped so the global layer isn't duplicated. Dev middleware mirrors the behavior by serving cross-namespace extras alongside each scope request, so dev and production resolve keys identically. See [API docs](./docs/api.md#bundlingcrossnamespacepacking) for the emitted shape.
|
|
308
|
+
|
|
234
309
|
### What you get
|
|
235
310
|
|
|
236
311
|
```
|
|
@@ -255,6 +330,7 @@ The build generates reports that show exactly what was extracted, what's missing
|
|
|
255
330
|
- `unused.json` — keys in locale files that no route references (candidates for removal)
|
|
256
331
|
- `stats.json` — per-route and per-namespace extraction statistics
|
|
257
332
|
- `ownership.json` — which dictionary owns which key, with collision data
|
|
333
|
+
- `scope-map.json` — framework-neutral `page id → { scopes, dictionaries }` index ([router integration](#router-integration))
|
|
258
334
|
|
|
259
335
|
### Edge cases
|
|
260
336
|
|
|
@@ -265,6 +341,7 @@ Keys that the AST extractor **cannot see** (dynamic concatenation, computed keys
|
|
|
265
341
|
```
|
|
266
342
|
__i18n/{locale}/_dict/{name}.json — dictionary bundles (JSON)
|
|
267
343
|
__i18n/{locale}/{scope}.json — scope bundles (JSON)
|
|
344
|
+
__i18n/scope-map.json — page id → scopes index
|
|
268
345
|
__i18n/compiled/manifest.js — compiled module manifest
|
|
269
346
|
__i18n/compiled/{locale}/... — compiled Map modules (optional)
|
|
270
347
|
```
|
|
@@ -287,7 +364,9 @@ React and Vue adapters detect and consume the hydrated data automatically.
|
|
|
287
364
|
|
|
288
365
|
Translation bundles are served via Vite middleware — no files written to disk. Types regenerate on locale file changes. The dev toolbar updates live on navigation.
|
|
289
366
|
|
|
290
|
-
|
|
367
|
+
**Dev toolbar behavior (v0.4.0+).** Missing-key entries are tagged with the current scope and a monotonic epoch. Navigating between pages automatically filters the "Missing Translations" panel to show only misses from the current route. Changing locale bumps the epoch so prior entries clear. HMR updates reset key-usage state automatically — editing a file doesn't leave stale misses behind.
|
|
368
|
+
|
|
369
|
+
**Sidecar setups** (Laravel serving assets from public/):
|
|
291
370
|
|
|
292
371
|
```ts
|
|
293
372
|
i18nPlugin(i18nConfig, {
|
|
@@ -348,6 +427,7 @@ cache: {
|
|
|
348
427
|
| `vite-bundled-i18n/vanilla` | `getTranslations`, `initI18n` |
|
|
349
428
|
| `vite-bundled-i18n/server` | `initServerI18n` (SSR) |
|
|
350
429
|
| `vite-bundled-i18n/plugin` | Vite plugin (`i18nPlugin`) |
|
|
430
|
+
| `vite-bundled-i18n/generated` | Generated types + `PAGE_SCOPE_MAP` / `I18nPageIdentifier` |
|
|
351
431
|
|
|
352
432
|
## Documentation
|
|
353
433
|
|
|
@@ -355,6 +435,12 @@ cache: {
|
|
|
355
435
|
- [API Reference](./docs/api.md)
|
|
356
436
|
- [Architecture](./docs/architecture.md)
|
|
357
437
|
|
|
438
|
+
## Releases
|
|
439
|
+
|
|
440
|
+
Current release: **v0.5.0** — persistent extraction cache, framework-neutral page scope map, typed `PAGE_SCOPE_MAP`, `loadScope` concurrency guarantees.
|
|
441
|
+
|
|
442
|
+
Version history lives in the [git log](https://github.com/nicolasvlachos/vite-bundled-i18n/commits/main) — each release is a `feat: v{version}` commit with a summary of the changes.
|
|
443
|
+
|
|
358
444
|
## License
|
|
359
445
|
|
|
360
446
|
[MIT](./LICENSE)
|
package/dist/cli/commands.d.ts
CHANGED
|
@@ -21,6 +21,22 @@ export interface CliConfig {
|
|
|
21
21
|
dictionaries?: Record<string, DictionaryConfig>;
|
|
22
22
|
/** Additional module specifiers that export `useI18n`. */
|
|
23
23
|
hookSources?: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Inline cross-namespace keys (tree-shaken) into each scope bundle.
|
|
26
|
+
* See `I18nSharedConfig.bundling.crossNamespacePacking`.
|
|
27
|
+
*/
|
|
28
|
+
crossNamespacePacking?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Extraction cache control. `false` disables, an object configures the
|
|
31
|
+
* backing directory and persistence. Env vars (`VITE_I18N_NO_CACHE`,
|
|
32
|
+
* `VITE_I18N_CLEAR_CACHE`, `VITE_I18N_CACHE_DEBUG`) always take
|
|
33
|
+
* precedence. See `resolveCacheConfig`.
|
|
34
|
+
*/
|
|
35
|
+
cache?: boolean | {
|
|
36
|
+
enabled?: boolean;
|
|
37
|
+
dir?: string;
|
|
38
|
+
persist?: boolean;
|
|
39
|
+
};
|
|
24
40
|
}
|
|
25
41
|
/**
|
|
26
42
|
* Run the walker and print a summary table to stdout.
|
package/dist/cli/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as generateReports,
|
|
2
|
+
import { a as createExtractionCache, d as generateReports, h as generateBundles, i as computeConfigHash, l as flattenLocaleKeys, n as PLUGIN_VERSION, p as writeTypes, r as resolveCacheConfig, s as walkAll, t as compileAll } from "../compiler-DFE3gpoU.js";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
//#region src/cli/commands.ts
|
|
@@ -14,7 +14,34 @@ function resolveConfig(config) {
|
|
|
14
14
|
extractionScope: config.extractionScope ?? "global"
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function buildCliCache(config, rootDir) {
|
|
18
|
+
const cacheSettings = resolveCacheConfig(config.cache, { rootDir });
|
|
19
|
+
if (!cacheSettings.enabled) return void 0;
|
|
20
|
+
if (cacheSettings.clearBeforeStart) try {
|
|
21
|
+
fs.rmSync(cacheSettings.dir, {
|
|
22
|
+
recursive: true,
|
|
23
|
+
force: true
|
|
24
|
+
});
|
|
25
|
+
} catch {}
|
|
26
|
+
return createExtractionCache({
|
|
27
|
+
dir: cacheSettings.dir,
|
|
28
|
+
pluginVersion: PLUGIN_VERSION,
|
|
29
|
+
configHash: computeConfigHash({
|
|
30
|
+
pages: config.pages,
|
|
31
|
+
defaultLocale: config.defaultLocale,
|
|
32
|
+
extractionScope: config.extractionScope ?? "global",
|
|
33
|
+
hookSources: config.hookSources,
|
|
34
|
+
dictionaries: config.dictionaries,
|
|
35
|
+
crossNamespacePacking: config.crossNamespacePacking
|
|
36
|
+
}),
|
|
37
|
+
debug: cacheSettings.debug
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function persistCache(config, cache, rootDir) {
|
|
41
|
+
if (!cache) return;
|
|
42
|
+
if (resolveCacheConfig(config.cache, { rootDir }).persist) cache.persistToDisk();
|
|
43
|
+
}
|
|
44
|
+
function runWalker(config, cache) {
|
|
18
45
|
const { rootDir, localesDir, extractionScope } = resolveConfig(config);
|
|
19
46
|
return walkAll({
|
|
20
47
|
pages: config.pages,
|
|
@@ -22,7 +49,8 @@ function runWalker(config) {
|
|
|
22
49
|
localesDir,
|
|
23
50
|
defaultLocale: config.defaultLocale,
|
|
24
51
|
extractionScope,
|
|
25
|
-
hookSources: config.hookSources
|
|
52
|
+
hookSources: config.hookSources,
|
|
53
|
+
cache
|
|
26
54
|
});
|
|
27
55
|
}
|
|
28
56
|
function collectScopeNames(analysis) {
|
|
@@ -54,8 +82,10 @@ function printTable(headers, rows) {
|
|
|
54
82
|
* Returns the ProjectAnalysis for programmatic use.
|
|
55
83
|
*/
|
|
56
84
|
function analyze(config) {
|
|
57
|
-
const { localesDir } = resolveConfig(config);
|
|
58
|
-
const
|
|
85
|
+
const { rootDir, localesDir } = resolveConfig(config);
|
|
86
|
+
const cache = buildCliCache(config, rootDir);
|
|
87
|
+
const analysis = runWalker(config, cache);
|
|
88
|
+
persistCache(config, cache, rootDir);
|
|
59
89
|
const availableKeys = flattenLocaleKeys(localesDir, config.defaultLocale);
|
|
60
90
|
const totalAvailable = Array.from(availableKeys.values()).reduce((sum, keys) => sum + keys.length, 0);
|
|
61
91
|
printTable([
|
|
@@ -80,12 +110,15 @@ function analyze(config) {
|
|
|
80
110
|
* Prints what was generated to stdout.
|
|
81
111
|
*/
|
|
82
112
|
function generate(config) {
|
|
83
|
-
const { outDir, typesOutPath, localesDir } = resolveConfig(config);
|
|
84
|
-
const
|
|
113
|
+
const { rootDir, outDir, typesOutPath, localesDir } = resolveConfig(config);
|
|
114
|
+
const cache = buildCliCache(config, rootDir);
|
|
115
|
+
const analysis = runWalker(config, cache);
|
|
116
|
+
persistCache(config, cache, rootDir);
|
|
85
117
|
const bundles = generateBundles(analysis, {
|
|
86
118
|
localesDir,
|
|
87
119
|
locales: config.locales,
|
|
88
|
-
outDir
|
|
120
|
+
outDir,
|
|
121
|
+
crossNamespacePacking: config.crossNamespacePacking
|
|
89
122
|
});
|
|
90
123
|
writeTypes(localesDir, config.defaultLocale, typesOutPath, collectScopeNames(analysis));
|
|
91
124
|
console.log(`Generated ${bundles.length} bundle(s):`);
|
|
@@ -97,8 +130,11 @@ function generate(config) {
|
|
|
97
130
|
* Prints summary to stdout.
|
|
98
131
|
*/
|
|
99
132
|
function report(config) {
|
|
100
|
-
const { outDir, localesDir } = resolveConfig(config);
|
|
101
|
-
|
|
133
|
+
const { rootDir, outDir, localesDir } = resolveConfig(config);
|
|
134
|
+
const cache = buildCliCache(config, rootDir);
|
|
135
|
+
const analysis = runWalker(config, cache);
|
|
136
|
+
persistCache(config, cache, rootDir);
|
|
137
|
+
generateReports(analysis, localesDir, config.defaultLocale, outDir, config.dictionaries);
|
|
102
138
|
console.log(`Reports written to ${outDir}:`);
|
|
103
139
|
console.log(" manifest.json");
|
|
104
140
|
console.log(" missing.json");
|
|
@@ -110,15 +146,18 @@ function report(config) {
|
|
|
110
146
|
* Prints a summary to stdout.
|
|
111
147
|
*/
|
|
112
148
|
function compile(config) {
|
|
113
|
-
const { outDir, localesDir } = resolveConfig(config);
|
|
114
|
-
const
|
|
149
|
+
const { rootDir, outDir, localesDir } = resolveConfig(config);
|
|
150
|
+
const cache = buildCliCache(config, rootDir);
|
|
151
|
+
const analysis = runWalker(config, cache);
|
|
152
|
+
persistCache(config, cache, rootDir);
|
|
115
153
|
const compiledOutDir = path.join(outDir, "compiled");
|
|
116
154
|
compileAll(analysis, {
|
|
117
155
|
localesDir,
|
|
118
156
|
locales: config.locales,
|
|
119
157
|
defaultLocale: config.defaultLocale,
|
|
120
158
|
outDir: compiledOutDir,
|
|
121
|
-
dictionaries: config.dictionaries
|
|
159
|
+
dictionaries: config.dictionaries,
|
|
160
|
+
crossNamespacePacking: config.crossNamespacePacking
|
|
122
161
|
});
|
|
123
162
|
const total = analysis.routes.length * config.locales.length + (config.dictionaries && Object.keys(config.dictionaries).length > 0 ? config.locales.length : 0) + 1;
|
|
124
163
|
console.log(`Compiled ${total} module(s) to ${compiledOutDir}`);
|
|
@@ -127,8 +166,10 @@ function compile(config) {
|
|
|
127
166
|
* Run analyze + generate + compile + report all at once.
|
|
128
167
|
*/
|
|
129
168
|
function build(config) {
|
|
130
|
-
const { outDir, typesOutPath, localesDir } = resolveConfig(config);
|
|
131
|
-
const
|
|
169
|
+
const { rootDir, outDir, typesOutPath, localesDir } = resolveConfig(config);
|
|
170
|
+
const cache = buildCliCache(config, rootDir);
|
|
171
|
+
const analysis = runWalker(config, cache);
|
|
172
|
+
persistCache(config, cache, rootDir);
|
|
132
173
|
const availableKeys = flattenLocaleKeys(localesDir, config.defaultLocale);
|
|
133
174
|
const totalAvailable = Array.from(availableKeys.values()).reduce((sum, keys) => sum + keys.length, 0);
|
|
134
175
|
printTable([
|
|
@@ -148,7 +189,8 @@ function build(config) {
|
|
|
148
189
|
const bundles = generateBundles(analysis, {
|
|
149
190
|
localesDir,
|
|
150
191
|
locales: config.locales,
|
|
151
|
-
outDir
|
|
192
|
+
outDir,
|
|
193
|
+
crossNamespacePacking: config.crossNamespacePacking
|
|
152
194
|
});
|
|
153
195
|
writeTypes(localesDir, config.defaultLocale, typesOutPath, collectScopeNames(analysis));
|
|
154
196
|
console.log(`\nGenerated ${bundles.length} bundle(s)`);
|
|
@@ -159,7 +201,8 @@ function build(config) {
|
|
|
159
201
|
locales: config.locales,
|
|
160
202
|
defaultLocale: config.defaultLocale,
|
|
161
203
|
outDir: compiledOutDir,
|
|
162
|
-
dictionaries: config.dictionaries
|
|
204
|
+
dictionaries: config.dictionaries,
|
|
205
|
+
crossNamespacePacking: config.crossNamespacePacking
|
|
163
206
|
});
|
|
164
207
|
console.log(`Compiled modules written to ${compiledOutDir}`);
|
|
165
208
|
generateReports(analysis, localesDir, config.defaultLocale, outDir, config.dictionaries);
|
|
@@ -176,7 +219,7 @@ var COMMANDS = [
|
|
|
176
219
|
"build"
|
|
177
220
|
];
|
|
178
221
|
function printUsage() {
|
|
179
|
-
console.log("Usage: vite-bundled-i18n <command> [
|
|
222
|
+
console.log("Usage: vite-bundled-i18n <command> [options]");
|
|
180
223
|
console.log("");
|
|
181
224
|
console.log("Commands:");
|
|
182
225
|
console.log(" analyze — Walk imports and print a summary of key usage per route");
|
|
@@ -187,6 +230,8 @@ function printUsage() {
|
|
|
187
230
|
console.log("");
|
|
188
231
|
console.log("Options:");
|
|
189
232
|
console.log(" --config <path> Path to config file (default: i18n.config.json)");
|
|
233
|
+
console.log(" --no-cache Disable the extraction cache for this run");
|
|
234
|
+
console.log(" --clear-cache Clear the extraction cache before running");
|
|
190
235
|
}
|
|
191
236
|
function loadConfig(configPath) {
|
|
192
237
|
const resolved = path.resolve(configPath);
|
|
@@ -201,9 +246,13 @@ function parseArgs(argv) {
|
|
|
201
246
|
const args = argv.slice(2);
|
|
202
247
|
let command;
|
|
203
248
|
let configPath = "i18n.config.json";
|
|
249
|
+
let noCache = false;
|
|
250
|
+
let clearCache = false;
|
|
204
251
|
for (let i = 0; i < args.length; i++) {
|
|
205
252
|
const arg = args[i];
|
|
206
253
|
if (arg === "--config" && i + 1 < args.length) configPath = args[++i];
|
|
254
|
+
else if (arg === "--no-cache") noCache = true;
|
|
255
|
+
else if (arg === "--clear-cache") clearCache = true;
|
|
207
256
|
else if (arg === "--help" || arg === "-h") {
|
|
208
257
|
printUsage();
|
|
209
258
|
process.exit(0);
|
|
@@ -220,11 +269,15 @@ function parseArgs(argv) {
|
|
|
220
269
|
}
|
|
221
270
|
return {
|
|
222
271
|
command,
|
|
223
|
-
configPath
|
|
272
|
+
configPath,
|
|
273
|
+
noCache,
|
|
274
|
+
clearCache
|
|
224
275
|
};
|
|
225
276
|
}
|
|
226
|
-
var { command, configPath } = parseArgs(process.argv);
|
|
277
|
+
var { command, configPath, noCache, clearCache } = parseArgs(process.argv);
|
|
227
278
|
var config = loadConfig(configPath);
|
|
279
|
+
if (noCache) config.cache = false;
|
|
280
|
+
if (clearCache) process.env.VITE_I18N_CLEAR_CACHE = "1";
|
|
228
281
|
({
|
|
229
282
|
analyze,
|
|
230
283
|
generate,
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/cli/commands.ts","../../src/cli/index.ts"],"sourcesContent":["import path from 'node:path';\nimport { walkAll } from '../extractor/walker';\nimport { generateBundles } from '../extractor/bundle-generator';\nimport { writeTypes } from '../extractor/type-generator';\nimport { generateReports } from '../extractor/reports';\nimport { compileAll } from '../extractor/compiler';\nimport type { ProjectAnalysis } from '../extractor/walker-types';\nimport type { DictionaryConfig } from '../core/types';\nimport { flattenLocaleKeys } from '../extractor/reports';\n\nexport interface CliConfig {\n /** Glob patterns for page entry points. */\n pages: string[];\n /** Locales directory (relative to rootDir). */\n localesDir: string;\n /** All supported locale codes. */\n locales: string[];\n /** Default locale. */\n defaultLocale: string;\n /** Root directory. Defaults to process.cwd(). */\n rootDir?: string;\n /** Output directory for generated bundles. Defaults to '.i18n'. */\n outDir?: string;\n /** Output path for generated types. Defaults to '.i18n/i18n.d.ts'. */\n typesOutPath?: string;\n /** Extraction scope. Defaults to 'global'. */\n extractionScope?: 'global' | 'scoped';\n /** Optional dictionary configurations for compiled mode. */\n dictionaries?: Record<string, DictionaryConfig>;\n /** Additional module specifiers that export `useI18n`. */\n hookSources?: string[];\n}\n\nfunction resolveConfig(config: CliConfig) {\n const rootDir = config.rootDir ?? process.cwd();\n const outDir = config.outDir ?? path.join(rootDir, '.i18n');\n const typesOutPath =\n config.typesOutPath ?? path.join(outDir, 'i18n-generated.ts');\n const localesDir = path.isAbsolute(config.localesDir)\n ? config.localesDir\n : path.join(rootDir, config.localesDir);\n const extractionScope = config.extractionScope ?? 'global';\n\n return { rootDir, outDir, typesOutPath, localesDir, extractionScope } as const;\n}\n\nfunction runWalker(config: CliConfig): ProjectAnalysis {\n const { rootDir, localesDir, extractionScope } = resolveConfig(config);\n\n return walkAll({\n pages: config.pages,\n rootDir,\n localesDir,\n defaultLocale: config.defaultLocale,\n extractionScope,\n hookSources: config.hookSources,\n });\n}\n\nfunction collectScopeNames(analysis: ProjectAnalysis): string[] {\n return [...new Set(analysis.routes.flatMap((route) => route.scopes))].sort();\n}\n\n/**\n * Pad a string to the given width.\n */\nfunction pad(str: string, width: number): string {\n return str + ' '.repeat(Math.max(0, width - str.length));\n}\n\n/**\n * Print a simple ASCII table to stdout.\n */\nfunction printTable(\n headers: string[],\n rows: string[][],\n): void {\n const colWidths = headers.map((h, i) =>\n Math.max(h.length, ...rows.map((r) => (r[i] ?? '').length)),\n );\n\n const sep =\n '\\u250c' +\n colWidths.map((w) => '\\u2500'.repeat(w + 2)).join('\\u252c') +\n '\\u2510';\n const mid =\n '\\u251c' +\n colWidths.map((w) => '\\u2500'.repeat(w + 2)).join('\\u253c') +\n '\\u2524';\n const bot =\n '\\u2514' +\n colWidths.map((w) => '\\u2500'.repeat(w + 2)).join('\\u2534') +\n '\\u2518';\n\n const formatRow = (cells: string[]) =>\n '\\u2502' +\n cells.map((c, i) => ' ' + pad(c, colWidths[i]) + ' ').join('\\u2502') +\n '\\u2502';\n\n console.log(sep);\n console.log(formatRow(headers));\n console.log(mid);\n for (const row of rows) {\n console.log(formatRow(row));\n }\n console.log(bot);\n}\n\n/**\n * Run the walker and print a summary table to stdout.\n * Returns the ProjectAnalysis for programmatic use.\n */\nexport function analyze(config: CliConfig): ProjectAnalysis {\n const { localesDir } = resolveConfig(config);\n const analysis = runWalker(config);\n\n const availableKeys = flattenLocaleKeys(localesDir, config.defaultLocale);\n const totalAvailable = Array.from(availableKeys.values()).reduce(\n (sum, keys) => sum + keys.length,\n 0,\n );\n\n const rows = analysis.routes.map((route) => {\n const usedCount = route.keys.filter((k) => !k.dynamic).length;\n return [\n route.routeId,\n String(usedCount),\n String(totalAvailable),\n String(totalAvailable - usedCount),\n ];\n });\n\n printTable(['Route', 'Used Keys', 'Available', 'Pruned'], rows);\n\n console.log(\n `\\n${analysis.routes.length} route(s), ${analysis.allKeys.length} unique key(s), ${analysis.availableNamespaces.length} namespace(s)`,\n );\n\n return analysis;\n}\n\n/**\n * Run the walker, then generate bundles and types.\n * Prints what was generated to stdout.\n */\nexport function generate(config: CliConfig): void {\n const { outDir, typesOutPath, localesDir } = resolveConfig(config);\n const analysis = runWalker(config);\n\n const bundles = generateBundles(analysis, {\n localesDir,\n locales: config.locales,\n outDir,\n });\n\n writeTypes(localesDir, config.defaultLocale, typesOutPath, collectScopeNames(analysis));\n\n console.log(`Generated ${bundles.length} bundle(s):`);\n for (const b of bundles) {\n console.log(` ${b.locale}/${b.name} — ${b.keyCount} keys (${b.prunedCount} pruned)`);\n }\n console.log(`Types written to ${typesOutPath}`);\n}\n\n/**\n * Run the walker, then generate diagnostic reports.\n * Prints summary to stdout.\n */\nexport function report(config: CliConfig): void {\n const { outDir, localesDir } = resolveConfig(config);\n const analysis = runWalker(config);\n\n generateReports(analysis, localesDir, config.defaultLocale, outDir, config.dictionaries);\n\n console.log(`Reports written to ${outDir}:`);\n console.log(' manifest.json');\n console.log(' missing.json');\n console.log(' unused.json');\n console.log(' stats.json');\n}\n\n/**\n * Run the walker, then compile pre-resolved flat Map modules.\n * Prints a summary to stdout.\n */\nexport function compile(config: CliConfig): void {\n const { outDir, localesDir } = resolveConfig(config);\n const analysis = runWalker(config);\n const compiledOutDir = path.join(outDir, 'compiled');\n\n compileAll(analysis, {\n localesDir,\n locales: config.locales,\n defaultLocale: config.defaultLocale,\n outDir: compiledOutDir,\n dictionaries: config.dictionaries,\n });\n\n // Count generated modules: one per route per locale, plus dictionary modules\n const routeModules = analysis.routes.length * config.locales.length;\n const dictModules =\n config.dictionaries && Object.keys(config.dictionaries).length > 0\n ? config.locales.length\n : 0;\n const total = routeModules + dictModules + 1; // +1 for manifest\n\n console.log(`Compiled ${total} module(s) to ${compiledOutDir}`);\n}\n\n/**\n * Run analyze + generate + compile + report all at once.\n */\nexport function build(config: CliConfig): void {\n const { outDir, typesOutPath, localesDir } = resolveConfig(config);\n const analysis = runWalker(config);\n\n // Analyze: print table\n const availableKeys = flattenLocaleKeys(localesDir, config.defaultLocale);\n const totalAvailable = Array.from(availableKeys.values()).reduce(\n (sum, keys) => sum + keys.length,\n 0,\n );\n\n const rows = analysis.routes.map((route) => {\n const usedCount = route.keys.filter((k) => !k.dynamic).length;\n return [\n route.routeId,\n String(usedCount),\n String(totalAvailable),\n String(totalAvailable - usedCount),\n ];\n });\n\n printTable(['Route', 'Used Keys', 'Available', 'Pruned'], rows);\n\n // Generate bundles + types\n const bundles = generateBundles(analysis, {\n localesDir,\n locales: config.locales,\n outDir,\n });\n\n writeTypes(localesDir, config.defaultLocale, typesOutPath, collectScopeNames(analysis));\n\n console.log(`\\nGenerated ${bundles.length} bundle(s)`);\n console.log(`Types written to ${typesOutPath}`);\n\n // Compile\n const compiledOutDir = path.join(outDir, 'compiled');\n compileAll(analysis, {\n localesDir,\n locales: config.locales,\n defaultLocale: config.defaultLocale,\n outDir: compiledOutDir,\n dictionaries: config.dictionaries,\n });\n console.log(`Compiled modules written to ${compiledOutDir}`);\n\n // Reports\n generateReports(analysis, localesDir, config.defaultLocale, outDir, config.dictionaries);\n\n console.log(`Reports written to ${outDir}`);\n console.log(\n `\\nDone. ${analysis.routes.length} route(s), ${analysis.allKeys.length} unique key(s).`,\n );\n}\n","#!/usr/bin/env node\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { analyze, generate, compile, report, build } from './commands';\nimport type { CliConfig } from './commands';\n\nconst COMMANDS = ['analyze', 'generate', 'compile', 'report', 'build'] as const;\ntype Command = (typeof COMMANDS)[number];\n\nfunction printUsage(): void {\n console.log('Usage: vite-bundled-i18n <command> [--config <path>]');\n console.log('');\n console.log('Commands:');\n console.log(' analyze — Walk imports and print a summary of key usage per route');\n console.log(' generate — Generate tree-shaken bundles and TypeScript types');\n console.log(' report — Generate diagnostic reports (manifest, missing, unused, stats)');\n console.log(' compile — Compile pre-resolved flat Map modules for production');\n console.log(' build — Run analyze + generate + compile + report in one step');\n console.log('');\n console.log('Options:');\n console.log(' --config <path> Path to config file (default: i18n.config.json)');\n}\n\nfunction loadConfig(configPath: string): CliConfig {\n const resolved = path.resolve(configPath);\n if (!fs.existsSync(resolved)) {\n console.error(`Config file not found: ${resolved}`);\n process.exit(1);\n }\n\n const raw = fs.readFileSync(resolved, 'utf-8');\n return JSON.parse(raw) as CliConfig;\n}\n\nfunction parseArgs(argv: string[]): { command: Command; configPath: string } {\n const args = argv.slice(2);\n let command: Command | undefined;\n let configPath = 'i18n.config.json';\n\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n if (arg === '--config' && i + 1 < args.length) {\n configPath = args[++i];\n } else if (arg === '--help' || arg === '-h') {\n printUsage();\n process.exit(0);\n } else if (!command && COMMANDS.includes(arg as Command)) {\n command = arg as Command;\n } else {\n console.error(`Unknown argument: ${arg}`);\n printUsage();\n process.exit(1);\n }\n }\n\n if (!command) {\n printUsage();\n process.exit(1);\n }\n\n return { command: command!, configPath };\n}\n\nconst { command, configPath } = parseArgs(process.argv);\nconst config = loadConfig(configPath);\n\nconst commands: Record<Command, (cfg: CliConfig) => void> = {\n analyze,\n generate,\n compile,\n report,\n build,\n};\n\ncommands[command](config);\n"],"mappings":";;;;;AAiCA,SAAS,cAAc,QAAmB;CACxC,MAAM,UAAU,OAAO,WAAW,QAAQ,KAAK;CAC/C,MAAM,SAAS,OAAO,UAAU,KAAK,KAAK,SAAS,QAAQ;AAQ3D,QAAO;EAAE;EAAS;EAAQ,cANxB,OAAO,gBAAgB,KAAK,KAAK,QAAQ,oBAAoB;EAMvB,YALrB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AACjB,MAAI,QAAQ,cAAc,IAAI,IAAI,KAAK,OACrC,cAAa,KAAK,EAAE;WACX,QAAQ,YAAY,QAAQ,MAAM;AAC3C,eAAY;AACZ,WAAQ,KAAK,EAAE;aACN,CAAC,WAAW,SAAS,SAAS,IAAe,CACtD,WAAU;OACL;AACL,WAAQ,MAAM,qBAAqB,MAAM;AACzC,eAAY;AACZ,WAAQ,KAAK,EAAE;;;AAInB,KAAI,CAAC,SAAS;AACZ,cAAY;AACZ,UAAQ,KAAK,EAAE;;AAGjB,QAAO;EAAW;EAAU;EAAY;;AAG1C,IAAM,EAAE,SAAS,eAAe,UAAU,QAAQ,KAAK;AACvD,IAAM,SAAS,WAAW,WAAW;CAEuB;CAC1D;CACA;CACA;CACA;CACA;CACD,EAEQ,SAAS,OAAO"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/cli/commands.ts","../../src/cli/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport { walkAll } from '../extractor/walker';\nimport { generateBundles } from '../extractor/bundle-generator';\nimport { writeTypes } from '../extractor/type-generator';\nimport { generateReports } from '../extractor/reports';\nimport { compileAll } from '../extractor/compiler';\nimport type { ProjectAnalysis } from '../extractor/walker-types';\nimport type { DictionaryConfig } from '../core/types';\nimport { flattenLocaleKeys } from '../extractor/reports';\nimport {\n createExtractionCache,\n computeConfigHash,\n type ExtractionCache,\n} from '../extractor/extraction-cache';\nimport { resolveCacheConfig } from '../extractor/cache-config';\nimport { PLUGIN_VERSION } from '../plugin/version';\n\nexport interface CliConfig {\n /** Glob patterns for page entry points. */\n pages: string[];\n /** Locales directory (relative to rootDir). */\n localesDir: string;\n /** All supported locale codes. */\n locales: string[];\n /** Default locale. */\n defaultLocale: string;\n /** Root directory. Defaults to process.cwd(). */\n rootDir?: string;\n /** Output directory for generated bundles. Defaults to '.i18n'. */\n outDir?: string;\n /** Output path for generated types. Defaults to '.i18n/i18n.d.ts'. */\n typesOutPath?: string;\n /** Extraction scope. Defaults to 'global'. */\n extractionScope?: 'global' | 'scoped';\n /** Optional dictionary configurations for compiled mode. */\n dictionaries?: Record<string, DictionaryConfig>;\n /** Additional module specifiers that export `useI18n`. */\n hookSources?: string[];\n /**\n * Inline cross-namespace keys (tree-shaken) into each scope bundle.\n * See `I18nSharedConfig.bundling.crossNamespacePacking`.\n */\n crossNamespacePacking?: boolean;\n /**\n * Extraction cache control. `false` disables, an object configures the\n * backing directory and persistence. Env vars (`VITE_I18N_NO_CACHE`,\n * `VITE_I18N_CLEAR_CACHE`, `VITE_I18N_CACHE_DEBUG`) always take\n * precedence. See `resolveCacheConfig`.\n */\n cache?: boolean | {\n enabled?: boolean;\n dir?: string;\n persist?: boolean;\n };\n}\n\nfunction resolveConfig(config: CliConfig) {\n const rootDir = config.rootDir ?? process.cwd();\n const outDir = config.outDir ?? path.join(rootDir, '.i18n');\n const typesOutPath =\n config.typesOutPath ?? path.join(outDir, 'i18n-generated.ts');\n const localesDir = path.isAbsolute(config.localesDir)\n ? config.localesDir\n : path.join(rootDir, config.localesDir);\n const extractionScope = config.extractionScope ?? 'global';\n\n return { rootDir, outDir, typesOutPath, localesDir, extractionScope } as const;\n}\n\nfunction buildCliCache(config: CliConfig, rootDir: string): ExtractionCache | undefined {\n const cacheSettings = resolveCacheConfig(config.cache, { rootDir });\n if (!cacheSettings.enabled) return undefined;\n\n if (cacheSettings.clearBeforeStart) {\n try {\n fs.rmSync(cacheSettings.dir, { recursive: true, force: true });\n } catch {\n // Non-fatal — fall through to a fresh cache.\n }\n }\n\n return createExtractionCache({\n dir: cacheSettings.dir,\n pluginVersion: PLUGIN_VERSION,\n configHash: computeConfigHash({\n pages: config.pages,\n defaultLocale: config.defaultLocale,\n extractionScope: config.extractionScope ?? 'global',\n hookSources: config.hookSources,\n dictionaries: config.dictionaries,\n crossNamespacePacking: config.crossNamespacePacking,\n }),\n debug: cacheSettings.debug,\n });\n}\n\nfunction persistCache(config: CliConfig, cache: ExtractionCache | undefined, rootDir: string): void {\n if (!cache) return;\n const cacheSettings = resolveCacheConfig(config.cache, { rootDir });\n if (cacheSettings.persist) {\n cache.persistToDisk();\n }\n}\n\nfunction runWalker(config: CliConfig, cache?: ExtractionCache): ProjectAnalysis {\n const { rootDir, localesDir, extractionScope } = resolveConfig(config);\n\n return walkAll({\n pages: config.pages,\n rootDir,\n localesDir,\n defaultLocale: config.defaultLocale,\n extractionScope,\n hookSources: config.hookSources,\n cache,\n });\n}\n\nfunction collectScopeNames(analysis: ProjectAnalysis): string[] {\n return [...new Set(analysis.routes.flatMap((route) => route.scopes))].sort();\n}\n\n/**\n * Pad a string to the given width.\n */\nfunction pad(str: string, width: number): string {\n return str + ' '.repeat(Math.max(0, width - str.length));\n}\n\n/**\n * Print a simple ASCII table to stdout.\n */\nfunction printTable(\n headers: string[],\n rows: string[][],\n): void {\n const colWidths = headers.map((h, i) =>\n Math.max(h.length, ...rows.map((r) => (r[i] ?? '').length)),\n );\n\n const sep =\n '\\u250c' +\n colWidths.map((w) => '\\u2500'.repeat(w + 2)).join('\\u252c') +\n '\\u2510';\n const mid =\n '\\u251c' +\n colWidths.map((w) => '\\u2500'.repeat(w + 2)).join('\\u253c') +\n '\\u2524';\n const bot =\n '\\u2514' +\n colWidths.map((w) => '\\u2500'.repeat(w + 2)).join('\\u2534') +\n '\\u2518';\n\n const formatRow = (cells: string[]) =>\n '\\u2502' +\n cells.map((c, i) => ' ' + pad(c, colWidths[i]) + ' ').join('\\u2502') +\n '\\u2502';\n\n console.log(sep);\n console.log(formatRow(headers));\n console.log(mid);\n for (const row of rows) {\n console.log(formatRow(row));\n }\n console.log(bot);\n}\n\n/**\n * Run the walker and print a summary table to stdout.\n * Returns the ProjectAnalysis for programmatic use.\n */\nexport function analyze(config: CliConfig): ProjectAnalysis {\n const { rootDir, localesDir } = resolveConfig(config);\n const cache = buildCliCache(config, rootDir);\n const analysis = runWalker(config, cache);\n persistCache(config, cache, rootDir);\n\n const availableKeys = flattenLocaleKeys(localesDir, config.defaultLocale);\n const totalAvailable = Array.from(availableKeys.values()).reduce(\n (sum, keys) => sum + keys.length,\n 0,\n );\n\n const rows = analysis.routes.map((route) => {\n const usedCount = route.keys.filter((k) => !k.dynamic).length;\n return [\n route.routeId,\n String(usedCount),\n String(totalAvailable),\n String(totalAvailable - usedCount),\n ];\n });\n\n printTable(['Route', 'Used Keys', 'Available', 'Pruned'], rows);\n\n console.log(\n `\\n${analysis.routes.length} route(s), ${analysis.allKeys.length} unique key(s), ${analysis.availableNamespaces.length} namespace(s)`,\n );\n\n return analysis;\n}\n\n/**\n * Run the walker, then generate bundles and types.\n * Prints what was generated to stdout.\n */\nexport function generate(config: CliConfig): void {\n const { rootDir, outDir, typesOutPath, localesDir } = resolveConfig(config);\n const cache = buildCliCache(config, rootDir);\n const analysis = runWalker(config, cache);\n persistCache(config, cache, rootDir);\n\n const bundles = generateBundles(analysis, {\n localesDir,\n locales: config.locales,\n outDir,\n crossNamespacePacking: config.crossNamespacePacking,\n });\n\n writeTypes(localesDir, config.defaultLocale, typesOutPath, collectScopeNames(analysis));\n\n console.log(`Generated ${bundles.length} bundle(s):`);\n for (const b of bundles) {\n console.log(` ${b.locale}/${b.name} — ${b.keyCount} keys (${b.prunedCount} pruned)`);\n }\n console.log(`Types written to ${typesOutPath}`);\n}\n\n/**\n * Run the walker, then generate diagnostic reports.\n * Prints summary to stdout.\n */\nexport function report(config: CliConfig): void {\n const { rootDir, outDir, localesDir } = resolveConfig(config);\n const cache = buildCliCache(config, rootDir);\n const analysis = runWalker(config, cache);\n persistCache(config, cache, rootDir);\n\n generateReports(analysis, localesDir, config.defaultLocale, outDir, config.dictionaries);\n\n console.log(`Reports written to ${outDir}:`);\n console.log(' manifest.json');\n console.log(' missing.json');\n console.log(' unused.json');\n console.log(' stats.json');\n}\n\n/**\n * Run the walker, then compile pre-resolved flat Map modules.\n * Prints a summary to stdout.\n */\nexport function compile(config: CliConfig): void {\n const { rootDir, outDir, localesDir } = resolveConfig(config);\n const cache = buildCliCache(config, rootDir);\n const analysis = runWalker(config, cache);\n persistCache(config, cache, rootDir);\n const compiledOutDir = path.join(outDir, 'compiled');\n\n compileAll(analysis, {\n localesDir,\n locales: config.locales,\n defaultLocale: config.defaultLocale,\n outDir: compiledOutDir,\n dictionaries: config.dictionaries,\n crossNamespacePacking: config.crossNamespacePacking,\n });\n\n // Count generated modules: one per route per locale, plus dictionary modules\n const routeModules = analysis.routes.length * config.locales.length;\n const dictModules =\n config.dictionaries && Object.keys(config.dictionaries).length > 0\n ? config.locales.length\n : 0;\n const total = routeModules + dictModules + 1; // +1 for manifest\n\n console.log(`Compiled ${total} module(s) to ${compiledOutDir}`);\n}\n\n/**\n * Run analyze + generate + compile + report all at once.\n */\nexport function build(config: CliConfig): void {\n const { rootDir, outDir, typesOutPath, localesDir } = resolveConfig(config);\n const cache = buildCliCache(config, rootDir);\n const analysis = runWalker(config, cache);\n persistCache(config, cache, rootDir);\n\n // Analyze: print table\n const availableKeys = flattenLocaleKeys(localesDir, config.defaultLocale);\n const totalAvailable = Array.from(availableKeys.values()).reduce(\n (sum, keys) => sum + keys.length,\n 0,\n );\n\n const rows = analysis.routes.map((route) => {\n const usedCount = route.keys.filter((k) => !k.dynamic).length;\n return [\n route.routeId,\n String(usedCount),\n String(totalAvailable),\n String(totalAvailable - usedCount),\n ];\n });\n\n printTable(['Route', 'Used Keys', 'Available', 'Pruned'], rows);\n\n // Generate bundles + types\n const bundles = generateBundles(analysis, {\n localesDir,\n locales: config.locales,\n outDir,\n crossNamespacePacking: config.crossNamespacePacking,\n });\n\n writeTypes(localesDir, config.defaultLocale, typesOutPath, collectScopeNames(analysis));\n\n console.log(`\\nGenerated ${bundles.length} bundle(s)`);\n console.log(`Types written to ${typesOutPath}`);\n\n // Compile\n const compiledOutDir = path.join(outDir, 'compiled');\n compileAll(analysis, {\n localesDir,\n locales: config.locales,\n defaultLocale: config.defaultLocale,\n outDir: compiledOutDir,\n dictionaries: config.dictionaries,\n crossNamespacePacking: config.crossNamespacePacking,\n });\n console.log(`Compiled modules written to ${compiledOutDir}`);\n\n // Reports\n generateReports(analysis, localesDir, config.defaultLocale, outDir, config.dictionaries);\n\n console.log(`Reports written to ${outDir}`);\n console.log(\n `\\nDone. ${analysis.routes.length} route(s), ${analysis.allKeys.length} unique key(s).`,\n );\n}\n","#!/usr/bin/env node\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { analyze, generate, compile, report, build } from './commands';\nimport type { CliConfig } from './commands';\n\nconst COMMANDS = ['analyze', 'generate', 'compile', 'report', 'build'] as const;\ntype Command = (typeof COMMANDS)[number];\n\nfunction printUsage(): void {\n console.log('Usage: vite-bundled-i18n <command> [options]');\n console.log('');\n console.log('Commands:');\n console.log(' analyze — Walk imports and print a summary of key usage per route');\n console.log(' generate — Generate tree-shaken bundles and TypeScript types');\n console.log(' report — Generate diagnostic reports (manifest, missing, unused, stats)');\n console.log(' compile — Compile pre-resolved flat Map modules for production');\n console.log(' build — Run analyze + generate + compile + report in one step');\n console.log('');\n console.log('Options:');\n console.log(' --config <path> Path to config file (default: i18n.config.json)');\n console.log(' --no-cache Disable the extraction cache for this run');\n console.log(' --clear-cache Clear the extraction cache before running');\n}\n\nfunction loadConfig(configPath: string): CliConfig {\n const resolved = path.resolve(configPath);\n if (!fs.existsSync(resolved)) {\n console.error(`Config file not found: ${resolved}`);\n process.exit(1);\n }\n\n const raw = fs.readFileSync(resolved, 'utf-8');\n return JSON.parse(raw) as CliConfig;\n}\n\ninterface ParsedArgs {\n command: Command;\n configPath: string;\n noCache: boolean;\n clearCache: boolean;\n}\n\nfunction parseArgs(argv: string[]): ParsedArgs {\n const args = argv.slice(2);\n let command: Command | undefined;\n let configPath = 'i18n.config.json';\n let noCache = false;\n let clearCache = false;\n\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n if (arg === '--config' && i + 1 < args.length) {\n configPath = args[++i];\n } else if (arg === '--no-cache') {\n noCache = true;\n } else if (arg === '--clear-cache') {\n clearCache = true;\n } else if (arg === '--help' || arg === '-h') {\n printUsage();\n process.exit(0);\n } else if (!command && COMMANDS.includes(arg as Command)) {\n command = arg as Command;\n } else {\n console.error(`Unknown argument: ${arg}`);\n printUsage();\n process.exit(1);\n }\n }\n\n if (!command) {\n printUsage();\n process.exit(1);\n }\n\n return { command: command!, configPath, noCache, clearCache };\n}\n\nconst { command, configPath, noCache, clearCache } = parseArgs(process.argv);\nconst config = loadConfig(configPath);\n\n// CLI flags merge into the config's `cache` field so downstream resolution\n// sees them. Env vars still take the final word via resolveCacheConfig.\nif (noCache) {\n config.cache = false;\n}\nif (clearCache) {\n // Resolve-time handling: a CLI-driven clear is honored even when config\n // doesn't opt into the cache object form. We signal via an env var so\n // the central resolver is the single source of truth.\n process.env.VITE_I18N_CLEAR_CACHE = '1';\n}\n\nconst commands: Record<Command, (cfg: CliConfig) => void> = {\n analyze,\n generate,\n compile,\n report,\n build,\n};\n\ncommands[command](config);\n"],"mappings":";;;;;AAyDA,SAAS,cAAc,QAAmB;CACxC,MAAM,UAAU,OAAO,WAAW,QAAQ,KAAK;CAC/C,MAAM,SAAS,OAAO,UAAU,KAAK,KAAK,SAAS,QAAQ;AAQ3D,QAAO;EAAE;EAAS;EAAQ,cANxB,OAAO,gBAAgB,KAAK,KAAK,QAAQ,oBAAoB;EAMvB,YALrB,KAAK,WAAW,OAAO,WAAW,GACjD,OAAO,aACP,KAAK,KAAK,SAAS,OAAO,WAAW;EAGW,iBAF5B,OAAO,mBAAmB;EAEmB;;AAGvE,SAAS,cAAc,QAAmB,SAA8C;CACtF,MAAM,gBAAgB,mBAAmB,OAAO,OAAO,EAAE,SAAS,CAAC;AACnE,KAAI,CAAC,cAAc,QAAS,QAAO,KAAA;AAEnC,KAAI,cAAc,iBAChB,KAAI;AACF,KAAG,OAAO,cAAc,KAAK;GAAE,WAAW;GAAM,OAAO;GAAM,CAAC;SACxD;AAKV,QAAO,sBAAsB;EAC3B,KAAK,cAAc;EACnB,eAAe;EACf,YAAY,kBAAkB;GAC5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