vite-bundled-i18n 0.7.4 → 0.8.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.
@@ -1,8 +1,8 @@
1
+ import crypto from "node:crypto";
1
2
  import fs from "node:fs";
2
3
  import path from "node:path";
3
4
  import { globSync } from "tinyglobby";
4
5
  import ts from "typescript";
5
- import crypto from "node:crypto";
6
6
  //#region src/extractor/dictionary-ownership.ts
7
7
  function getDictionaryIncludePatterns(dict) {
8
8
  return [...(dict.keys ?? []).map((key) => `${key}.*`), ...dict.include ?? []];
@@ -108,6 +108,96 @@ function buildScopePlans(analysis, availableKeys, options = {}) {
108
108
  return [...scopePlans.values()].sort((a, b) => a.scope.localeCompare(b.scope));
109
109
  }
110
110
  //#endregion
111
+ //#region src/extractor/locale-store.ts
112
+ /**
113
+ * Flattens a nested translation object into `target`, prefixing every key
114
+ * with `prefix` (which must already end with a dot, e.g. `'products.'`).
115
+ *
116
+ * Writes straight into one accumulator instead of building a map per
117
+ * nesting level. Insertion order and last-write-wins semantics are the same
118
+ * as building nested maps and copying them into their parent.
119
+ *
120
+ * Only string leaves are kept; arrays recurse by index; other values
121
+ * (numbers, booleans, null) are skipped.
122
+ *
123
+ * @internal
124
+ */
125
+ function flattenNamespaceInto(target, data, prefix) {
126
+ for (const key of Object.keys(data)) {
127
+ const value = data[key];
128
+ const fullKey = `${prefix}${key}`;
129
+ if (typeof value === "string") target.set(fullKey, value);
130
+ else if (typeof value === "object" && value !== null) flattenNamespaceInto(target, value, `${fullKey}.`);
131
+ }
132
+ }
133
+ /**
134
+ * Creates an empty per-run {@link LocaleStore} for `localesDir`.
135
+ *
136
+ * @internal
137
+ */
138
+ function createLocaleStore(localesDir) {
139
+ const namespaceLists = /* @__PURE__ */ new Map();
140
+ const parsed = /* @__PURE__ */ new Map();
141
+ const fullMaps = /* @__PURE__ */ new Map();
142
+ const fullMapIndexes = /* @__PURE__ */ new Map();
143
+ function namespaces(locale) {
144
+ let list = namespaceLists.get(locale);
145
+ if (!list) {
146
+ const localeDir = path.join(localesDir, locale);
147
+ list = fs.existsSync(localeDir) ? fs.readdirSync(localeDir).filter((file) => file.endsWith(".json")).map((file) => file.replace(/\.json$/, "")) : [];
148
+ namespaceLists.set(locale, list);
149
+ }
150
+ return list;
151
+ }
152
+ function namespace(locale, ns) {
153
+ const cacheKey = `${locale}\0${ns}`;
154
+ if (parsed.has(cacheKey)) return parsed.get(cacheKey);
155
+ const filePath = path.join(localesDir, locale, `${ns}.json`);
156
+ const data = fs.existsSync(filePath) ? JSON.parse(fs.readFileSync(filePath, "utf-8")) : null;
157
+ parsed.set(cacheKey, data);
158
+ return data;
159
+ }
160
+ function fullMap(locale) {
161
+ let map = fullMaps.get(locale);
162
+ if (!map) {
163
+ map = /* @__PURE__ */ new Map();
164
+ for (const ns of namespaces(locale)) {
165
+ const data = namespace(locale, ns);
166
+ if (!data) continue;
167
+ flattenNamespaceInto(map, data, `${ns}.`);
168
+ }
169
+ fullMaps.set(locale, map);
170
+ }
171
+ return map;
172
+ }
173
+ function fullMapIndex(locale) {
174
+ let index = fullMapIndexes.get(locale);
175
+ if (!index) {
176
+ index = /* @__PURE__ */ new Map();
177
+ let position = 0;
178
+ for (const key of fullMap(locale).keys()) index.set(key, position++);
179
+ fullMapIndexes.set(locale, index);
180
+ }
181
+ return index;
182
+ }
183
+ return {
184
+ localesDir,
185
+ namespaces,
186
+ namespace,
187
+ fullMap,
188
+ fullMapIndex
189
+ };
190
+ }
191
+ /**
192
+ * Returns `store` when it reads from `localesDir`, otherwise a fresh store.
193
+ * Guards against a caller passing a store built for a different directory.
194
+ *
195
+ * @internal
196
+ */
197
+ function localeStoreFor(localesDir, store) {
198
+ return store && store.localesDir === localesDir ? store : createLocaleStore(localesDir);
199
+ }
200
+ //#endregion
111
201
  //#region src/extractor/bundle-generator.ts
112
202
  /**
113
203
  * Flatten a nested object into dot-separated key paths. Null/undefined at
@@ -115,26 +205,52 @@ function buildScopePlans(analysis, availableKeys, options = {}) {
115
205
  * namespace contributes no keys, never throws.
116
206
  */
117
207
  function flattenKeys(data, prefix) {
118
- if (data == null) return [];
119
208
  const keys = [];
209
+ flattenKeysInto(keys, data, prefix);
210
+ return keys;
211
+ }
212
+ /** {@link flattenKeys} into one accumulator instead of an array per level. */
213
+ function flattenKeysInto(out, data, prefix) {
214
+ if (data == null) return;
120
215
  for (const [k, v] of Object.entries(data)) {
121
216
  const fullKey = prefix ? `${prefix}.${k}` : k;
122
- if (v !== null && typeof v === "object" && !Array.isArray(v)) keys.push(...flattenKeys(v, fullKey));
123
- else keys.push(fullKey);
217
+ if (v !== null && typeof v === "object" && !Array.isArray(v)) flattenKeysInto(out, v, fullKey);
218
+ else out.push(fullKey);
124
219
  }
125
- return keys;
220
+ }
221
+ /**
222
+ * Number of entries {@link flattenKeys} would return, without building the
223
+ * array.
224
+ */
225
+ function countFlatKeys(data) {
226
+ if (data == null) return 0;
227
+ let count = 0;
228
+ for (const v of Object.values(data)) if (v !== null && typeof v === "object" && !Array.isArray(v)) count += countFlatKeys(v);
229
+ else count++;
230
+ return count;
126
231
  }
127
232
  /**
128
233
  * Set a value at a dot-separated path in a nested object, creating
129
234
  * intermediate objects as needed.
235
+ *
236
+ * `owned` holds the containers this prune created. When the path runs into
237
+ * a container that isn't owned, a whole subtree of the input already sits
238
+ * at that path and holds this exact value, so there is nothing to write.
239
+ * Stopping there keeps the input untouched: parsed locale files are shared
240
+ * between scopes for the whole build.
130
241
  */
131
- function setNestedValue(obj, keyPath, value) {
242
+ function setNestedValue(obj, keyPath, value, owned) {
132
243
  const parts = keyPath.split(".");
133
244
  let current = obj;
134
245
  for (let i = 0; i < parts.length - 1; i++) {
135
246
  const part = parts[i];
136
- if (!(part in current) || typeof current[part] !== "object" || current[part] === null) current[part] = {};
247
+ if (!(part in current) || typeof current[part] !== "object" || current[part] === null) {
248
+ const created = {};
249
+ owned.add(created);
250
+ current[part] = created;
251
+ }
137
252
  current = current[part];
253
+ if (!owned.has(current)) return;
138
254
  }
139
255
  current[parts[parts.length - 1]] = value;
140
256
  }
@@ -160,27 +276,40 @@ function getNestedValue(obj, keyPath) {
160
276
  */
161
277
  function pruneNamespace(fullData, usedKeyPaths) {
162
278
  const result = {};
279
+ const owned = new WeakSet([result]);
163
280
  for (const keyPath of usedKeyPaths) {
164
281
  const value = getNestedValue(fullData, keyPath);
165
- if (value !== void 0) setNestedValue(result, keyPath, value);
282
+ if (value !== void 0) setNestedValue(result, keyPath, value, owned);
166
283
  }
167
284
  return result;
168
285
  }
169
286
  /**
170
- * Read a namespace JSON file for a given locale.
171
- */
172
- function readNamespaceFile(localesDir, locale, namespace) {
173
- const filePath = path.join(localesDir, locale, `${namespace}.json`);
174
- if (!fs.existsSync(filePath)) return null;
175
- const content = fs.readFileSync(filePath, "utf-8");
176
- return JSON.parse(content);
177
- }
178
- /**
179
287
  * Generate tree-shaken per-route translation bundles from project analysis.
180
288
  */
181
289
  function generateBundles(analysis, options) {
182
290
  const { localesDir, locales, outDir, dictionaries, crossNamespacePacking } = options;
183
291
  const bundles = [];
292
+ const serialize = options.pretty === false ? (data) => JSON.stringify(data) : (data) => JSON.stringify(data, null, 2);
293
+ const store = localeStoreFor(localesDir, options.localeStore);
294
+ const readNamespaceFile = (locale, namespace) => store.namespace(locale, namespace);
295
+ const flatKeysCache = /* @__PURE__ */ new WeakMap();
296
+ const flatKeysOf = (data) => {
297
+ let keys = flatKeysCache.get(data);
298
+ if (!keys) {
299
+ keys = flattenKeys(data);
300
+ flatKeysCache.set(data, keys);
301
+ }
302
+ return keys;
303
+ };
304
+ const keyCountCache = /* @__PURE__ */ new WeakMap();
305
+ const keyCountOf = (data) => {
306
+ let count = keyCountCache.get(data);
307
+ if (count === void 0) {
308
+ count = flatKeysCache.get(data)?.length ?? countFlatKeys(data);
309
+ keyCountCache.set(data, count);
310
+ }
311
+ return count;
312
+ };
184
313
  const availableKeys = /* @__PURE__ */ new Set();
185
314
  for (const route of analysis.routes) for (const key of route.keys) if (!key.dynamic) availableKeys.add(key.key);
186
315
  const ownership = resolveDictionaryOwnership(availableKeys, dictionaries);
@@ -194,12 +323,12 @@ function generateBundles(analysis, options) {
194
323
  if (ownership.keyOwner.has(key)) return false;
195
324
  return !(!hasNamedDictionaries && sharedNsSet.has(plan.namespace));
196
325
  }).filter((key) => key.startsWith(`${plan.namespace}.`)).map((key) => key.slice(plan.namespace.length + 1));
197
- const fullData = readNamespaceFile(localesDir, locale, plan.namespace);
326
+ const fullData = readNamespaceFile(locale, plan.namespace);
198
327
  if (fullData && subKeys.length > 0) {
199
328
  const pruned = pruneNamespace(fullData, [...new Set(subKeys)]);
200
329
  bundleData[plan.namespace] = pruned;
201
- const availableCount = flattenKeys(fullData).length;
202
- const keptCount = flattenKeys(pruned).length;
330
+ const availableCount = keyCountOf(fullData);
331
+ const keptCount = countFlatKeys(pruned);
203
332
  totalKeyCount += keptCount;
204
333
  totalPrunedCount += availableCount - keptCount;
205
334
  }
@@ -209,15 +338,15 @@ function generateBundles(analysis, options) {
209
338
  if (!hasNamedDictionaries && sharedNsSet.has(extraNs)) continue;
210
339
  const extraSubKeys = retained.filter((key) => key.startsWith(`${extraNs}.`)).map((key) => key.slice(extraNs.length + 1));
211
340
  if (extraSubKeys.length === 0) continue;
212
- const extraFullData = readNamespaceFile(localesDir, locale, extraNs);
341
+ const extraFullData = readNamespaceFile(locale, extraNs);
213
342
  if (!extraFullData) continue;
214
343
  const pruned = pruneNamespace(extraFullData, [...new Set(extraSubKeys)]);
215
344
  bundleData[extraNs] = pruned;
216
- totalKeyCount += flattenKeys(pruned).length;
345
+ totalKeyCount += countFlatKeys(pruned);
217
346
  }
218
347
  const filePath = path.join(outDir, locale, `${plan.scope}.json`);
219
348
  fs.mkdirSync(path.dirname(filePath), { recursive: true });
220
- fs.writeFileSync(filePath, JSON.stringify(bundleData, null, 2));
349
+ fs.writeFileSync(filePath, serialize(bundleData));
221
350
  bundles.push({
222
351
  name: plan.scope,
223
352
  locale,
@@ -247,9 +376,9 @@ function generateBundles(analysis, options) {
247
376
  const bundleData = {};
248
377
  let totalKeyCount = 0;
249
378
  for (const ns of matchedNamespaces) {
250
- const fullData = readNamespaceFile(localesDir, locale, ns);
379
+ const fullData = readNamespaceFile(locale, ns);
251
380
  if (!fullData) continue;
252
- const includedKeys = flattenKeys(fullData).filter((subKey) => {
381
+ const includedKeys = flatKeysOf(fullData).filter((subKey) => {
253
382
  const fullKey = `${ns}.${subKey}`;
254
383
  const included = rule.include.some((pattern) => keyMatchesPattern(fullKey, pattern));
255
384
  const excluded = rule.exclude.length > 0 && rule.exclude.some((pattern) => keyMatchesPattern(fullKey, pattern));
@@ -258,11 +387,11 @@ function generateBundles(analysis, options) {
258
387
  if (includedKeys.length === 0) continue;
259
388
  const pruned = pruneNamespace(fullData, includedKeys);
260
389
  bundleData[ns] = pruned;
261
- totalKeyCount += flattenKeys(pruned).length;
390
+ totalKeyCount += countFlatKeys(pruned);
262
391
  }
263
392
  const filePath = path.join(outDir, locale, "_dict", `${rule.name}.json`);
264
393
  fs.mkdirSync(path.dirname(filePath), { recursive: true });
265
- fs.writeFileSync(filePath, JSON.stringify(bundleData, null, 2));
394
+ fs.writeFileSync(filePath, serialize(bundleData));
266
395
  bundles.push({
267
396
  name: `_dict/${rule.name}`,
268
397
  locale,
@@ -285,14 +414,14 @@ function generateBundles(analysis, options) {
285
414
  }
286
415
  }
287
416
  for (const locale of locales) {
288
- const fullData = readNamespaceFile(localesDir, locale, sharedNs);
417
+ const fullData = readNamespaceFile(locale, sharedNs);
289
418
  if (!fullData) continue;
290
419
  const pruned = pruneNamespace(fullData, [...allSubKeys]);
291
420
  const filePath = path.join(outDir, locale, "_dict", `${sharedNs}.json`);
292
421
  fs.mkdirSync(path.dirname(filePath), { recursive: true });
293
- fs.writeFileSync(filePath, JSON.stringify(pruned, null, 2));
294
- const availableCount = flattenKeys(fullData).length;
295
- const keptCount = flattenKeys(pruned).length;
422
+ fs.writeFileSync(filePath, serialize(pruned));
423
+ const availableCount = keyCountOf(fullData);
424
+ const keptCount = countFlatKeys(pruned);
296
425
  bundles.push({
297
426
  name: `_dict/${sharedNs}`,
298
427
  locale,
@@ -538,8 +667,14 @@ function runtimePathFromTypesPath(typesOutPath) {
538
667
  * Read all namespace JSON files for the default locale and return a map of
539
668
  * namespace → flattened dot-path key arrays.
540
669
  */
541
- function flattenLocaleKeys(localesDir, defaultLocale) {
670
+ function flattenLocaleKeys(localesDir, defaultLocale, localeStore) {
542
671
  const result = /* @__PURE__ */ new Map();
672
+ if (localeStore && localeStore.localesDir === localesDir) {
673
+ for (const namespace of localeStore.namespaces(defaultLocale)) try {
674
+ result.set(namespace, flattenKeys(localeStore.namespace(defaultLocale, namespace)));
675
+ } catch {}
676
+ return result;
677
+ }
543
678
  const localeDir = path.join(localesDir, defaultLocale);
544
679
  if (!fs.existsSync(localeDir)) return result;
545
680
  const entries = fs.readdirSync(localeDir);
@@ -732,8 +867,8 @@ function generateDictionaryOwnershipReport(availableKeys, dictionaries) {
732
867
  * Orchestrate report generation: flatten locale keys, generate all four
733
868
  * reports, and write them as JSON files to outDir.
734
869
  */
735
- function generateReports(analysis, localesDir, defaultLocale, outDir, dictionaries) {
736
- const availableKeys = flattenLocaleKeys(localesDir, defaultLocale);
870
+ function generateReports(analysis, localesDir, defaultLocale, outDir, dictionaries, localeStore) {
871
+ const availableKeys = flattenLocaleKeys(localesDir, defaultLocale, localeStore);
737
872
  const manifest = generateManifest$1(analysis);
738
873
  const missing = generateMissing(analysis, availableKeys);
739
874
  const unused = generateUnused(analysis, availableKeys);
@@ -1559,7 +1694,7 @@ function resolveCacheConfig(input, context) {
1559
1694
  * back to a development placeholder during tests and direct imports before
1560
1695
  * the build step runs.
1561
1696
  */
1562
- var PLUGIN_VERSION = "0.7.4";
1697
+ var PLUGIN_VERSION = "0.8.0";
1563
1698
  //#endregion
1564
1699
  //#region src/extractor/scope-map.ts
1565
1700
  var COMPOSITE_PAGE_SUFFIXES = [
@@ -1737,27 +1872,6 @@ function escapeValue(value) {
1737
1872
  return value.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
1738
1873
  }
1739
1874
  /**
1740
- * Flattens a nested translation object into a flat Map with fully qualified keys.
1741
- *
1742
- * @param namespace - The namespace prefix (e.g., 'products')
1743
- * @param data - The nested translation object
1744
- * @param prefix - Internal prefix for recursion
1745
- * @returns A Map of fully qualified keys to string values
1746
- */
1747
- function flattenNamespace(namespace, data, prefix) {
1748
- const result = /* @__PURE__ */ new Map();
1749
- const currentPrefix = prefix ? `${prefix}.` : `${namespace}.`;
1750
- for (const [key, value] of Object.entries(data)) {
1751
- const fullKey = `${currentPrefix}${key}`;
1752
- if (typeof value === "string") result.set(fullKey, value);
1753
- else if (typeof value === "object" && value !== null) {
1754
- const nested = flattenNamespace(namespace, value, fullKey);
1755
- for (const [k, v] of nested) result.set(k, v);
1756
- }
1757
- }
1758
- return result;
1759
- }
1760
- /**
1761
1875
  * Creates a new map with all keys from primary, plus any missing keys filled from fallback.
1762
1876
  */
1763
1877
  function preResolveFallbacks(primary, fallback) {
@@ -1779,42 +1893,42 @@ function generateCompiledModule(entries) {
1779
1893
  return lines.join("\n");
1780
1894
  }
1781
1895
  /**
1782
- * Reads namespace JSON files for a locale and returns a combined flattened Map.
1896
+ * Picks `keys` out of `map`, keeping `map`'s insertion order.
1897
+ *
1898
+ * Same result as scanning `map` and keeping the entries whose key is in
1899
+ * `keys`, but costs O(|keys| log |keys|) instead of O(|map|): scope plans
1900
+ * use a few dozen keys out of tens of thousands.
1783
1901
  */
1784
- function buildLocaleMap(localesDir, locale, namespaces) {
1785
- const combined = /* @__PURE__ */ new Map();
1786
- for (const ns of namespaces) {
1787
- const filePath = path.join(localesDir, locale, `${ns}.json`);
1788
- if (!fs.existsSync(filePath)) continue;
1789
- const flat = flattenNamespace(ns, JSON.parse(fs.readFileSync(filePath, "utf-8")));
1790
- for (const [k, v] of flat) combined.set(k, v);
1902
+ function pickInMapOrder(map, index, keys) {
1903
+ const positions = [];
1904
+ const byPosition = /* @__PURE__ */ new Map();
1905
+ for (const key of keys) {
1906
+ const position = index.get(key);
1907
+ if (position === void 0 || byPosition.has(position)) continue;
1908
+ positions.push(position);
1909
+ byPosition.set(position, key);
1791
1910
  }
1792
- return combined;
1793
- }
1794
- /**
1795
- * Reads ALL namespace JSON files for a locale directory.
1796
- */
1797
- function buildFullLocaleMap(localesDir, locale) {
1798
- const localeDir = path.join(localesDir, locale);
1799
- if (!fs.existsSync(localeDir)) return /* @__PURE__ */ new Map();
1800
- return buildLocaleMap(localesDir, locale, fs.readdirSync(localeDir).filter((f) => f.endsWith(".json")).map((f) => f.replace(/\.json$/, "")));
1801
- }
1802
- /**
1803
- * Filters a map to only include entries whose keys are in the given set.
1804
- */
1805
- function filterMap(map, keys) {
1911
+ positions.sort((a, b) => a - b);
1806
1912
  const result = /* @__PURE__ */ new Map();
1807
- for (const [k, v] of map) if (keys.has(k)) result.set(k, v);
1913
+ for (const position of positions) {
1914
+ const key = byPosition.get(position);
1915
+ result.set(key, map.get(key));
1916
+ }
1808
1917
  return result;
1809
1918
  }
1919
+ /** {@link pickInMapOrder} over a locale's full map from the store. */
1920
+ function pickFromLocale(store, locale, keys) {
1921
+ return pickInMapOrder(store.fullMap(locale), store.fullMapIndex(locale), keys);
1922
+ }
1810
1923
  /**
1811
- * Generates a dictionary module for a locale by reading all dictionary namespace files,
1812
- * flattening them, and pre-resolving fallbacks against the default locale.
1924
+ * Builds one dictionary module from already-loaded locale maps and an
1925
+ * already-resolved ownership. Shared by {@link compileAll} and the public
1926
+ * {@link generateDictionaryModule} wrapper so both emit the same bytes.
1813
1927
  */
1814
- function generateDictionaryModule(localesDir, locale, defaultLocale, dictionaries, dictionaryName) {
1815
- const ownedKeys = resolveDictionaryOwnership(buildFullLocaleMap(localesDir, defaultLocale).keys(), dictionaries).dictionaryKeys.get(dictionaryName) ?? /* @__PURE__ */ new Set();
1816
- const localeMap = filterMap(buildFullLocaleMap(localesDir, locale), ownedKeys);
1817
- if (locale !== defaultLocale) return generateCompiledModule(preResolveFallbacks(localeMap, filterMap(buildFullLocaleMap(localesDir, defaultLocale), ownedKeys)));
1928
+ function generateDictionaryModuleFrom(store, ownership, locale, defaultLocale, dictionaryName) {
1929
+ const ownedKeys = ownership.dictionaryKeys.get(dictionaryName) ?? /* @__PURE__ */ new Set();
1930
+ const localeMap = pickFromLocale(store, locale, ownedKeys);
1931
+ if (locale !== defaultLocale) return generateCompiledModule(preResolveFallbacks(localeMap, pickFromLocale(store, defaultLocale, ownedKeys)));
1818
1932
  return generateCompiledModule(localeMap);
1819
1933
  }
1820
1934
  /**
@@ -1850,8 +1964,9 @@ function generateManifest(scopeIds, locales, dictionaryNames) {
1850
1964
  */
1851
1965
  function compileAll(analysis, options) {
1852
1966
  const { localesDir, locales, defaultLocale, outDir, dictionaries, crossNamespacePacking } = options;
1967
+ const store = localeStoreFor(localesDir, options.localeStore);
1853
1968
  fs.mkdirSync(outDir, { recursive: true });
1854
- const defaultFullMap = buildFullLocaleMap(localesDir, defaultLocale);
1969
+ const defaultFullMap = store.fullMap(defaultLocale);
1855
1970
  const ownership = resolveDictionaryOwnership(defaultFullMap.keys(), dictionaries);
1856
1971
  const scopePlans = buildScopePlans(analysis, defaultFullMap.keys(), { crossNamespacePacking });
1857
1972
  for (const plan of scopePlans) {
@@ -1860,11 +1975,17 @@ function compileAll(analysis, options) {
1860
1975
  if (ownership.keyOwner.has(key)) continue;
1861
1976
  usedKeys.add(key);
1862
1977
  }
1978
+ let defaultFiltered;
1863
1979
  for (const locale of locales) {
1864
1980
  const localeDir = path.join(outDir, locale);
1865
1981
  fs.mkdirSync(localeDir, { recursive: true });
1866
- const filtered = filterMap(buildFullLocaleMap(localesDir, locale), usedKeys);
1867
- const moduleSource = generateCompiledModule(locale !== defaultLocale ? preResolveFallbacks(filtered, filterMap(defaultFullMap, usedKeys)) : filtered);
1982
+ const filtered = pickFromLocale(store, locale, usedKeys);
1983
+ let resolved = filtered;
1984
+ if (locale !== defaultLocale) {
1985
+ defaultFiltered ??= pickFromLocale(store, defaultLocale, usedKeys);
1986
+ resolved = preResolveFallbacks(filtered, defaultFiltered);
1987
+ }
1988
+ const moduleSource = generateCompiledModule(resolved);
1868
1989
  fs.writeFileSync(path.join(localeDir, `${plan.scope}.js`), moduleSource);
1869
1990
  }
1870
1991
  }
@@ -1873,7 +1994,7 @@ function compileAll(analysis, options) {
1873
1994
  const dictDir = path.join(localeDir, "_dict");
1874
1995
  fs.mkdirSync(dictDir, { recursive: true });
1875
1996
  for (const dictionaryName of Object.keys(dictionaries)) {
1876
- const dictModule = generateDictionaryModule(localesDir, locale, defaultLocale, dictionaries, dictionaryName);
1997
+ const dictModule = generateDictionaryModuleFrom(store, ownership, locale, defaultLocale, dictionaryName);
1877
1998
  fs.writeFileSync(path.join(dictDir, `${dictionaryName}.js`), dictModule);
1878
1999
  }
1879
2000
  }
@@ -2238,6 +2359,6 @@ function formatDuration(ms) {
2238
2359
  return `${Math.round(ms / 864e5)}d`;
2239
2360
  }
2240
2361
  //#endregion
2241
- export { keyMatchesPattern as A, writeRuntimeConst as C, pruneNamespace as D, generateBundles as E, resolveDictionaryOwnership as M, buildScopePlans as O, runtimePathFromTypesPath as S, flattenKeys as T, extractKeys as _, runStrictExtraction as a, generateReports as b, applyDynamicKeys as c, resolveCacheConfig as d, CACHE_FILE_NAME as f, walkAll as g, resolveImport as h, assertNoStrictExtractionErrors as i, normalizeDictionaries as j, inferScopeNamespace as k, buildScopeMap as l, createExtractionCache as m, detectStaleness as n, writeStrictExtractionReport as o, computeConfigHash as p, writeBuildStamp as r, compileAll as s, computeAnalysisFingerprint as t, PLUGIN_VERSION as u, flattenLocaleKeys as v, writeTypes as w, generateTypes as x, generateDictionaryOwnershipReport as y };
2362
+ export { pruneNamespace as A, flattenToLeafValues as C, writeTypes as D, writeRuntimeConst as E, normalizeDictionaries as F, resolveDictionaryOwnership as I, buildScopePlans as M, inferScopeNamespace as N, flattenKeys as O, keyMatchesPattern as P, flattenToKeyPaths as S, runtimePathFromTypesPath as T, extractKeys as _, runStrictExtraction as a, generateReports as b, applyDynamicKeys as c, resolveCacheConfig as d, CACHE_FILE_NAME as f, walkAll as g, resolveImport as h, assertNoStrictExtractionErrors as i, createLocaleStore as j, generateBundles as k, buildScopeMap as l, createExtractionCache as m, detectStaleness as n, writeStrictExtractionReport as o, computeConfigHash as p, writeBuildStamp as r, compileAll as s, computeAnalysisFingerprint as t, PLUGIN_VERSION as u, flattenLocaleKeys as v, generateTypes as w, extractPlaceholders as x, generateDictionaryOwnershipReport as y };
2242
2363
 
2243
- //# sourceMappingURL=build-stamp-B_2oi0vc.js.map
2364
+ //# sourceMappingURL=build-stamp-BgrEayAW.js.map