@rushstack/webpack5-localization-plugin 0.16.27 → 0.16.28

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.json CHANGED
@@ -1,6 +1,26 @@
1
1
  {
2
2
  "name": "@rushstack/webpack5-localization-plugin",
3
3
  "entries": [
4
+ {
5
+ "version": "0.16.28",
6
+ "tag": "@rushstack/webpack5-localization-plugin_v0.16.28",
7
+ "date": "Mon, 14 Sep 2026 22:42:32 GMT",
8
+ "comments": {
9
+ "none": [
10
+ {
11
+ "comment": "Use ECMAScript private syntax for internal class members."
12
+ }
13
+ ],
14
+ "dependency": [
15
+ {
16
+ "comment": "Updating dependency \"@rushstack/localization-utilities\" to `0.16.5`"
17
+ },
18
+ {
19
+ "comment": "Updating dependency \"@rushstack/heft\" to `1.3.0`"
20
+ }
21
+ ]
22
+ }
23
+ },
4
24
  {
5
25
  "version": "0.16.27",
6
26
  "tag": "@rushstack/webpack5-localization-plugin_v0.16.27",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Change Log - @rushstack/webpack5-localization-plugin
2
2
 
3
- This log was last generated on Sat, 05 Sep 2026 00:15:08 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 14 Sep 2026 22:42:32 GMT and should not be manually modified.
4
+
5
+ ## 0.16.28
6
+ Mon, 14 Sep 2026 22:42:32 GMT
7
+
8
+ _Version update only_
4
9
 
5
10
  ## 0.16.27
6
11
  Sat, 05 Sep 2026 00:15:08 GMT
@@ -280,30 +280,11 @@ export declare interface IValuePlaceholderBase {
280
280
  * @public
281
281
  */
282
282
  export declare class LocalizationPlugin implements WebpackPluginInstance {
283
- private readonly _locFiles;
283
+ #private;
284
284
  /**
285
285
  * @internal
286
286
  */
287
287
  readonly _options: ILocalizationPluginOptions;
288
- private readonly _resolvedTranslatedStringsFromOptions;
289
- private readonly _stringPlaceholderBySuffix;
290
- private readonly _customDataPlaceholderBySuffix;
291
- private readonly _customDataPlaceholderByUniqueId;
292
- private _passthroughLocaleName;
293
- private _defaultLocale;
294
- private _noStringsLocaleName;
295
- private _fillMissingTranslationStrings;
296
- /**
297
- * @remarks
298
- * Include the `chunk` parameter so that the functions arity is the same as the
299
- * `ValueForLocaleFn` type.
300
- */
301
- private _formatLocaleForFilename;
302
- private readonly _pseudolocalizers;
303
- /**
304
- * The set of locales that have translations provided.
305
- */
306
- private _translatedLocales;
307
288
  constructor(options: ILocalizationPluginOptions);
308
289
  /**
309
290
  * Apply this plugin to the specified webpack compiler.
@@ -331,15 +312,13 @@ export declare class LocalizationPlugin implements WebpackPluginInstance {
331
312
  * @internal
332
313
  */
333
314
  _getCustomDataForSerialNumber(suffix: string): _ICustomDataPlaceholder | undefined;
334
- private _addLocFileAndGetPlaceholders;
335
- private _initializeAndValidateOptions;
336
315
  }
337
316
 
338
317
  /**
339
318
  * @public
340
319
  */
341
320
  export declare class TrueHashPlugin implements WebpackPluginInstance {
342
- private readonly _options;
321
+ #private;
343
322
  constructor(options?: ITrueHashPluginOptions);
344
323
  apply(compiler: Compiler): void;
345
324
  }
@@ -64,30 +64,30 @@ function getPluginInstance(compiler) {
64
64
  * @public
65
65
  */
66
66
  class LocalizationPlugin {
67
- _locFiles = new Map();
67
+ #locFiles = new Map();
68
68
  /**
69
69
  * @internal
70
70
  */
71
71
  _options;
72
- _resolvedTranslatedStringsFromOptions = new Map();
73
- _stringPlaceholderBySuffix = new Map();
74
- _customDataPlaceholderBySuffix = new Map();
75
- _customDataPlaceholderByUniqueId = new Map();
76
- _passthroughLocaleName;
77
- _defaultLocale;
78
- _noStringsLocaleName;
79
- _fillMissingTranslationStrings;
72
+ #resolvedTranslatedStringsFromOptions = new Map();
73
+ #stringPlaceholderBySuffix = new Map();
74
+ #customDataPlaceholderBySuffix = new Map();
75
+ #customDataPlaceholderByUniqueId = new Map();
76
+ #passthroughLocaleName;
77
+ #defaultLocale;
78
+ #noStringsLocaleName;
79
+ #fillMissingTranslationStrings;
80
80
  /**
81
81
  * @remarks
82
82
  * Include the `chunk` parameter so that the functions arity is the same as the
83
83
  * `ValueForLocaleFn` type.
84
84
  */
85
- _formatLocaleForFilename;
86
- _pseudolocalizers = new Map();
85
+ #formatLocaleForFilename;
86
+ #pseudolocalizers = new Map();
87
87
  /**
88
88
  * The set of locales that have translations provided.
89
89
  */
90
- _translatedLocales = new Set();
90
+ #translatedLocales = new Set();
91
91
  constructor(options) {
92
92
  this._options = options;
93
93
  }
@@ -98,7 +98,7 @@ class LocalizationPlugin {
98
98
  pluginForCompiler.set(compiler, this);
99
99
  // https://github.com/webpack/webpack-dev-server/pull/1929/files#diff-15fb51940da53816af13330d8ce69b4eR66
100
100
  const isWebpackDevServer = process.env.WEBPACK_DEV_SERVER === 'true';
101
- const { errors, warnings } = this._initializeAndValidateOptions(compiler, isWebpackDevServer);
101
+ const { errors, warnings } = this.#initializeAndValidateOptions(compiler, isWebpackDevServer);
102
102
  if (errors.length > 0 || warnings.length > 0) {
103
103
  compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
104
104
  compilation.errors.push(...errors);
@@ -180,7 +180,7 @@ class LocalizationPlugin {
180
180
  chunksWithUrlGenerators.add(activeChunkWithAsyncUrlGenerator);
181
181
  }
182
182
  if (chunkIdsWithStrings.size === 0) {
183
- return this._formatLocaleForFilename(this._noStringsLocaleName, undefined);
183
+ return this.#formatLocaleForFilename(this.#noStringsLocaleName, undefined);
184
184
  }
185
185
  else if (chunkIdsWithoutStrings.size === 0) {
186
186
  return `" + ${localeExpression} + "`;
@@ -203,7 +203,7 @@ class LocalizationPlugin {
203
203
  for (const id of smallerSet) {
204
204
  chunkMapping[id] = 1;
205
205
  }
206
- const noLocaleExpression = JSON.stringify(this._formatLocaleForFilename(this._noStringsLocaleName, undefined));
206
+ const noLocaleExpression = JSON.stringify(this.#formatLocaleForFilename(this.#noStringsLocaleName, undefined));
207
207
  return `" + (${JSON.stringify(chunkMapping)}[chunkId]?${isLocalizedSmaller ? localeExpression : noLocaleExpression}:${isLocalizedSmaller ? noLocaleExpression : localeExpression}) + "`;
208
208
  }
209
209
  });
@@ -213,9 +213,9 @@ class LocalizationPlugin {
213
213
  if (!locale) {
214
214
  const isLocalized = _chunkHasLocalizedModules(chunkGraph, options.chunk, runtimeLocaleExpression);
215
215
  // Ensure that the initial name maps to a file that should exist in the final output
216
- locale = isLocalized ? this._defaultLocale : this._noStringsLocaleName;
216
+ locale = isLocalized ? this.#defaultLocale : this.#noStringsLocaleName;
217
217
  }
218
- return assetPath.replace(Constants.LOCALE_FILENAME_TOKEN_REGEX, this._formatLocaleForFilename(locale, undefined));
218
+ return assetPath.replace(Constants.LOCALE_FILENAME_TOKEN_REGEX, this.#formatLocaleForFilename(locale, undefined));
219
219
  }
220
220
  }
221
221
  else {
@@ -229,7 +229,7 @@ class LocalizationPlugin {
229
229
  // Generating derived assets, but explicitly want to create them *after* asset optimization
230
230
  stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING - 1
231
231
  }, async () => {
232
- const locales = this._translatedLocales;
232
+ const locales = this.#translatedLocales;
233
233
  const { chunkGraph, chunks } = compilation;
234
234
  const { localizationStats: statsOptions } = this._options;
235
235
  const filesByChunkName = statsOptions
@@ -262,10 +262,10 @@ class LocalizationPlugin {
262
262
  compilation,
263
263
  cache,
264
264
  locales,
265
- defaultLocale: this._defaultLocale,
266
- passthroughLocaleName: this._passthroughLocaleName,
267
- fillMissingTranslationStrings: this._fillMissingTranslationStrings,
268
- formatLocaleForFilenameFn: this._formatLocaleForFilename,
265
+ defaultLocale: this.#defaultLocale,
266
+ passthroughLocaleName: this.#passthroughLocaleName,
267
+ fillMissingTranslationStrings: this.#fillMissingTranslationStrings,
268
+ formatLocaleForFilenameFn: this.#formatLocaleForFilename,
269
269
  // Chunk-specific values
270
270
  chunk,
271
271
  asset,
@@ -283,8 +283,8 @@ class LocalizationPlugin {
283
283
  compilation,
284
284
  cache,
285
285
  hasUrlGenerator: chunksWithUrlGenerators.has(chunk),
286
- noStringsLocaleName: this._noStringsLocaleName,
287
- formatLocaleForFilenameFn: this._formatLocaleForFilename,
286
+ noStringsLocaleName: this.#noStringsLocaleName,
287
+ formatLocaleForFilenameFn: this.#formatLocaleForFilename,
288
288
  // Chunk-specific values
289
289
  chunk,
290
290
  asset,
@@ -346,9 +346,9 @@ class LocalizationPlugin {
346
346
  */
347
347
  async addDefaultLocFileAsync(context, localizedFileKey, localizedResourceData) {
348
348
  const locFileData = convertLocalizationFileToLocData(localizedResourceData);
349
- const fileInfo = this._addLocFileAndGetPlaceholders(this._defaultLocale, localizedFileKey, locFileData);
349
+ const fileInfo = this.#addLocFileAndGetPlaceholders(this.#defaultLocale, localizedFileKey, locFileData);
350
350
  const missingLocales = [];
351
- for (const [translatedLocaleName, translatedStrings] of this._resolvedTranslatedStringsFromOptions) {
351
+ for (const [translatedLocaleName, translatedStrings] of this.#resolvedTranslatedStringsFromOptions) {
352
352
  const translatedLocFileFromOptions = translatedStrings.get(localizedFileKey);
353
353
  if (!translatedLocFileFromOptions) {
354
354
  missingLocales.push(translatedLocaleName);
@@ -379,7 +379,7 @@ class LocalizationPlugin {
379
379
  }
380
380
  }
381
381
  }
382
- for (const [pseudolocaleName, pseudolocalizer] of this._pseudolocalizers) {
382
+ for (const [pseudolocaleName, pseudolocalizer] of this.#pseudolocalizers) {
383
383
  const pseudolocFileData = new Map();
384
384
  for (const [stringName, stringValue] of locFileData) {
385
385
  pseudolocFileData.set(stringName, pseudolocalizer(stringValue));
@@ -393,7 +393,7 @@ class LocalizationPlugin {
393
393
  * @public
394
394
  */
395
395
  getPlaceholder(localizedFileKey, stringName) {
396
- const file = this._locFiles.get(localizedFileKey);
396
+ const file = this.#locFiles.get(localizedFileKey);
397
397
  if (!file) {
398
398
  return undefined;
399
399
  }
@@ -403,7 +403,7 @@ class LocalizationPlugin {
403
403
  * @beta
404
404
  */
405
405
  getCustomDataPlaceholderForValueFunction(valueForLocaleFn, placeholderUniqueId) {
406
- let placeholder = this._customDataPlaceholderByUniqueId.get(placeholderUniqueId);
406
+ let placeholder = this.#customDataPlaceholderByUniqueId.get(placeholderUniqueId);
407
407
  if (!placeholder) {
408
408
  // Get a hash of the unique ID to make sure its value doesn't interfere with our placeholder tokens
409
409
  const suffix = Buffer.from(placeholderUniqueId, 'utf-8').toString('hex');
@@ -412,8 +412,8 @@ class LocalizationPlugin {
412
412
  suffix,
413
413
  valueForLocaleFn
414
414
  };
415
- this._customDataPlaceholderBySuffix.set(suffix, placeholder);
416
- this._customDataPlaceholderByUniqueId.set(placeholderUniqueId, placeholder);
415
+ this.#customDataPlaceholderBySuffix.set(suffix, placeholder);
416
+ this.#customDataPlaceholderByUniqueId.set(placeholderUniqueId, placeholder);
417
417
  }
418
418
  else if (placeholder.valueForLocaleFn !== valueForLocaleFn) {
419
419
  throw new Error(`${this.getCustomDataPlaceholderForValueFunction.name} has already been called with "${placeholderUniqueId}" ` +
@@ -425,23 +425,23 @@ class LocalizationPlugin {
425
425
  * @internal
426
426
  */
427
427
  _getStringDataForSerialNumber(suffix) {
428
- return this._stringPlaceholderBySuffix.get(suffix);
428
+ return this.#stringPlaceholderBySuffix.get(suffix);
429
429
  }
430
430
  /**
431
431
  * @internal
432
432
  */
433
433
  _getCustomDataForSerialNumber(suffix) {
434
- return this._customDataPlaceholderBySuffix.get(suffix);
434
+ return this.#customDataPlaceholderBySuffix.get(suffix);
435
435
  }
436
- _addLocFileAndGetPlaceholders(localeName, localizedFileKey, localizedFileData) {
437
- let fileInfo = this._locFiles.get(localizedFileKey);
436
+ #addLocFileAndGetPlaceholders(localeName, localizedFileKey, localizedFileData) {
437
+ let fileInfo = this.#locFiles.get(localizedFileKey);
438
438
  if (!fileInfo) {
439
439
  fileInfo = {
440
440
  placeholders: new Map(),
441
441
  translations: new Map(),
442
442
  renderedPlaceholders: {}
443
443
  };
444
- this._locFiles.set(localizedFileKey, fileInfo);
444
+ this.#locFiles.set(localizedFileKey, fileInfo);
445
445
  }
446
446
  const { placeholders, translations } = fileInfo;
447
447
  const locFilePrefix = Buffer.from(localizedFileKey, 'utf-8').toString('hex') + '$';
@@ -458,7 +458,7 @@ class LocalizationPlugin {
458
458
  stringName
459
459
  };
460
460
  placeholders.set(stringName, placeholder);
461
- this._stringPlaceholderBySuffix.set(suffix, placeholder);
461
+ this.#stringPlaceholderBySuffix.set(suffix, placeholder);
462
462
  }
463
463
  resultObject[stringName] = placeholder.value;
464
464
  }
@@ -466,7 +466,7 @@ class LocalizationPlugin {
466
466
  fileInfo.renderedPlaceholders = resultObject;
467
467
  return fileInfo;
468
468
  }
469
- _initializeAndValidateOptions(compiler, isWebpackDevServer) {
469
+ #initializeAndValidateOptions(compiler, isWebpackDevServer) {
470
470
  const errors = [];
471
471
  const warnings = [];
472
472
  const { WebpackError } = compiler.webpack;
@@ -499,18 +499,18 @@ class LocalizationPlugin {
499
499
  if (passthroughLocale) {
500
500
  const { usePassthroughLocale, passthroughLocaleName = 'passthrough' } = passthroughLocale;
501
501
  if (usePassthroughLocale) {
502
- this._passthroughLocaleName = passthroughLocaleName;
503
- this._translatedLocales.add(passthroughLocaleName);
502
+ this.#passthroughLocaleName = passthroughLocaleName;
503
+ this.#translatedLocales.add(passthroughLocaleName);
504
504
  }
505
505
  }
506
506
  // END options.localizedData.passthroughLocale
507
507
  // START options.localizedData.translatedStrings
508
508
  const resolveRelativeToContext = (configuration.context?.startsWith('/') ? path.posix.resolve : path.resolve).bind(0, configuration.context);
509
509
  const { translatedStrings } = localizedData;
510
- this._resolvedTranslatedStringsFromOptions.clear();
510
+ this.#resolvedTranslatedStringsFromOptions.clear();
511
511
  if (translatedStrings) {
512
512
  for (const [localeName, locale] of Object.entries(translatedStrings)) {
513
- if (this._translatedLocales.has(localeName)) {
513
+ if (this.#translatedLocales.has(localeName)) {
514
514
  errors.push(new WebpackError(`The locale "${localeName}" appears multiple times. ` +
515
515
  'There may be multiple instances with different casing.'));
516
516
  return { errors, warnings };
@@ -518,9 +518,9 @@ class LocalizationPlugin {
518
518
  if (!ensureValidLocaleName(localeName)) {
519
519
  return { errors, warnings };
520
520
  }
521
- this._translatedLocales.add(localeName);
521
+ this.#translatedLocales.add(localeName);
522
522
  const resolvedFromOptionsForLocale = new Map();
523
- this._resolvedTranslatedStringsFromOptions.set(localeName, resolvedFromOptionsForLocale);
523
+ this.#resolvedTranslatedStringsFromOptions.set(localeName, resolvedFromOptionsForLocale);
524
524
  for (const [locFilePath, locFileDataFromOptions] of Object.entries(locale)) {
525
525
  const normalizedLocFilePath = resolveRelativeToContext(locFilePath);
526
526
  if (resolvedFromOptionsForLocale.has(normalizedLocFilePath)) {
@@ -541,16 +541,16 @@ class LocalizationPlugin {
541
541
  if (defaultLocale) {
542
542
  const { localeName, fillMissingTranslationStrings } = defaultLocale;
543
543
  if (localeName) {
544
- if (this._translatedLocales.has(localeName)) {
544
+ if (this.#translatedLocales.has(localeName)) {
545
545
  errors.push(new WebpackError('The default locale is also specified in the translated strings.'));
546
546
  return { errors, warnings };
547
547
  }
548
548
  else if (!ensureValidLocaleName(localeName)) {
549
549
  return { errors, warnings };
550
550
  }
551
- this._translatedLocales.add(localeName);
552
- this._defaultLocale = localeName;
553
- this._fillMissingTranslationStrings = !!fillMissingTranslationStrings;
551
+ this.#translatedLocales.add(localeName);
552
+ this.#defaultLocale = localeName;
553
+ this.#fillMissingTranslationStrings = !!fillMissingTranslationStrings;
554
554
  }
555
555
  else {
556
556
  errors.push(new WebpackError('Missing default locale name'));
@@ -566,16 +566,16 @@ class LocalizationPlugin {
566
566
  const { pseudolocales } = localizedData;
567
567
  if (pseudolocales) {
568
568
  for (const [pseudolocaleName, pseudoLocaleOpts] of Object.entries(pseudolocales)) {
569
- if (this._defaultLocale === pseudolocaleName) {
569
+ if (this.#defaultLocale === pseudolocaleName) {
570
570
  errors.push(new WebpackError(`A pseudolocale (${pseudolocaleName}) name is also the default locale name.`));
571
571
  return { errors, warnings };
572
572
  }
573
- if (this._translatedLocales.has(pseudolocaleName)) {
573
+ if (this.#translatedLocales.has(pseudolocaleName)) {
574
574
  errors.push(new WebpackError(`A pseudolocale (${pseudolocaleName}) name is also specified in the translated strings.`));
575
575
  return { errors, warnings };
576
576
  }
577
- this._pseudolocalizers.set(pseudolocaleName, (0, localization_utilities_1.getPseudolocalizer)(pseudoLocaleOpts));
578
- this._translatedLocales.add(pseudolocaleName);
577
+ this.#pseudolocalizers.set(pseudolocaleName, (0, localization_utilities_1.getPseudolocalizer)(pseudoLocaleOpts));
578
+ this.#translatedLocales.add(pseudolocaleName);
579
579
  }
580
580
  }
581
581
  // END options.localizedData.pseudoLocales
@@ -589,15 +589,15 @@ class LocalizationPlugin {
589
589
  if (noStringsLocaleName === undefined ||
590
590
  noStringsLocaleName === null ||
591
591
  !ensureValidLocaleName(noStringsLocaleName)) {
592
- this._noStringsLocaleName = 'none';
592
+ this.#noStringsLocaleName = 'none';
593
593
  }
594
594
  else {
595
- this._noStringsLocaleName = noStringsLocaleName;
595
+ this.#noStringsLocaleName = noStringsLocaleName;
596
596
  }
597
597
  // END options.noStringsLocaleName
598
598
  // START options.formatLocaleForFilename
599
599
  const { formatLocaleForFilename = (localeName) => localeName } = this._options;
600
- this._formatLocaleForFilename = formatLocaleForFilename;
600
+ this.#formatLocaleForFilename = formatLocaleForFilename;
601
601
  // END options.formatLocaleForFilename
602
602
  return { errors, warnings };
603
603
  }