@rushstack/webpack5-localization-plugin 0.13.0 → 0.13.2

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,36 @@
1
1
  {
2
2
  "name": "@rushstack/webpack5-localization-plugin",
3
3
  "entries": [
4
+ {
5
+ "version": "0.13.2",
6
+ "tag": "@rushstack/webpack5-localization-plugin_v0.13.2",
7
+ "date": "Tue, 11 Mar 2025 00:11:25 GMT",
8
+ "comments": {
9
+ "dependency": [
10
+ {
11
+ "comment": "Updating dependency \"@rushstack/localization-utilities\" to `0.13.2`"
12
+ },
13
+ {
14
+ "comment": "Updating dependency \"@rushstack/heft\" to `0.69.3`"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "version": "0.13.1",
21
+ "tag": "@rushstack/webpack5-localization-plugin_v0.13.1",
22
+ "date": "Sat, 01 Mar 2025 05:00:09 GMT",
23
+ "comments": {
24
+ "dependency": [
25
+ {
26
+ "comment": "Updating dependency \"@rushstack/localization-utilities\" to `0.13.1`"
27
+ },
28
+ {
29
+ "comment": "Updating dependency \"@rushstack/heft\" to `0.69.2`"
30
+ }
31
+ ]
32
+ }
33
+ },
4
34
  {
5
35
  "version": "0.13.0",
6
36
  "tag": "@rushstack/webpack5-localization-plugin_v0.13.0",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,16 @@
1
1
  # Change Log - @rushstack/webpack5-localization-plugin
2
2
 
3
- This log was last generated on Thu, 27 Feb 2025 16:10:47 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 11 Mar 2025 00:11:25 GMT and should not be manually modified.
4
+
5
+ ## 0.13.2
6
+ Tue, 11 Mar 2025 00:11:25 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 0.13.1
11
+ Sat, 01 Mar 2025 05:00:09 GMT
12
+
13
+ _Version update only_
4
14
 
5
15
  ## 0.13.0
6
16
  Thu, 27 Feb 2025 16:10:47 GMT
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.51.0"
8
+ "packageVersion": "7.51.1"
9
9
  }
10
10
  ]
11
11
  }
@@ -17,15 +17,29 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
17
17
  }) : function(o, v) {
18
18
  o["default"] = v;
19
19
  });
20
- var __importStar = (this && this.__importStar) || function (mod) {
21
- if (mod && mod.__esModule) return mod;
22
- var result = {};
23
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
- __setModuleDefault(result, mod);
25
- return result;
26
- };
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
+ };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
27
37
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.processNonLocalizedAsset = exports.processNonLocalizedAssetCachedAsync = exports.processLocalizedAsset = exports.processLocalizedAssetCachedAsync = exports.PLACEHOLDER_REGEX = void 0;
38
+ exports.PLACEHOLDER_REGEX = void 0;
39
+ exports.processLocalizedAssetCachedAsync = processLocalizedAssetCachedAsync;
40
+ exports.processLocalizedAsset = processLocalizedAsset;
41
+ exports.processNonLocalizedAssetCachedAsync = processNonLocalizedAssetCachedAsync;
42
+ exports.processNonLocalizedAsset = processNonLocalizedAsset;
29
43
  const Constants = __importStar(require("./utilities/Constants"));
30
44
  exports.PLACEHOLDER_REGEX = new RegExp(`${Constants.STRING_PLACEHOLDER_PREFIX}_([A-C])_(\\\\*)_([0-9a-f$]+)_`, 'g');
31
45
  async function processLocalizedAssetCachedAsync(options) {
@@ -55,7 +69,6 @@ async function processLocalizedAssetCachedAsync(options) {
55
69
  }
56
70
  return localizedFiles;
57
71
  }
58
- exports.processLocalizedAssetCachedAsync = processLocalizedAssetCachedAsync;
59
72
  function processLocalizedAsset(options) {
60
73
  const { compilation, asset, chunk, filenameTemplate, locales, formatLocaleForFilenameFn } = options;
61
74
  const { sources, WebpackError } = compilation.compiler.webpack;
@@ -112,7 +125,6 @@ function processLocalizedAsset(options) {
112
125
  processedAssets
113
126
  };
114
127
  }
115
- exports.processLocalizedAsset = processLocalizedAsset;
116
128
  async function processNonLocalizedAssetCachedAsync(options) {
117
129
  const { compilation, asset, cache } = options;
118
130
  const { source: originalSource } = asset;
@@ -130,7 +142,6 @@ async function processNonLocalizedAssetCachedAsync(options) {
130
142
  compilation.renameAsset(originName, filename);
131
143
  }
132
144
  }
133
- exports.processNonLocalizedAssetCachedAsync = processNonLocalizedAssetCachedAsync;
134
145
  function processNonLocalizedAsset(options) {
135
146
  const { asset, fileName, compilation, formatLocaleForFilenameFn, hasUrlGenerator } = options;
136
147
  const { sources, WebpackError } = compilation.compiler.webpack;
@@ -165,7 +176,6 @@ function processNonLocalizedAsset(options) {
165
176
  info
166
177
  };
167
178
  }
168
- exports.processNonLocalizedAsset = processNonLocalizedAsset;
169
179
  const ESCAPE_MAP = new Map([
170
180
  ['\r', 'r'],
171
181
  ['\n', 'n'],
@@ -1 +1 @@
1
- {"version":3,"file":"AssetProcessor.js","sourceRoot":"","sources":["../src/AssetProcessor.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAI3D,iEAAmD;AAkEtC,QAAA,iBAAiB,GAAW,IAAI,MAAM,CACjD,GAAG,SAAS,CAAC,yBAAyB,gCAAgC,EACtE,GAAG,CACJ,CA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CAAC;gBACF,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;gBAC1C,MAAM;YACR,CAAC;YACD,KAAK,SAAS,CAAC,uBAAuB,CAAC,CAAC,CAAC;gBACvC,sCAAsC,KAAtC,sCAAsC,GAAK,CAAC,MAAc,EAAE,EAAE,CAC5D,IAAI,CAAC,SAAS,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,EAAC;gBACpD,MAAM,cAAc,GAAkC;oBACpD,IAAI,EAAE,SAAS;oBACf,KAAK;oBACL,GAAG;oBACH,OAAO,EAAE,sCAAsC;iBAChD,CAAC;gBACF,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;gBAC1C,MAAM;YACR,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,IAAI,KAAK,CAAC,oBAAoB,YAAY,eAAe,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;YAC7F,CAAC;QACH,CAAC;QAED,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC;IACnE,CAAC;IAED,OAAO;QACL,MAAM;QACN,oBAAoB;KACrB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { Asset, AssetInfo, Chunk, Compilation, sources } from 'webpack';\n\nimport * as Constants from './utilities/Constants';\nimport type { LocalizationPlugin, IStringPlaceholder } from './LocalizationPlugin';\nimport type { ILocalizedWebpackChunk, IAssetPathOptions } from './webpackInterfaces';\n\ninterface ILocalizedReconstructionElement {\n kind: 'localized';\n start: number;\n end: number;\n escapedBackslash: string;\n data: IStringPlaceholder;\n}\n\ninterface IDynamicReconstructionElement {\n kind: 'dynamic';\n start: number;\n end: number;\n valueFn: (locale: string) => string;\n}\n\ntype IReconstructionElement = ILocalizedReconstructionElement | IDynamicReconstructionElement;\ntype FormatLocaleForFilenameFn = (locale: string) => string;\n\ninterface IParseResult {\n issues: string[];\n reconstructionSeries: IReconstructionElement[];\n}\n\ninterface ILocalizedReconstructionResult {\n result: sources.ReplaceSource;\n issues: string[];\n}\n\ninterface INonLocalizedReconstructionResult {\n result: sources.ReplaceSource;\n issues: string[];\n}\n\nexport interface IProcessAssetOptionsBase {\n plugin: LocalizationPlugin;\n compilation: Compilation;\n cache: ReturnType<Compilation['getCache']>;\n chunk: Chunk;\n asset: Asset;\n}\n\nexport interface IProcessNonLocalizedAssetOptions extends IProcessAssetOptionsBase {\n fileName: string;\n hasUrlGenerator: boolean;\n noStringsLocaleName: string;\n formatLocaleForFilenameFn: FormatLocaleForFilenameFn;\n}\n\nexport interface IProcessLocalizedAssetOptions extends IProcessAssetOptionsBase {\n locales: Set<string>;\n fillMissingTranslationStrings: boolean;\n defaultLocale: string;\n passthroughLocaleName: string | undefined;\n filenameTemplate: Parameters<typeof Compilation.prototype.getAssetPath>[0];\n formatLocaleForFilenameFn: FormatLocaleForFilenameFn;\n}\n\nexport interface IProcessAssetResult {\n filename: string;\n asset: sources.Source;\n}\n\nexport const PLACEHOLDER_REGEX: RegExp = new RegExp(\n `${Constants.STRING_PLACEHOLDER_PREFIX}_([A-C])_(\\\\\\\\*)_([0-9a-f$]+)_`,\n 'g'\n);\n\nexport interface IProcessedAsset {\n filename: string;\n source: sources.CachedSource;\n info: AssetInfo;\n}\n\nexport interface IProcessLocalizedAssetResult {\n localizedFiles: Record<string, string>;\n processedAssets: IProcessedAsset[];\n}\n\ntype ItemCacheFacade = ReturnType<ReturnType<Compilation['getCache']>['getItemCache']>;\n\nexport async function processLocalizedAssetCachedAsync(\n options: IProcessLocalizedAssetOptions\n): Promise<Record<string, string>> {\n const { compilation, asset, cache, chunk } = options;\n const { source: originalSource } = asset;\n\n type ETag = NonNullable<ReturnType<typeof cache.getLazyHashedEtag>>;\n const eTag: ETag | null = cache.getLazyHashedEtag(originalSource);\n const { name: originName } = asset;\n const cacheItem: ItemCacheFacade = cache.getItemCache(originName, eTag);\n let output: IProcessLocalizedAssetResult | undefined = await cacheItem.getPromise();\n\n if (!output) {\n output = processLocalizedAsset(options);\n await cacheItem.storePromise(output);\n }\n\n const { localizedFiles, processedAssets } = output;\n\n (chunk as ILocalizedWebpackChunk).localizedFiles = localizedFiles;\n\n for (const { filename, source, info } of processedAssets) {\n if (originName === filename) {\n // This helper throws if the asset doesn't already exist\n // Use the function form so that the object identity of `related` is preserved.\n // Since we already read the original info, we don't need fancy merge logic.\n compilation.updateAsset(filename, source, () => info);\n } else {\n // This helper throws if the asset already exists\n compilation.emitAsset(filename, source, info);\n }\n }\n\n return localizedFiles;\n}\n\nexport function processLocalizedAsset(options: IProcessLocalizedAssetOptions): IProcessLocalizedAssetResult {\n const { compilation, asset, chunk, filenameTemplate, locales, formatLocaleForFilenameFn } = options;\n\n const { sources, WebpackError } = compilation.compiler.webpack;\n\n const { source: originalSource } = asset;\n\n const rawSource: sources.CachedSource =\n originalSource instanceof sources.CachedSource\n ? originalSource\n : new sources.CachedSource(originalSource);\n const assetSource: string = rawSource.source().toString();\n\n const parsedAsset: IParseResult = _parseStringToReconstructionSequence(\n options.plugin,\n assetSource,\n formatLocaleForFilenameFn\n );\n\n const { issues } = parsedAsset;\n\n const localizedFiles: Record<string, string> = {};\n\n const processedAssets: IProcessedAsset[] = [];\n\n const { info: originInfo, name: originName } = asset;\n if (!originInfo.related) {\n originInfo.related = {};\n }\n\n for (const locale of locales) {\n const { issues: localeIssues, result: localeResult } = _reconstructLocalized(\n new sources.ReplaceSource(rawSource, locale),\n parsedAsset.reconstructionSeries,\n locale,\n options.fillMissingTranslationStrings ? options.defaultLocale : undefined,\n options.passthroughLocaleName\n );\n\n for (const issue of localeIssues) {\n issues.push(issue);\n }\n\n const data: IAssetPathOptions = {\n chunk,\n contentHashType: 'javascript',\n // The locale property will get processed by the extension to the getAssetPath hook\n locale\n };\n\n const fileName: string = compilation.getAssetPath(filenameTemplate, data);\n\n const info: AssetInfo & { locale: string } = {\n ...originInfo,\n locale\n };\n\n const wrapped: sources.CachedSource = new sources.CachedSource(localeResult);\n localizedFiles[locale] = fileName;\n\n processedAssets.push({\n filename: fileName,\n source: wrapped,\n info\n });\n\n // If file already exists\n if (originName !== fileName) {\n // If A.related points to B, B.related can't point to A or the stats emitter explodes\n // So just strip the related object for the localized assets\n info.related = undefined;\n // We omit the `related` property that does a self-reference.\n originInfo.related[locale] = fileName;\n }\n }\n\n if (issues.length > 0) {\n compilation.errors.push(\n new WebpackError(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n\n return {\n localizedFiles,\n processedAssets\n };\n}\n\nexport async function processNonLocalizedAssetCachedAsync(\n options: IProcessNonLocalizedAssetOptions\n): Promise<void> {\n const { compilation, asset, cache } = options;\n const { source: originalSource } = asset;\n\n type ETag = NonNullable<ReturnType<typeof cache.getLazyHashedEtag>>;\n const eTag: ETag | null = cache.getLazyHashedEtag(originalSource);\n const { name: originName } = asset;\n const cacheItem: ItemCacheFacade = cache.getItemCache(originName, eTag);\n let output: IProcessedAsset | undefined = await cacheItem.getPromise();\n\n if (!output) {\n output = processNonLocalizedAsset(options);\n await cacheItem.storePromise(output);\n }\n\n const { filename, source, info } = output;\n compilation.updateAsset(originName, source, info);\n if (originName !== filename) {\n compilation.renameAsset(originName, filename);\n }\n}\n\nexport function processNonLocalizedAsset(options: IProcessNonLocalizedAssetOptions): IProcessedAsset {\n const { asset, fileName, compilation, formatLocaleForFilenameFn, hasUrlGenerator } = options;\n\n const { sources, WebpackError } = compilation.compiler.webpack;\n\n const rawSource: sources.Source = asset.source;\n let cachedSource: sources.CachedSource =\n rawSource instanceof sources.CachedSource ? rawSource : new sources.CachedSource(rawSource);\n\n const { info: originInfo } = asset;\n const locale: string = options.noStringsLocaleName;\n\n if (hasUrlGenerator) {\n const assetSource: string = cachedSource.source().toString();\n const parsedAsset: IParseResult = _parseStringToReconstructionSequence(\n options.plugin,\n assetSource,\n formatLocaleForFilenameFn\n );\n\n const { issues } = parsedAsset;\n\n const { issues: localeIssues, result } = _reconstructNonLocalized(\n new sources.ReplaceSource(cachedSource, locale),\n parsedAsset.reconstructionSeries,\n locale\n );\n\n for (const issue of localeIssues) {\n issues.push(issue);\n }\n\n if (issues.length > 0) {\n options.compilation.errors.push(\n new WebpackError(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n\n cachedSource = new sources.CachedSource(result);\n } else {\n // Force the CachedSource to cache the concatenated *string*, so that the subsequent ask for the buffer is fast\n cachedSource.source();\n }\n\n const info: AssetInfo = {\n ...originInfo,\n locale\n };\n\n return {\n filename: fileName,\n source: cachedSource,\n info\n };\n}\n\nconst ESCAPE_MAP: Map<string, string> = new Map([\n ['\\r', 'r'],\n ['\\n', 'n'],\n ['\\t', 't'],\n ['\"', 'u0022'],\n [\"'\", 'u0027']\n]);\n\nconst BACKSLASH_REGEX: RegExp = /\\\\/g;\nconst ESCAPE_REGEX: RegExp = /[\\r\\n\\t\"']/g;\n\nfunction _reconstructLocalized(\n result: sources.ReplaceSource,\n reconstructionSeries: IReconstructionElement[],\n locale: string,\n fallbackLocale: string | undefined,\n passthroughLocale: string | undefined\n): ILocalizedReconstructionResult {\n const issues: string[] = [];\n\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'localized': {\n const { data } = element;\n const { stringName, translations } = data;\n let newValue: string | undefined =\n locale === passthroughLocale ? stringName : translations.get(locale)?.get(stringName);\n if (fallbackLocale && newValue === undefined) {\n newValue = translations.get(fallbackLocale)?.get(stringName);\n }\n\n if (newValue === undefined) {\n issues.push(\n `The string \"${stringName}\" in \"${data.locFilePath}\" is missing in the locale ${locale}`\n );\n\n newValue = '-- MISSING STRING --';\n }\n\n const escapedBackslash: string = element.escapedBackslash || '\\\\';\n\n if (newValue.includes('\\\\')) {\n // The vast majority of localized strings do not contain `\\\\`, so this check avoids an allocation.\n // Replace backslashes with the properly escaped backslash\n BACKSLASH_REGEX.lastIndex = -1;\n newValue = newValue.replace(BACKSLASH_REGEX, escapedBackslash);\n }\n\n // Ensure the the quotemark, apostrophe, tab, and newline characters are properly escaped\n ESCAPE_REGEX.lastIndex = -1;\n if (ESCAPE_REGEX.test(newValue)) {\n // The majority of localized strings do not contain the characters that need to be escaped,\n // so this check avoids an allocation.\n // @todo: look into using JSON.parse(...) to get the escaping characters\n const escapingCharacterSequence: string = escapedBackslash.slice(escapedBackslash.length / 2);\n newValue = newValue.replace(\n ESCAPE_REGEX,\n (match) => `${escapingCharacterSequence}${ESCAPE_MAP.get(match)}`\n );\n }\n\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n\n case 'dynamic': {\n const newValue: string = element.valueFn(locale);\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n }\n }\n\n return {\n issues,\n result\n };\n}\n\nfunction _reconstructNonLocalized(\n result: sources.ReplaceSource,\n reconstructionSeries: IReconstructionElement[],\n noStringsLocaleName: string\n): INonLocalizedReconstructionResult {\n const issues: string[] = [];\n\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'localized': {\n issues.push(\n `The string \"${element.data.stringName}\" in \"${element.data.locFilePath}\" appeared in an asset ` +\n 'that is not expected to contain localized resources.'\n );\n\n const newValue: string = '-- NOT EXPECTED TO BE LOCALIZED --';\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n\n case 'dynamic': {\n const newValue: string = element.valueFn(noStringsLocaleName);\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n }\n }\n\n return {\n issues,\n result\n };\n}\n\nfunction _parseStringToReconstructionSequence(\n plugin: LocalizationPlugin,\n source: string,\n formatLocaleForFilenameFn: FormatLocaleForFilenameFn\n): IParseResult {\n const issues: string[] = [];\n const reconstructionSeries: IReconstructionElement[] = [];\n\n let jsonStringifyFormatLocaleForFilenameFn: FormatLocaleForFilenameFn | undefined;\n\n let index: number = source.indexOf(Constants.STRING_PLACEHOLDER_PREFIX);\n const increment: number = Constants.STRING_PLACEHOLDER_PREFIX.length + 1;\n while (index >= 0) {\n const start: number = index;\n const elementStart: number = index + increment;\n const elementLabel: string = source.charAt(elementStart);\n let end: number = elementStart + 2;\n\n switch (elementLabel) {\n case Constants.STRING_PLACEHOLDER_LABEL: {\n const backslashEnd: number = source.indexOf('_', end);\n const escapedBackslash: string = source.slice(end, backslashEnd);\n end = backslashEnd + 1;\n const serialEnd: number = source.indexOf('_', end);\n const serial: string = source.slice(end, serialEnd);\n end = serialEnd + 1;\n\n const stringData: IStringPlaceholder | undefined = plugin.getDataForSerialNumber(serial);\n if (!stringData) {\n issues.push(`Missing placeholder ${serial}`);\n } else {\n const localizedElement: ILocalizedReconstructionElement = {\n kind: 'localized',\n start,\n end,\n escapedBackslash,\n data: stringData\n };\n reconstructionSeries.push(localizedElement);\n }\n break;\n }\n case Constants.LOCALE_NAME_PLACEHOLDER_LABEL: {\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n start,\n end,\n valueFn: formatLocaleForFilenameFn\n };\n reconstructionSeries.push(dynamicElement);\n break;\n }\n case Constants.JSONP_PLACEHOLDER_LABEL: {\n jsonStringifyFormatLocaleForFilenameFn ||= (locale: string) =>\n JSON.stringify(formatLocaleForFilenameFn(locale));\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n start,\n end,\n valueFn: jsonStringifyFormatLocaleForFilenameFn\n };\n reconstructionSeries.push(dynamicElement);\n break;\n }\n default: {\n throw new Error(`Unexpected label ${elementLabel} in pattern ${source.slice(start, end)}`);\n }\n }\n\n index = source.indexOf(Constants.STRING_PLACEHOLDER_PREFIX, end);\n }\n\n return {\n issues,\n reconstructionSeries\n };\n}\n"]}
1
+ {"version":3,"file":"AssetProcessor.js","sourceRoot":"","sources":["../src/AssetProcessor.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwF3D,4EAkCC;AAED,sDAsFC;AAED,kFAsBC;AAED,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SAAS;oBACf,KAAK;oBACL,GAAG;oBACH,OAAO,EAAE,yBAAyB;iBACnC,CAAC;gBACF,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;gBAC1C,MAAM;YACR,CAAC;YACD,KAAK,SAAS,CAAC,uBAAuB,CAAC,CAAC,CAAC;gBACvC,sCAAsC,KAAtC,sCAAsC,GAAK,CAAC,MAAc,EAAE,EAAE,CAC5D,IAAI,CAAC,SAAS,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,EAAC;gBACpD,MAAM,cAAc,GAAkC;oBACpD,IAAI,EAAE,SAAS;oBACf,KAAK;oBACL,GAAG;oBACH,OAAO,EAAE,sCAAsC;iBAChD,CAAC;gBACF,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;gBAC1C,MAAM;YACR,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,IAAI,KAAK,CAAC,oBAAoB,YAAY,eAAe,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;YAC7F,CAAC;QACH,CAAC;QAED,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC;IACnE,CAAC;IAED,OAAO;QACL,MAAM;QACN,oBAAoB;KACrB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { Asset, AssetInfo, Chunk, Compilation, sources } from 'webpack';\n\nimport * as Constants from './utilities/Constants';\nimport type { LocalizationPlugin, IStringPlaceholder } from './LocalizationPlugin';\nimport type { ILocalizedWebpackChunk, IAssetPathOptions } from './webpackInterfaces';\n\ninterface ILocalizedReconstructionElement {\n kind: 'localized';\n start: number;\n end: number;\n escapedBackslash: string;\n data: IStringPlaceholder;\n}\n\ninterface IDynamicReconstructionElement {\n kind: 'dynamic';\n start: number;\n end: number;\n valueFn: (locale: string) => string;\n}\n\ntype IReconstructionElement = ILocalizedReconstructionElement | IDynamicReconstructionElement;\ntype FormatLocaleForFilenameFn = (locale: string) => string;\n\ninterface IParseResult {\n issues: string[];\n reconstructionSeries: IReconstructionElement[];\n}\n\ninterface ILocalizedReconstructionResult {\n result: sources.ReplaceSource;\n issues: string[];\n}\n\ninterface INonLocalizedReconstructionResult {\n result: sources.ReplaceSource;\n issues: string[];\n}\n\nexport interface IProcessAssetOptionsBase {\n plugin: LocalizationPlugin;\n compilation: Compilation;\n cache: ReturnType<Compilation['getCache']>;\n chunk: Chunk;\n asset: Asset;\n}\n\nexport interface IProcessNonLocalizedAssetOptions extends IProcessAssetOptionsBase {\n fileName: string;\n hasUrlGenerator: boolean;\n noStringsLocaleName: string;\n formatLocaleForFilenameFn: FormatLocaleForFilenameFn;\n}\n\nexport interface IProcessLocalizedAssetOptions extends IProcessAssetOptionsBase {\n locales: Set<string>;\n fillMissingTranslationStrings: boolean;\n defaultLocale: string;\n passthroughLocaleName: string | undefined;\n filenameTemplate: Parameters<typeof Compilation.prototype.getAssetPath>[0];\n formatLocaleForFilenameFn: FormatLocaleForFilenameFn;\n}\n\nexport interface IProcessAssetResult {\n filename: string;\n asset: sources.Source;\n}\n\nexport const PLACEHOLDER_REGEX: RegExp = new RegExp(\n `${Constants.STRING_PLACEHOLDER_PREFIX}_([A-C])_(\\\\\\\\*)_([0-9a-f$]+)_`,\n 'g'\n);\n\nexport interface IProcessedAsset {\n filename: string;\n source: sources.CachedSource;\n info: AssetInfo;\n}\n\nexport interface IProcessLocalizedAssetResult {\n localizedFiles: Record<string, string>;\n processedAssets: IProcessedAsset[];\n}\n\ntype ItemCacheFacade = ReturnType<ReturnType<Compilation['getCache']>['getItemCache']>;\n\nexport async function processLocalizedAssetCachedAsync(\n options: IProcessLocalizedAssetOptions\n): Promise<Record<string, string>> {\n const { compilation, asset, cache, chunk } = options;\n const { source: originalSource } = asset;\n\n type ETag = NonNullable<ReturnType<typeof cache.getLazyHashedEtag>>;\n const eTag: ETag | null = cache.getLazyHashedEtag(originalSource);\n const { name: originName } = asset;\n const cacheItem: ItemCacheFacade = cache.getItemCache(originName, eTag);\n let output: IProcessLocalizedAssetResult | undefined = await cacheItem.getPromise();\n\n if (!output) {\n output = processLocalizedAsset(options);\n await cacheItem.storePromise(output);\n }\n\n const { localizedFiles, processedAssets } = output;\n\n (chunk as ILocalizedWebpackChunk).localizedFiles = localizedFiles;\n\n for (const { filename, source, info } of processedAssets) {\n if (originName === filename) {\n // This helper throws if the asset doesn't already exist\n // Use the function form so that the object identity of `related` is preserved.\n // Since we already read the original info, we don't need fancy merge logic.\n compilation.updateAsset(filename, source, () => info);\n } else {\n // This helper throws if the asset already exists\n compilation.emitAsset(filename, source, info);\n }\n }\n\n return localizedFiles;\n}\n\nexport function processLocalizedAsset(options: IProcessLocalizedAssetOptions): IProcessLocalizedAssetResult {\n const { compilation, asset, chunk, filenameTemplate, locales, formatLocaleForFilenameFn } = options;\n\n const { sources, WebpackError } = compilation.compiler.webpack;\n\n const { source: originalSource } = asset;\n\n const rawSource: sources.CachedSource =\n originalSource instanceof sources.CachedSource\n ? originalSource\n : new sources.CachedSource(originalSource);\n const assetSource: string = rawSource.source().toString();\n\n const parsedAsset: IParseResult = _parseStringToReconstructionSequence(\n options.plugin,\n assetSource,\n formatLocaleForFilenameFn\n );\n\n const { issues } = parsedAsset;\n\n const localizedFiles: Record<string, string> = {};\n\n const processedAssets: IProcessedAsset[] = [];\n\n const { info: originInfo, name: originName } = asset;\n if (!originInfo.related) {\n originInfo.related = {};\n }\n\n for (const locale of locales) {\n const { issues: localeIssues, result: localeResult } = _reconstructLocalized(\n new sources.ReplaceSource(rawSource, locale),\n parsedAsset.reconstructionSeries,\n locale,\n options.fillMissingTranslationStrings ? options.defaultLocale : undefined,\n options.passthroughLocaleName\n );\n\n for (const issue of localeIssues) {\n issues.push(issue);\n }\n\n const data: IAssetPathOptions = {\n chunk,\n contentHashType: 'javascript',\n // The locale property will get processed by the extension to the getAssetPath hook\n locale\n };\n\n const fileName: string = compilation.getAssetPath(filenameTemplate, data);\n\n const info: AssetInfo & { locale: string } = {\n ...originInfo,\n locale\n };\n\n const wrapped: sources.CachedSource = new sources.CachedSource(localeResult);\n localizedFiles[locale] = fileName;\n\n processedAssets.push({\n filename: fileName,\n source: wrapped,\n info\n });\n\n // If file already exists\n if (originName !== fileName) {\n // If A.related points to B, B.related can't point to A or the stats emitter explodes\n // So just strip the related object for the localized assets\n info.related = undefined;\n // We omit the `related` property that does a self-reference.\n originInfo.related[locale] = fileName;\n }\n }\n\n if (issues.length > 0) {\n compilation.errors.push(\n new WebpackError(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n\n return {\n localizedFiles,\n processedAssets\n };\n}\n\nexport async function processNonLocalizedAssetCachedAsync(\n options: IProcessNonLocalizedAssetOptions\n): Promise<void> {\n const { compilation, asset, cache } = options;\n const { source: originalSource } = asset;\n\n type ETag = NonNullable<ReturnType<typeof cache.getLazyHashedEtag>>;\n const eTag: ETag | null = cache.getLazyHashedEtag(originalSource);\n const { name: originName } = asset;\n const cacheItem: ItemCacheFacade = cache.getItemCache(originName, eTag);\n let output: IProcessedAsset | undefined = await cacheItem.getPromise();\n\n if (!output) {\n output = processNonLocalizedAsset(options);\n await cacheItem.storePromise(output);\n }\n\n const { filename, source, info } = output;\n compilation.updateAsset(originName, source, info);\n if (originName !== filename) {\n compilation.renameAsset(originName, filename);\n }\n}\n\nexport function processNonLocalizedAsset(options: IProcessNonLocalizedAssetOptions): IProcessedAsset {\n const { asset, fileName, compilation, formatLocaleForFilenameFn, hasUrlGenerator } = options;\n\n const { sources, WebpackError } = compilation.compiler.webpack;\n\n const rawSource: sources.Source = asset.source;\n let cachedSource: sources.CachedSource =\n rawSource instanceof sources.CachedSource ? rawSource : new sources.CachedSource(rawSource);\n\n const { info: originInfo } = asset;\n const locale: string = options.noStringsLocaleName;\n\n if (hasUrlGenerator) {\n const assetSource: string = cachedSource.source().toString();\n const parsedAsset: IParseResult = _parseStringToReconstructionSequence(\n options.plugin,\n assetSource,\n formatLocaleForFilenameFn\n );\n\n const { issues } = parsedAsset;\n\n const { issues: localeIssues, result } = _reconstructNonLocalized(\n new sources.ReplaceSource(cachedSource, locale),\n parsedAsset.reconstructionSeries,\n locale\n );\n\n for (const issue of localeIssues) {\n issues.push(issue);\n }\n\n if (issues.length > 0) {\n options.compilation.errors.push(\n new WebpackError(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n\n cachedSource = new sources.CachedSource(result);\n } else {\n // Force the CachedSource to cache the concatenated *string*, so that the subsequent ask for the buffer is fast\n cachedSource.source();\n }\n\n const info: AssetInfo = {\n ...originInfo,\n locale\n };\n\n return {\n filename: fileName,\n source: cachedSource,\n info\n };\n}\n\nconst ESCAPE_MAP: Map<string, string> = new Map([\n ['\\r', 'r'],\n ['\\n', 'n'],\n ['\\t', 't'],\n ['\"', 'u0022'],\n [\"'\", 'u0027']\n]);\n\nconst BACKSLASH_REGEX: RegExp = /\\\\/g;\nconst ESCAPE_REGEX: RegExp = /[\\r\\n\\t\"']/g;\n\nfunction _reconstructLocalized(\n result: sources.ReplaceSource,\n reconstructionSeries: IReconstructionElement[],\n locale: string,\n fallbackLocale: string | undefined,\n passthroughLocale: string | undefined\n): ILocalizedReconstructionResult {\n const issues: string[] = [];\n\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'localized': {\n const { data } = element;\n const { stringName, translations } = data;\n let newValue: string | undefined =\n locale === passthroughLocale ? stringName : translations.get(locale)?.get(stringName);\n if (fallbackLocale && newValue === undefined) {\n newValue = translations.get(fallbackLocale)?.get(stringName);\n }\n\n if (newValue === undefined) {\n issues.push(\n `The string \"${stringName}\" in \"${data.locFilePath}\" is missing in the locale ${locale}`\n );\n\n newValue = '-- MISSING STRING --';\n }\n\n const escapedBackslash: string = element.escapedBackslash || '\\\\';\n\n if (newValue.includes('\\\\')) {\n // The vast majority of localized strings do not contain `\\\\`, so this check avoids an allocation.\n // Replace backslashes with the properly escaped backslash\n BACKSLASH_REGEX.lastIndex = -1;\n newValue = newValue.replace(BACKSLASH_REGEX, escapedBackslash);\n }\n\n // Ensure the the quotemark, apostrophe, tab, and newline characters are properly escaped\n ESCAPE_REGEX.lastIndex = -1;\n if (ESCAPE_REGEX.test(newValue)) {\n // The majority of localized strings do not contain the characters that need to be escaped,\n // so this check avoids an allocation.\n // @todo: look into using JSON.parse(...) to get the escaping characters\n const escapingCharacterSequence: string = escapedBackslash.slice(escapedBackslash.length / 2);\n newValue = newValue.replace(\n ESCAPE_REGEX,\n (match) => `${escapingCharacterSequence}${ESCAPE_MAP.get(match)}`\n );\n }\n\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n\n case 'dynamic': {\n const newValue: string = element.valueFn(locale);\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n }\n }\n\n return {\n issues,\n result\n };\n}\n\nfunction _reconstructNonLocalized(\n result: sources.ReplaceSource,\n reconstructionSeries: IReconstructionElement[],\n noStringsLocaleName: string\n): INonLocalizedReconstructionResult {\n const issues: string[] = [];\n\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'localized': {\n issues.push(\n `The string \"${element.data.stringName}\" in \"${element.data.locFilePath}\" appeared in an asset ` +\n 'that is not expected to contain localized resources.'\n );\n\n const newValue: string = '-- NOT EXPECTED TO BE LOCALIZED --';\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n\n case 'dynamic': {\n const newValue: string = element.valueFn(noStringsLocaleName);\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n }\n }\n\n return {\n issues,\n result\n };\n}\n\nfunction _parseStringToReconstructionSequence(\n plugin: LocalizationPlugin,\n source: string,\n formatLocaleForFilenameFn: FormatLocaleForFilenameFn\n): IParseResult {\n const issues: string[] = [];\n const reconstructionSeries: IReconstructionElement[] = [];\n\n let jsonStringifyFormatLocaleForFilenameFn: FormatLocaleForFilenameFn | undefined;\n\n let index: number = source.indexOf(Constants.STRING_PLACEHOLDER_PREFIX);\n const increment: number = Constants.STRING_PLACEHOLDER_PREFIX.length + 1;\n while (index >= 0) {\n const start: number = index;\n const elementStart: number = index + increment;\n const elementLabel: string = source.charAt(elementStart);\n let end: number = elementStart + 2;\n\n switch (elementLabel) {\n case Constants.STRING_PLACEHOLDER_LABEL: {\n const backslashEnd: number = source.indexOf('_', end);\n const escapedBackslash: string = source.slice(end, backslashEnd);\n end = backslashEnd + 1;\n const serialEnd: number = source.indexOf('_', end);\n const serial: string = source.slice(end, serialEnd);\n end = serialEnd + 1;\n\n const stringData: IStringPlaceholder | undefined = plugin.getDataForSerialNumber(serial);\n if (!stringData) {\n issues.push(`Missing placeholder ${serial}`);\n } else {\n const localizedElement: ILocalizedReconstructionElement = {\n kind: 'localized',\n start,\n end,\n escapedBackslash,\n data: stringData\n };\n reconstructionSeries.push(localizedElement);\n }\n break;\n }\n case Constants.LOCALE_NAME_PLACEHOLDER_LABEL: {\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n start,\n end,\n valueFn: formatLocaleForFilenameFn\n };\n reconstructionSeries.push(dynamicElement);\n break;\n }\n case Constants.JSONP_PLACEHOLDER_LABEL: {\n jsonStringifyFormatLocaleForFilenameFn ||= (locale: string) =>\n JSON.stringify(formatLocaleForFilenameFn(locale));\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n start,\n end,\n valueFn: jsonStringifyFormatLocaleForFilenameFn\n };\n reconstructionSeries.push(dynamicElement);\n break;\n }\n default: {\n throw new Error(`Unexpected label ${elementLabel} in pattern ${source.slice(start, end)}`);\n }\n }\n\n index = source.indexOf(Constants.STRING_PLACEHOLDER_PREFIX, end);\n }\n\n return {\n issues,\n reconstructionSeries\n };\n}\n"]}
@@ -17,15 +17,26 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
17
17
  }) : function(o, v) {
18
18
  o["default"] = v;
19
19
  });
20
- var __importStar = (this && this.__importStar) || function (mod) {
21
- if (mod && mod.__esModule) return mod;
22
- var result = {};
23
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
- __setModuleDefault(result, mod);
25
- return result;
26
- };
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
+ };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
27
37
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.LocalizationPlugin = exports.getPluginInstance = void 0;
38
+ exports.LocalizationPlugin = void 0;
39
+ exports.getPluginInstance = getPluginInstance;
29
40
  const path = __importStar(require("path"));
30
41
  const localization_utilities_1 = require("@rushstack/localization-utilities");
31
42
  const Async_1 = require("@rushstack/node-core-library/lib/Async");
@@ -47,7 +58,6 @@ function getPluginInstance(compiler) {
47
58
  }
48
59
  return instance;
49
60
  }
50
- exports.getPluginInstance = getPluginInstance;
51
61
  /**
52
62
  * This plugin facilitates localization in webpack.
53
63
  *
@@ -1 +1 @@
1
- {"version":3,"file":"LocalizationPlugin.js","sourceRoot":"","sources":["../src/LocalizationPlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,2CAA6B;AAe7B,8EAA6G;AAC7G,kEAA+D;AAE/D,iEAAmD;AASnD,2DAA+D;AAC/D,qDAAyG;AACzG,6CAA+E;AAC/E,+DAAuD;AAkCvD,MAAM,WAAW,GAAmB,cAAc,CAAC;AAEnD,MA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EAAE,CAAC;QACtC,+DAA+D;QAC/D,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QACrC,MAAM,OAAO,GAAW,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC5D,2FAA2F;YAC3F,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;gBAC/C,IAAI,GAAG,EAAE,CAAC;oBACR,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;gBACrB,CAAC;qBAAM,IAAI,CAAC,IAAI,EAAE,CAAC;oBACjB,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC,cAAc,aAAa,EAAE,CAAC,CAAC,CAAC;gBAC1D,CAAC;gBACD,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,gBAAgB,GAAsB,IAAA,qCAAY,EAAC;YACvD,QAAQ,EAAE,aAAa;YACvB,OAAO;SACR,CAAC,CAAC;QAEH,OAAO,gCAAgC,CAAC,gBAAgB,CAAC,CAAC;IAC5D,CAAC;SAAM,CAAC;QACN,OAAO,aAAa,YAAY,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;IAC/F,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as path from 'path';\n\nimport type {\n Asset,\n Chunk,\n ChunkGraph,\n Compilation,\n Compiler,\n LoaderContext,\n Module,\n runtime,\n WebpackError,\n WebpackPluginInstance\n} from 'webpack';\n\nimport { getPseudolocalizer, type ILocalizationFile, parseResJson } from '@rushstack/localization-utilities';\nimport { Async } from '@rushstack/node-core-library/lib/Async';\n\nimport * as Constants from './utilities/Constants';\nimport type {\n ILocalizationPluginOptions,\n ILocalizationStats,\n ILocaleFileData,\n ILocaleFileObject,\n IResolvedMissingTranslations\n} from './interfaces';\nimport type { IAssetPathOptions } from './webpackInterfaces';\nimport { markEntity, getMark } from './utilities/EntityMarker';\nimport { processLocalizedAssetCachedAsync, processNonLocalizedAssetCachedAsync } from './AssetProcessor';\nimport { getHashFunction, type HashFn, updateAssetHashes } from './trueHashes';\nimport { chunkIsJs } from './utilities/chunkUtilities';\n\n/**\n * @public\n */\nexport interface IStringPlaceholder {\n /**\n * The literal string that will be injected for later replacement.\n */\n value: string;\n /**\n * The identifier for this particular placeholder, for lookup.\n */\n suffix: string;\n /**\n * The values of this string in each output locale.\n */\n translations: ReadonlyMap<string, ReadonlyMap<string, string>>;\n /**\n * The key used to identify the source file containing the string.\n */\n locFilePath: string;\n /**\n * The identifier of the string within its original source file.\n */\n stringName: string;\n}\n\nexport interface IFileTranslationInfo {\n placeholders: Map<string, IStringPlaceholder>;\n translations: Map<string, ReadonlyMap<string, string>>;\n renderedPlacholders: Record<string, string>;\n}\n\nconst PLUGIN_NAME: 'localization' = 'localization';\n\nconst pluginForCompiler: WeakMap<Compiler, LocalizationPlugin> = new WeakMap();\n\n/**\n * Gets the instance of the LocalizationPlugin bound to the specified webpack compiler.\n * Used by loaders.\n */\nexport function getPluginInstance(compiler: Compiler | undefined): LocalizationPlugin {\n const instance: LocalizationPlugin | undefined = compiler && pluginForCompiler.get(compiler);\n if (!instance) {\n throw new Error(`Could not find a LocalizationPlugin instance for the current webpack compiler!`);\n }\n return instance;\n}\n\n/**\n * This plugin facilitates localization in webpack.\n *\n * @public\n */\nexport class LocalizationPlugin implements WebpackPluginInstance {\n private readonly _locFiles: Map<string, IFileTranslationInfo> = new Map();\n\n /**\n * @internal\n */\n public readonly _options: ILocalizationPluginOptions;\n private readonly _resolvedTranslatedStringsFromOptions: Map<\n string,\n Map<string, ILocaleFileObject | string | ReadonlyMap<string, string>>\n > = new Map();\n private readonly _stringPlaceholderMap: Map<string, IStringPlaceholder> = new Map();\n private _passthroughLocaleName!: string;\n private _defaultLocale!: string;\n private _noStringsLocaleName!: string;\n private _fillMissingTranslationStrings!: boolean;\n private _formatLocaleForFilename!: (loc: string) => string;\n private readonly _pseudolocalizers: Map<string, (str: string) => string> = new Map();\n\n /**\n * The set of locales that have translations provided.\n */\n private _translatedLocales: Set<string> = new Set();\n\n public constructor(options: ILocalizationPluginOptions) {\n this._options = options;\n }\n\n /**\n * Apply this plugin to the specified webpack compiler.\n */\n public apply(compiler: Compiler): void {\n pluginForCompiler.set(compiler, this);\n\n // https://github.com/webpack/webpack-dev-server/pull/1929/files#diff-15fb51940da53816af13330d8ce69b4eR66\n const isWebpackDevServer: boolean = process.env.WEBPACK_DEV_SERVER === 'true';\n\n const { errors, warnings } = this._initializeAndValidateOptions(compiler, isWebpackDevServer);\n\n if (errors.length > 0 || warnings.length > 0) {\n compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation: Compilation) => {\n compilation.errors.push(...errors);\n compilation.warnings.push(...warnings);\n });\n\n if (errors.length > 0) {\n // If there are any errors, just pass through the resources in source and don't do any\n // additional configuration\n return;\n }\n }\n\n const { webpack: thisWebpack } = compiler;\n const {\n WebpackError,\n runtime: { GetChunkFilenameRuntimeModule }\n } = thisWebpack;\n\n // Side-channel for async chunk URL generator chunk, since the actual chunk is completely inaccessible\n // from the assetPath hook below when invoked to build the async URL generator\n let chunkWithAsyncURLGenerator: Chunk | undefined;\n\n const originalGenerate: typeof GetChunkFilenameRuntimeModule.prototype.generate =\n GetChunkFilenameRuntimeModule.prototype.generate;\n GetChunkFilenameRuntimeModule.prototype.generate = function (\n this: runtime.GetChunkFilenameRuntimeModule\n ): string | null {\n // `originalGenerate` will invoke `getAssetPath` to produce the async URL generator\n // Need to know the identity of the containing chunk to correctly produce the asset path expression\n chunkWithAsyncURLGenerator = this.chunk;\n const result: string | null = originalGenerate.call(this);\n // Unset after the call finishes because we are no longer generating async URL generators\n chunkWithAsyncURLGenerator = undefined;\n return result;\n };\n\n const asyncGeneratorTest: RegExp = /^\\\" \\+/;\n\n const { runtimeLocaleExpression } = this._options;\n\n compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation: Compilation) => {\n let hashFn: HashFn | undefined;\n if (this._options.realContentHash) {\n if (runtimeLocaleExpression) {\n compilation.errors.push(\n new WebpackError(\n `The \"realContentHash\" option cannot be used in conjunction with \"runtimeLocaleExpression\".`\n )\n );\n } else {\n hashFn = getHashFunction({ thisWebpack, compilation });\n }\n } else if (compiler.options.optimization?.realContentHash) {\n compilation.errors.push(\n new thisWebpack.WebpackError(\n `The \\`optimization.realContentHash\\` option is set and the ${LocalizationPlugin.name}'s ` +\n '`realContentHash` option is not set. This will likely produce invalid results. Consider setting the ' +\n `\\`realContentHash\\` option in the ${LocalizationPlugin.name} plugin.`\n )\n );\n }\n\n const chunksWithUrlGenerators: WeakSet<Chunk> = new WeakSet();\n\n compilation.hooks.assetPath.tap(\n PLUGIN_NAME,\n (assetPath: string, options: IAssetPathOptions): string => {\n const { chunkGraph } = compilation;\n\n if (\n options.contentHashType === 'javascript' &&\n assetPath.match(Constants.LOCALE_FILENAME_TOKEN_REGEX)\n ) {\n // Does this look like an async chunk URL generator?\n if (typeof options.chunk?.id === 'string' && options.chunk.id.match(asyncGeneratorTest)) {\n const chunkIdsWithStrings: Set<number | string> = new Set<number | string>();\n const chunkIdsWithoutStrings: Set<number | string> = new Set<number | string>();\n\n const activeChunkWithAsyncUrlGenerator: Chunk | undefined = chunkWithAsyncURLGenerator;\n\n if (!activeChunkWithAsyncUrlGenerator) {\n compilation.errors.push(\n new WebpackError(`No active chunk while constructing async chunk URL generator!`)\n );\n return assetPath;\n }\n\n const asyncChunks: Set<Chunk> = activeChunkWithAsyncUrlGenerator.getAllAsyncChunks();\n for (const asyncChunk of asyncChunks) {\n const chunkId: number | string | null = asyncChunk.id;\n\n if (chunkId === null || chunkId === undefined) {\n throw new Error(`Chunk \"${asyncChunk.name}\"'s ID is null or undefined.`);\n }\n\n if (_chunkHasLocalizedModules(chunkGraph, asyncChunk, runtimeLocaleExpression)) {\n chunkIdsWithStrings.add(chunkId);\n } else {\n chunkIdsWithoutStrings.add(chunkId);\n }\n }\n\n return assetPath.replace(Constants.LOCALE_FILENAME_TOKEN_REGEX, () => {\n // Use a replacer function so that we don't need to escape anything in the return value\n\n // If the runtime chunk is itself localized, forcibly match the locale of the runtime chunk\n // Otherwise prefer the runtime expression if specified\n const localeExpression: string =\n (!_chunkHasLocalizedModules(\n chunkGraph,\n activeChunkWithAsyncUrlGenerator,\n runtimeLocaleExpression\n ) &&\n runtimeLocaleExpression) ||\n Constants.JSONP_PLACEHOLDER;\n if (localeExpression === Constants.JSONP_PLACEHOLDER) {\n chunksWithUrlGenerators.add(activeChunkWithAsyncUrlGenerator);\n }\n\n if (chunkIdsWithStrings.size === 0) {\n return this._formatLocaleForFilename(this._noStringsLocaleName);\n } else if (chunkIdsWithoutStrings.size === 0) {\n return `\" + ${localeExpression} + \"`;\n } else {\n // Generate an object that is used to select between <locale> and <nostrings locale> for each chunk ID\n // Method: pick the smaller set of (localized, non-localized) and map that to 1 (a truthy value)\n // All other IDs map to `undefined` (a falsy value), so we then use the ternary operator to select\n // the appropriate token\n //\n // This can be improved in the future. We can maybe sort the chunks such that the chunks below a certain ID\n // number are localized and the those above are not.\n const chunkMapping: { [chunkId: string]: 1 } = {};\n // Use the map with the fewest values to shorten the expression\n const isLocalizedSmaller: boolean = chunkIdsWithStrings.size <= chunkIdsWithoutStrings.size;\n // These are the ids for which the expression should evaluate to a truthy value\n const smallerSet: Set<number | string> = isLocalizedSmaller\n ? chunkIdsWithStrings\n : chunkIdsWithoutStrings;\n for (const id of smallerSet) {\n chunkMapping[id] = 1;\n }\n\n const noLocaleExpression: string = JSON.stringify(\n this._formatLocaleForFilename(this._noStringsLocaleName)\n );\n\n return `\" + (${JSON.stringify(chunkMapping)}[chunkId]?${\n isLocalizedSmaller ? localeExpression : noLocaleExpression\n }:${isLocalizedSmaller ? noLocaleExpression : localeExpression}) + \"`;\n }\n });\n } else {\n let locale: string | undefined = options.locale;\n if (!locale) {\n const isLocalized: boolean = _chunkHasLocalizedModules(\n chunkGraph,\n options.chunk as Chunk,\n runtimeLocaleExpression\n );\n // Ensure that the initial name maps to a file that should exist in the final output\n locale = isLocalized ? this._defaultLocale : this._noStringsLocaleName;\n }\n return assetPath.replace(\n Constants.LOCALE_FILENAME_TOKEN_REGEX,\n this._formatLocaleForFilename(locale)\n );\n }\n } else {\n return assetPath;\n }\n }\n );\n\n const { outputOptions } = compilation;\n\n // For compatibility with minifiers, need to generate the additional assets after the optimize process runs\n compilation.hooks.processAssets.tapPromise(\n {\n name: PLUGIN_NAME,\n // Generating derived assets, but explicitly want to create them *after* asset optimization\n stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING - 1\n },\n async (): Promise<void> => {\n const locales: Set<string> = this._translatedLocales;\n\n const { chunkGraph, chunks } = compilation;\n const { localizationStats: statsOptions } = this._options;\n\n const filesByChunkName: Map<string, Record<string, string>> | undefined = statsOptions\n ? new Map()\n : undefined;\n const localizedEntryPointNames: string[] = [];\n const localizedChunkNames: string[] = [];\n\n type CacheFacade = ReturnType<Compilation['getCache']>;\n const cache: CacheFacade = compilation.getCache(PLUGIN_NAME);\n\n await Async.forEachAsync(\n chunks,\n async (chunk: Chunk) => {\n if (!chunkIsJs(chunk, chunkGraph)) {\n return;\n }\n\n const isLocalized: boolean = _chunkHasLocalizedModules(\n chunkGraph,\n chunk,\n runtimeLocaleExpression\n );\n\n const template: Parameters<typeof Compilation.prototype.getAssetPath>[0] =\n chunk.filenameTemplate ||\n (chunk.hasRuntime() ? outputOptions.filename : outputOptions.chunkFilename)!;\n\n const defaultAssetName: string = compilation.getPath(template, {\n chunk,\n contentHashType: 'javascript'\n // Without locale this should return the name of the default asset\n });\n\n const asset: Asset | undefined = compilation.getAsset(defaultAssetName);\n if (!asset) {\n compilation.errors.push(new WebpackError(`Missing expected chunk asset ${defaultAssetName}`));\n return;\n }\n\n if (isLocalized) {\n const localizedAssets: Record<string, string> = await processLocalizedAssetCachedAsync({\n // Global values\n plugin: this,\n compilation,\n cache,\n locales,\n defaultLocale: this._defaultLocale,\n passthroughLocaleName: this._passthroughLocaleName,\n fillMissingTranslationStrings: this._fillMissingTranslationStrings,\n formatLocaleForFilenameFn: this._formatLocaleForFilename,\n // Chunk-specific values\n chunk,\n asset,\n filenameTemplate: template\n });\n\n if (filesByChunkName && chunk.name) {\n filesByChunkName.set(chunk.name, localizedAssets);\n (chunk.hasRuntime() ? localizedEntryPointNames : localizedChunkNames).push(chunk.name);\n }\n } else {\n await processNonLocalizedAssetCachedAsync({\n // Global values\n plugin: this,\n compilation,\n cache,\n hasUrlGenerator: chunksWithUrlGenerators.has(chunk),\n noStringsLocaleName: this._noStringsLocaleName,\n formatLocaleForFilenameFn: this._formatLocaleForFilename,\n // Chunk-specific values\n chunk,\n asset,\n fileName: defaultAssetName\n });\n }\n },\n {\n // Only async component is the cache layer\n concurrency: 20\n }\n );\n\n if (hashFn) {\n updateAssetHashes({\n thisWebpack,\n compilation,\n hashFn,\n filesByChunkName\n });\n }\n\n // Since the stats generation doesn't depend on content, do it immediately\n if (statsOptions && filesByChunkName) {\n const localizationStats: ILocalizationStats = {\n entrypoints: {},\n namedChunkGroups: {}\n };\n\n // Sort in lexicographic order to ensure stable output\n localizedChunkNames.sort();\n for (const chunkName of localizedChunkNames) {\n localizationStats.namedChunkGroups[chunkName] = {\n localizedAssets: filesByChunkName.get(chunkName)!\n };\n }\n\n // Sort in lexicographic order to ensure stable output\n localizedEntryPointNames.sort();\n for (const chunkName of localizedEntryPointNames) {\n localizationStats.entrypoints[chunkName] = {\n localizedAssets: filesByChunkName.get(chunkName)!\n };\n }\n\n const { dropPath, callback } = statsOptions;\n\n if (dropPath) {\n compilation.emitAsset(\n dropPath,\n new compiler.webpack.sources.RawSource(JSON.stringify(localizationStats))\n );\n }\n\n if (callback) {\n try {\n callback(localizationStats, compilation);\n } catch (e) {\n /* swallow errors from the callback */\n }\n }\n }\n }\n );\n });\n }\n\n /**\n * @public\n *\n * @returns An object mapping the string keys to placeholders\n */\n public async addDefaultLocFileAsync(\n context: LoaderContext<{}>,\n localizedFileKey: string,\n localizedResourceData: ILocalizationFile\n ): Promise<Record<string, string>> {\n const locFileData: ReadonlyMap<string, string> = convertLocalizationFileToLocData(localizedResourceData);\n const fileInfo: IFileTranslationInfo = this._addLocFileAndGetPlaceholders(\n this._defaultLocale,\n localizedFileKey,\n locFileData\n );\n\n const missingLocales: string[] = [];\n for (const [translatedLocaleName, translatedStrings] of this._resolvedTranslatedStringsFromOptions) {\n const translatedLocFileFromOptions: ILocaleFileData | undefined =\n translatedStrings.get(localizedFileKey);\n\n if (!translatedLocFileFromOptions) {\n missingLocales.push(translatedLocaleName);\n } else {\n const translatedLocFileData: ReadonlyMap<string, string> = await normalizeLocalizedDataAsync(\n context,\n translatedLocFileFromOptions\n );\n fileInfo.translations.set(translatedLocaleName, translatedLocFileData);\n }\n }\n\n const { resolveMissingTranslatedStrings } = this._options.localizedData;\n\n if (missingLocales.length > 0 && resolveMissingTranslatedStrings) {\n let resolvedTranslatedData: IResolvedMissingTranslations | undefined = undefined;\n try {\n resolvedTranslatedData = await resolveMissingTranslatedStrings(\n missingLocales,\n localizedFileKey,\n context\n );\n } catch (e) {\n context.emitError(e);\n }\n\n if (resolvedTranslatedData) {\n const iterable: Iterable<[string, ILocaleFileData]> =\n resolvedTranslatedData instanceof Map\n ? resolvedTranslatedData.entries()\n : Object.entries(resolvedTranslatedData);\n for (const [resolvedLocaleName, resolvedLocaleData] of iterable) {\n if (resolvedLocaleData) {\n const translatedLocFileData: ReadonlyMap<string, string> = await normalizeLocalizedDataAsync(\n context,\n resolvedLocaleData\n );\n fileInfo.translations.set(resolvedLocaleName, translatedLocFileData);\n }\n }\n }\n }\n\n for (const [pseudolocaleName, pseudolocalizer] of this._pseudolocalizers) {\n const pseudolocFileData: Map<string, string> = new Map();\n\n for (const [stringName, stringValue] of locFileData) {\n pseudolocFileData.set(stringName, pseudolocalizer(stringValue));\n }\n\n fileInfo.translations.set(pseudolocaleName, pseudolocFileData);\n }\n\n markEntity(context._module!, true);\n\n return fileInfo.renderedPlacholders;\n }\n\n /**\n * @public\n */\n public getPlaceholder(localizedFileKey: string, stringName: string): IStringPlaceholder | undefined {\n const file: IFileTranslationInfo | undefined = this._locFiles.get(localizedFileKey);\n if (!file) {\n return undefined;\n }\n return file.placeholders.get(stringName);\n }\n\n /**\n * @internal\n */\n public getDataForSerialNumber(serialNumber: string): IStringPlaceholder | undefined {\n return this._stringPlaceholderMap.get(serialNumber);\n }\n\n private _addLocFileAndGetPlaceholders(\n localeName: string,\n localizedFileKey: string,\n localizedFileData: ReadonlyMap<string, string>\n ): IFileTranslationInfo {\n let fileInfo: IFileTranslationInfo | undefined = this._locFiles.get(localizedFileKey);\n if (!fileInfo) {\n fileInfo = {\n placeholders: new Map(),\n translations: new Map(),\n renderedPlacholders: {}\n };\n this._locFiles.set(localizedFileKey, fileInfo);\n }\n const { placeholders, translations } = fileInfo;\n const locFilePrefix: string = Buffer.from(localizedFileKey, 'utf-8').toString('hex') + '$';\n\n const resultObject: Record<string, string> = {};\n for (const stringName of localizedFileData.keys()) {\n let placeholder: IStringPlaceholder | undefined = placeholders.get(stringName);\n if (!placeholder) {\n const suffix: string = `${locFilePrefix}${Buffer.from(stringName, 'utf-8').toString('hex')}`;\n\n placeholder = {\n value: `${Constants.STRING_PLACEHOLDER_PREFIX}_${Constants.STRING_PLACEHOLDER_LABEL}_\\\\_${suffix}_`,\n suffix,\n translations,\n locFilePath: localizedFileKey,\n stringName\n };\n\n placeholders.set(stringName, placeholder);\n this._stringPlaceholderMap.set(suffix, placeholder);\n }\n\n resultObject[stringName] = placeholder.value;\n }\n\n translations.set(localeName, localizedFileData);\n fileInfo.renderedPlacholders = resultObject;\n\n return fileInfo;\n }\n\n private _addTranslations(\n localeName: string,\n fileInfo: IFileTranslationInfo,\n localizedFileData: ReadonlyMap<string, string>\n ): void {\n fileInfo.translations.set(localeName, localizedFileData);\n }\n\n private _initializeAndValidateOptions(\n compiler: Compiler,\n isWebpackDevServer: boolean\n ): { errors: WebpackError[]; warnings: WebpackError[] } {\n const errors: WebpackError[] = [];\n const warnings: WebpackError[] = [];\n\n const { WebpackError } = compiler.webpack;\n const { options: configuration } = compiler;\n\n const LOCALE_NAME_REGEX: RegExp = /[a-z-]/i;\n function ensureValidLocaleName(localeName: string): boolean {\n if (!localeName.match(LOCALE_NAME_REGEX)) {\n errors.push(\n new WebpackError(\n `Invalid locale name: ${localeName}. Locale names may only contain letters and hyphens.`\n )\n );\n return false;\n } else {\n return true;\n }\n }\n\n // START configuration\n if (\n !configuration.output ||\n !configuration.output.filename ||\n typeof configuration.output.filename !== 'string' ||\n configuration.output.filename.indexOf(Constants.LOCALE_FILENAME_TOKEN) === -1\n ) {\n errors.push(\n new WebpackError(\n 'The configuration.output.filename property must be provided, must be a string, and must include ' +\n `the ${Constants.LOCALE_FILENAME_TOKEN} placeholder`\n )\n );\n }\n // END configuration\n\n // START misc options\n // START options.localizedData\n const { localizedData } = this._options;\n if (localizedData) {\n // START options.localizedData.passthroughLocale\n const { passthroughLocale } = localizedData;\n if (passthroughLocale) {\n const { usePassthroughLocale, passthroughLocaleName = 'passthrough' } = passthroughLocale;\n if (usePassthroughLocale) {\n this._passthroughLocaleName = passthroughLocaleName;\n this._translatedLocales.add(passthroughLocaleName);\n }\n }\n // END options.localizedData.passthroughLocale\n\n // START options.localizedData.translatedStrings\n const resolveRelativeToContext: (relative: string) => string = (\n configuration.context?.startsWith('/') ? path.posix.resolve : path.resolve\n ).bind(0, configuration.context!);\n const { translatedStrings } = localizedData;\n this._resolvedTranslatedStringsFromOptions.clear();\n if (translatedStrings) {\n for (const [localeName, locale] of Object.entries(translatedStrings)) {\n if (this._translatedLocales.has(localeName)) {\n errors.push(\n new WebpackError(\n `The locale \"${localeName}\" appears multiple times. ` +\n 'There may be multiple instances with different casing.'\n )\n );\n return { errors, warnings };\n }\n\n if (!ensureValidLocaleName(localeName)) {\n return { errors, warnings };\n }\n\n this._translatedLocales.add(localeName);\n const resolvedFromOptionsForLocale: Map<string, ILocaleFileData> = new Map();\n this._resolvedTranslatedStringsFromOptions.set(localeName, resolvedFromOptionsForLocale);\n\n for (const [locFilePath, locFileDataFromOptions] of Object.entries(locale)) {\n const normalizedLocFilePath: string = resolveRelativeToContext(locFilePath);\n\n if (resolvedFromOptionsForLocale.has(normalizedLocFilePath)) {\n errors.push(\n new WebpackError(\n `The localization file path \"${locFilePath}\" appears multiple times in locale ${localeName}. ` +\n 'There may be multiple instances with different casing.'\n )\n );\n return { errors, warnings };\n }\n\n const normalizedLocFileDataFromOptions: ILocaleFileData =\n typeof locFileDataFromOptions === 'string'\n ? resolveRelativeToContext(locFileDataFromOptions)\n : locFileDataFromOptions;\n\n resolvedFromOptionsForLocale.set(normalizedLocFilePath, normalizedLocFileDataFromOptions);\n }\n }\n }\n // END options.localizedData.translatedStrings\n\n // START options.localizedData.defaultLocale\n const { defaultLocale } = localizedData;\n if (defaultLocale) {\n const { localeName, fillMissingTranslationStrings } = defaultLocale;\n if (localeName) {\n if (this._translatedLocales.has(localeName)) {\n errors.push(new WebpackError('The default locale is also specified in the translated strings.'));\n return { errors, warnings };\n } else if (!ensureValidLocaleName(localeName)) {\n return { errors, warnings };\n }\n\n this._translatedLocales.add(localeName);\n this._defaultLocale = localeName;\n this._fillMissingTranslationStrings = !!fillMissingTranslationStrings;\n } else {\n errors.push(new WebpackError('Missing default locale name'));\n return { errors, warnings };\n }\n } else {\n errors.push(new WebpackError('Missing default locale options.'));\n return { errors, warnings };\n }\n // END options.localizedData.defaultLocale\n\n // START options.localizedData.pseudoLocales\n const { pseudolocales } = localizedData;\n if (pseudolocales) {\n for (const [pseudolocaleName, pseudoLocaleOpts] of Object.entries(pseudolocales)) {\n if (this._defaultLocale === pseudolocaleName) {\n errors.push(\n new WebpackError(`A pseudolocale (${pseudolocaleName}) name is also the default locale name.`)\n );\n return { errors, warnings };\n }\n\n if (this._translatedLocales.has(pseudolocaleName)) {\n errors.push(\n new WebpackError(\n `A pseudolocale (${pseudolocaleName}) name is also specified in the translated strings.`\n )\n );\n return { errors, warnings };\n }\n\n this._pseudolocalizers.set(pseudolocaleName, getPseudolocalizer(pseudoLocaleOpts));\n this._translatedLocales.add(pseudolocaleName);\n }\n }\n // END options.localizedData.pseudoLocales\n } else if (!isWebpackDevServer) {\n throw new Error('Localized data must be provided unless webpack dev server is running.');\n }\n // END options.localizedData\n\n // START options.noStringsLocaleName\n const { noStringsLocaleName } = this._options;\n if (\n noStringsLocaleName === undefined ||\n noStringsLocaleName === null ||\n !ensureValidLocaleName(noStringsLocaleName)\n ) {\n this._noStringsLocaleName = 'none';\n } else {\n this._noStringsLocaleName = noStringsLocaleName;\n }\n // END options.noStringsLocaleName\n\n // START options.formatLocaleForFilename\n const { formatLocaleForFilename = (localeName: string) => localeName } = this._options;\n this._formatLocaleForFilename = formatLocaleForFilename;\n // END options.formatLocaleForFilename\n return { errors, warnings };\n }\n}\n\nfunction _chunkHasLocalizedModules(\n chunkGraph: ChunkGraph,\n chunk: Chunk,\n runtimeLocaleExpression: string | undefined\n): boolean {\n let chunkHasAnyLocModules: boolean | undefined = getMark(chunk);\n if (chunkHasAnyLocModules === undefined) {\n chunkHasAnyLocModules = false;\n const candidateModules: Iterable<Module> | undefined = chunkGraph.getChunkModulesIterableBySourceType(\n chunk,\n 'javascript'\n );\n if (candidateModules) {\n outer: for (const module of candidateModules) {\n const moduleMark: boolean | undefined = getMark(module);\n if (moduleMark) {\n chunkHasAnyLocModules = true;\n break;\n } else if (moduleMark === false) {\n continue;\n }\n\n // Is this a concatenated module?\n const { _modules: modules } = module as { _modules?: Iterable<Module> };\n if (modules) {\n for (const nestedModule of modules) {\n if (getMark(nestedModule)) {\n markEntity(module, true);\n chunkHasAnyLocModules = true;\n break outer;\n }\n }\n markEntity(module, false);\n }\n }\n }\n\n // If this chunk doesn't directly contain any localized resources, it still\n // needs to be localized if it's an entrypoint chunk (i.e. - it has a runtime)\n // and it loads localized async chunks.\n // In that case, the generated chunk URL generation code needs to contain\n // the locale name.\n if (!chunkHasAnyLocModules && !runtimeLocaleExpression && chunk.hasRuntime()) {\n for (const asyncChunk of chunk.getAllAsyncChunks()) {\n if (_chunkHasLocalizedModules(chunkGraph, asyncChunk, runtimeLocaleExpression)) {\n chunkHasAnyLocModules = true;\n break;\n }\n }\n }\n\n markEntity(chunk, chunkHasAnyLocModules);\n }\n\n return chunkHasAnyLocModules;\n}\n\nfunction convertLocalizationFileToLocData(locFile: ILocalizationFile): ReadonlyMap<string, string> {\n const locFileData: Map<string, string> = new Map();\n for (const [stringName, locFileEntry] of Object.entries(locFile)) {\n locFileData.set(stringName, locFileEntry.value);\n }\n\n return locFileData;\n}\n\nasync function normalizeLocalizedDataAsync(\n context: LoaderContext<{}>,\n localizedData: ILocaleFileData\n): Promise<ReadonlyMap<string, string>> {\n if (typeof localizedData === 'string') {\n // The value is the path to a file. Add it as a file dependency\n context.addDependency(localizedData);\n const content: string = await new Promise((resolve, reject) => {\n // Use context.fs so that the plugin is compatible with overriding compiler.inputFileSystem\n context.fs.readFile(localizedData, (err, data) => {\n if (err) {\n return reject(err);\n } else if (!data) {\n return reject(new Error(`No data in ${localizedData}`));\n }\n resolve(data.toString());\n });\n });\n\n const localizationFile: ILocalizationFile = parseResJson({\n filePath: localizedData,\n content\n });\n\n return convertLocalizationFileToLocData(localizationFile);\n } else {\n return localizedData instanceof Map ? localizedData : new Map(Object.entries(localizedData));\n }\n}\n"]}
1
+ {"version":3,"file":"LocalizationPlugin.js","sourceRoot":"","sources":["../src/LocalizationPlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0E3D,8CAMC;AA9ED,2CAA6B;AAe7B,8EAA6G;AAC7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ED,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,KAAK,UAAU,2BAA2B,CACxC,OAA0B,EAC1B,aAA8B;IAE9B,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE,CAAC;QACtC,+DAA+D;QAC/D,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QACrC,MAAM,OAAO,GAAW,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC5D,2FAA2F;YAC3F,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;gBAC/C,IAAI,GAAG,EAAE,CAAC;oBACR,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;gBACrB,CAAC;qBAAM,IAAI,CAAC,IAAI,EAAE,CAAC;oBACjB,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC,cAAc,aAAa,EAAE,CAAC,CAAC,CAAC;gBAC1D,CAAC;gBACD,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,gBAAgB,GAAsB,IAAA,qCAAY,EAAC;YACvD,QAAQ,EAAE,aAAa;YACvB,OAAO;SACR,CAAC,CAAC;QAEH,OAAO,gCAAgC,CAAC,gBAAgB,CAAC,CAAC;IAC5D,CAAC;SAAM,CAAC;QACN,OAAO,aAAa,YAAY,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;IAC/F,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as path from 'path';\n\nimport type {\n Asset,\n Chunk,\n ChunkGraph,\n Compilation,\n Compiler,\n LoaderContext,\n Module,\n runtime,\n WebpackError,\n WebpackPluginInstance\n} from 'webpack';\n\nimport { getPseudolocalizer, type ILocalizationFile, parseResJson } from '@rushstack/localization-utilities';\nimport { Async } from '@rushstack/node-core-library/lib/Async';\n\nimport * as Constants from './utilities/Constants';\nimport type {\n ILocalizationPluginOptions,\n ILocalizationStats,\n ILocaleFileData,\n ILocaleFileObject,\n IResolvedMissingTranslations\n} from './interfaces';\nimport type { IAssetPathOptions } from './webpackInterfaces';\nimport { markEntity, getMark } from './utilities/EntityMarker';\nimport { processLocalizedAssetCachedAsync, processNonLocalizedAssetCachedAsync } from './AssetProcessor';\nimport { getHashFunction, type HashFn, updateAssetHashes } from './trueHashes';\nimport { chunkIsJs } from './utilities/chunkUtilities';\n\n/**\n * @public\n */\nexport interface IStringPlaceholder {\n /**\n * The literal string that will be injected for later replacement.\n */\n value: string;\n /**\n * The identifier for this particular placeholder, for lookup.\n */\n suffix: string;\n /**\n * The values of this string in each output locale.\n */\n translations: ReadonlyMap<string, ReadonlyMap<string, string>>;\n /**\n * The key used to identify the source file containing the string.\n */\n locFilePath: string;\n /**\n * The identifier of the string within its original source file.\n */\n stringName: string;\n}\n\nexport interface IFileTranslationInfo {\n placeholders: Map<string, IStringPlaceholder>;\n translations: Map<string, ReadonlyMap<string, string>>;\n renderedPlacholders: Record<string, string>;\n}\n\nconst PLUGIN_NAME: 'localization' = 'localization';\n\nconst pluginForCompiler: WeakMap<Compiler, LocalizationPlugin> = new WeakMap();\n\n/**\n * Gets the instance of the LocalizationPlugin bound to the specified webpack compiler.\n * Used by loaders.\n */\nexport function getPluginInstance(compiler: Compiler | undefined): LocalizationPlugin {\n const instance: LocalizationPlugin | undefined = compiler && pluginForCompiler.get(compiler);\n if (!instance) {\n throw new Error(`Could not find a LocalizationPlugin instance for the current webpack compiler!`);\n }\n return instance;\n}\n\n/**\n * This plugin facilitates localization in webpack.\n *\n * @public\n */\nexport class LocalizationPlugin implements WebpackPluginInstance {\n private readonly _locFiles: Map<string, IFileTranslationInfo> = new Map();\n\n /**\n * @internal\n */\n public readonly _options: ILocalizationPluginOptions;\n private readonly _resolvedTranslatedStringsFromOptions: Map<\n string,\n Map<string, ILocaleFileObject | string | ReadonlyMap<string, string>>\n > = new Map();\n private readonly _stringPlaceholderMap: Map<string, IStringPlaceholder> = new Map();\n private _passthroughLocaleName!: string;\n private _defaultLocale!: string;\n private _noStringsLocaleName!: string;\n private _fillMissingTranslationStrings!: boolean;\n private _formatLocaleForFilename!: (loc: string) => string;\n private readonly _pseudolocalizers: Map<string, (str: string) => string> = new Map();\n\n /**\n * The set of locales that have translations provided.\n */\n private _translatedLocales: Set<string> = new Set();\n\n public constructor(options: ILocalizationPluginOptions) {\n this._options = options;\n }\n\n /**\n * Apply this plugin to the specified webpack compiler.\n */\n public apply(compiler: Compiler): void {\n pluginForCompiler.set(compiler, this);\n\n // https://github.com/webpack/webpack-dev-server/pull/1929/files#diff-15fb51940da53816af13330d8ce69b4eR66\n const isWebpackDevServer: boolean = process.env.WEBPACK_DEV_SERVER === 'true';\n\n const { errors, warnings } = this._initializeAndValidateOptions(compiler, isWebpackDevServer);\n\n if (errors.length > 0 || warnings.length > 0) {\n compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation: Compilation) => {\n compilation.errors.push(...errors);\n compilation.warnings.push(...warnings);\n });\n\n if (errors.length > 0) {\n // If there are any errors, just pass through the resources in source and don't do any\n // additional configuration\n return;\n }\n }\n\n const { webpack: thisWebpack } = compiler;\n const {\n WebpackError,\n runtime: { GetChunkFilenameRuntimeModule }\n } = thisWebpack;\n\n // Side-channel for async chunk URL generator chunk, since the actual chunk is completely inaccessible\n // from the assetPath hook below when invoked to build the async URL generator\n let chunkWithAsyncURLGenerator: Chunk | undefined;\n\n const originalGenerate: typeof GetChunkFilenameRuntimeModule.prototype.generate =\n GetChunkFilenameRuntimeModule.prototype.generate;\n GetChunkFilenameRuntimeModule.prototype.generate = function (\n this: runtime.GetChunkFilenameRuntimeModule\n ): string | null {\n // `originalGenerate` will invoke `getAssetPath` to produce the async URL generator\n // Need to know the identity of the containing chunk to correctly produce the asset path expression\n chunkWithAsyncURLGenerator = this.chunk;\n const result: string | null = originalGenerate.call(this);\n // Unset after the call finishes because we are no longer generating async URL generators\n chunkWithAsyncURLGenerator = undefined;\n return result;\n };\n\n const asyncGeneratorTest: RegExp = /^\\\" \\+/;\n\n const { runtimeLocaleExpression } = this._options;\n\n compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation: Compilation) => {\n let hashFn: HashFn | undefined;\n if (this._options.realContentHash) {\n if (runtimeLocaleExpression) {\n compilation.errors.push(\n new WebpackError(\n `The \"realContentHash\" option cannot be used in conjunction with \"runtimeLocaleExpression\".`\n )\n );\n } else {\n hashFn = getHashFunction({ thisWebpack, compilation });\n }\n } else if (compiler.options.optimization?.realContentHash) {\n compilation.errors.push(\n new thisWebpack.WebpackError(\n `The \\`optimization.realContentHash\\` option is set and the ${LocalizationPlugin.name}'s ` +\n '`realContentHash` option is not set. This will likely produce invalid results. Consider setting the ' +\n `\\`realContentHash\\` option in the ${LocalizationPlugin.name} plugin.`\n )\n );\n }\n\n const chunksWithUrlGenerators: WeakSet<Chunk> = new WeakSet();\n\n compilation.hooks.assetPath.tap(\n PLUGIN_NAME,\n (assetPath: string, options: IAssetPathOptions): string => {\n const { chunkGraph } = compilation;\n\n if (\n options.contentHashType === 'javascript' &&\n assetPath.match(Constants.LOCALE_FILENAME_TOKEN_REGEX)\n ) {\n // Does this look like an async chunk URL generator?\n if (typeof options.chunk?.id === 'string' && options.chunk.id.match(asyncGeneratorTest)) {\n const chunkIdsWithStrings: Set<number | string> = new Set<number | string>();\n const chunkIdsWithoutStrings: Set<number | string> = new Set<number | string>();\n\n const activeChunkWithAsyncUrlGenerator: Chunk | undefined = chunkWithAsyncURLGenerator;\n\n if (!activeChunkWithAsyncUrlGenerator) {\n compilation.errors.push(\n new WebpackError(`No active chunk while constructing async chunk URL generator!`)\n );\n return assetPath;\n }\n\n const asyncChunks: Set<Chunk> = activeChunkWithAsyncUrlGenerator.getAllAsyncChunks();\n for (const asyncChunk of asyncChunks) {\n const chunkId: number | string | null = asyncChunk.id;\n\n if (chunkId === null || chunkId === undefined) {\n throw new Error(`Chunk \"${asyncChunk.name}\"'s ID is null or undefined.`);\n }\n\n if (_chunkHasLocalizedModules(chunkGraph, asyncChunk, runtimeLocaleExpression)) {\n chunkIdsWithStrings.add(chunkId);\n } else {\n chunkIdsWithoutStrings.add(chunkId);\n }\n }\n\n return assetPath.replace(Constants.LOCALE_FILENAME_TOKEN_REGEX, () => {\n // Use a replacer function so that we don't need to escape anything in the return value\n\n // If the runtime chunk is itself localized, forcibly match the locale of the runtime chunk\n // Otherwise prefer the runtime expression if specified\n const localeExpression: string =\n (!_chunkHasLocalizedModules(\n chunkGraph,\n activeChunkWithAsyncUrlGenerator,\n runtimeLocaleExpression\n ) &&\n runtimeLocaleExpression) ||\n Constants.JSONP_PLACEHOLDER;\n if (localeExpression === Constants.JSONP_PLACEHOLDER) {\n chunksWithUrlGenerators.add(activeChunkWithAsyncUrlGenerator);\n }\n\n if (chunkIdsWithStrings.size === 0) {\n return this._formatLocaleForFilename(this._noStringsLocaleName);\n } else if (chunkIdsWithoutStrings.size === 0) {\n return `\" + ${localeExpression} + \"`;\n } else {\n // Generate an object that is used to select between <locale> and <nostrings locale> for each chunk ID\n // Method: pick the smaller set of (localized, non-localized) and map that to 1 (a truthy value)\n // All other IDs map to `undefined` (a falsy value), so we then use the ternary operator to select\n // the appropriate token\n //\n // This can be improved in the future. We can maybe sort the chunks such that the chunks below a certain ID\n // number are localized and the those above are not.\n const chunkMapping: { [chunkId: string]: 1 } = {};\n // Use the map with the fewest values to shorten the expression\n const isLocalizedSmaller: boolean = chunkIdsWithStrings.size <= chunkIdsWithoutStrings.size;\n // These are the ids for which the expression should evaluate to a truthy value\n const smallerSet: Set<number | string> = isLocalizedSmaller\n ? chunkIdsWithStrings\n : chunkIdsWithoutStrings;\n for (const id of smallerSet) {\n chunkMapping[id] = 1;\n }\n\n const noLocaleExpression: string = JSON.stringify(\n this._formatLocaleForFilename(this._noStringsLocaleName)\n );\n\n return `\" + (${JSON.stringify(chunkMapping)}[chunkId]?${\n isLocalizedSmaller ? localeExpression : noLocaleExpression\n }:${isLocalizedSmaller ? noLocaleExpression : localeExpression}) + \"`;\n }\n });\n } else {\n let locale: string | undefined = options.locale;\n if (!locale) {\n const isLocalized: boolean = _chunkHasLocalizedModules(\n chunkGraph,\n options.chunk as Chunk,\n runtimeLocaleExpression\n );\n // Ensure that the initial name maps to a file that should exist in the final output\n locale = isLocalized ? this._defaultLocale : this._noStringsLocaleName;\n }\n return assetPath.replace(\n Constants.LOCALE_FILENAME_TOKEN_REGEX,\n this._formatLocaleForFilename(locale)\n );\n }\n } else {\n return assetPath;\n }\n }\n );\n\n const { outputOptions } = compilation;\n\n // For compatibility with minifiers, need to generate the additional assets after the optimize process runs\n compilation.hooks.processAssets.tapPromise(\n {\n name: PLUGIN_NAME,\n // Generating derived assets, but explicitly want to create them *after* asset optimization\n stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING - 1\n },\n async (): Promise<void> => {\n const locales: Set<string> = this._translatedLocales;\n\n const { chunkGraph, chunks } = compilation;\n const { localizationStats: statsOptions } = this._options;\n\n const filesByChunkName: Map<string, Record<string, string>> | undefined = statsOptions\n ? new Map()\n : undefined;\n const localizedEntryPointNames: string[] = [];\n const localizedChunkNames: string[] = [];\n\n type CacheFacade = ReturnType<Compilation['getCache']>;\n const cache: CacheFacade = compilation.getCache(PLUGIN_NAME);\n\n await Async.forEachAsync(\n chunks,\n async (chunk: Chunk) => {\n if (!chunkIsJs(chunk, chunkGraph)) {\n return;\n }\n\n const isLocalized: boolean = _chunkHasLocalizedModules(\n chunkGraph,\n chunk,\n runtimeLocaleExpression\n );\n\n const template: Parameters<typeof Compilation.prototype.getAssetPath>[0] =\n chunk.filenameTemplate ||\n (chunk.hasRuntime() ? outputOptions.filename : outputOptions.chunkFilename)!;\n\n const defaultAssetName: string = compilation.getPath(template, {\n chunk,\n contentHashType: 'javascript'\n // Without locale this should return the name of the default asset\n });\n\n const asset: Asset | undefined = compilation.getAsset(defaultAssetName);\n if (!asset) {\n compilation.errors.push(new WebpackError(`Missing expected chunk asset ${defaultAssetName}`));\n return;\n }\n\n if (isLocalized) {\n const localizedAssets: Record<string, string> = await processLocalizedAssetCachedAsync({\n // Global values\n plugin: this,\n compilation,\n cache,\n locales,\n defaultLocale: this._defaultLocale,\n passthroughLocaleName: this._passthroughLocaleName,\n fillMissingTranslationStrings: this._fillMissingTranslationStrings,\n formatLocaleForFilenameFn: this._formatLocaleForFilename,\n // Chunk-specific values\n chunk,\n asset,\n filenameTemplate: template\n });\n\n if (filesByChunkName && chunk.name) {\n filesByChunkName.set(chunk.name, localizedAssets);\n (chunk.hasRuntime() ? localizedEntryPointNames : localizedChunkNames).push(chunk.name);\n }\n } else {\n await processNonLocalizedAssetCachedAsync({\n // Global values\n plugin: this,\n compilation,\n cache,\n hasUrlGenerator: chunksWithUrlGenerators.has(chunk),\n noStringsLocaleName: this._noStringsLocaleName,\n formatLocaleForFilenameFn: this._formatLocaleForFilename,\n // Chunk-specific values\n chunk,\n asset,\n fileName: defaultAssetName\n });\n }\n },\n {\n // Only async component is the cache layer\n concurrency: 20\n }\n );\n\n if (hashFn) {\n updateAssetHashes({\n thisWebpack,\n compilation,\n hashFn,\n filesByChunkName\n });\n }\n\n // Since the stats generation doesn't depend on content, do it immediately\n if (statsOptions && filesByChunkName) {\n const localizationStats: ILocalizationStats = {\n entrypoints: {},\n namedChunkGroups: {}\n };\n\n // Sort in lexicographic order to ensure stable output\n localizedChunkNames.sort();\n for (const chunkName of localizedChunkNames) {\n localizationStats.namedChunkGroups[chunkName] = {\n localizedAssets: filesByChunkName.get(chunkName)!\n };\n }\n\n // Sort in lexicographic order to ensure stable output\n localizedEntryPointNames.sort();\n for (const chunkName of localizedEntryPointNames) {\n localizationStats.entrypoints[chunkName] = {\n localizedAssets: filesByChunkName.get(chunkName)!\n };\n }\n\n const { dropPath, callback } = statsOptions;\n\n if (dropPath) {\n compilation.emitAsset(\n dropPath,\n new compiler.webpack.sources.RawSource(JSON.stringify(localizationStats))\n );\n }\n\n if (callback) {\n try {\n callback(localizationStats, compilation);\n } catch (e) {\n /* swallow errors from the callback */\n }\n }\n }\n }\n );\n });\n }\n\n /**\n * @public\n *\n * @returns An object mapping the string keys to placeholders\n */\n public async addDefaultLocFileAsync(\n context: LoaderContext<{}>,\n localizedFileKey: string,\n localizedResourceData: ILocalizationFile\n ): Promise<Record<string, string>> {\n const locFileData: ReadonlyMap<string, string> = convertLocalizationFileToLocData(localizedResourceData);\n const fileInfo: IFileTranslationInfo = this._addLocFileAndGetPlaceholders(\n this._defaultLocale,\n localizedFileKey,\n locFileData\n );\n\n const missingLocales: string[] = [];\n for (const [translatedLocaleName, translatedStrings] of this._resolvedTranslatedStringsFromOptions) {\n const translatedLocFileFromOptions: ILocaleFileData | undefined =\n translatedStrings.get(localizedFileKey);\n\n if (!translatedLocFileFromOptions) {\n missingLocales.push(translatedLocaleName);\n } else {\n const translatedLocFileData: ReadonlyMap<string, string> = await normalizeLocalizedDataAsync(\n context,\n translatedLocFileFromOptions\n );\n fileInfo.translations.set(translatedLocaleName, translatedLocFileData);\n }\n }\n\n const { resolveMissingTranslatedStrings } = this._options.localizedData;\n\n if (missingLocales.length > 0 && resolveMissingTranslatedStrings) {\n let resolvedTranslatedData: IResolvedMissingTranslations | undefined = undefined;\n try {\n resolvedTranslatedData = await resolveMissingTranslatedStrings(\n missingLocales,\n localizedFileKey,\n context\n );\n } catch (e) {\n context.emitError(e);\n }\n\n if (resolvedTranslatedData) {\n const iterable: Iterable<[string, ILocaleFileData]> =\n resolvedTranslatedData instanceof Map\n ? resolvedTranslatedData.entries()\n : Object.entries(resolvedTranslatedData);\n for (const [resolvedLocaleName, resolvedLocaleData] of iterable) {\n if (resolvedLocaleData) {\n const translatedLocFileData: ReadonlyMap<string, string> = await normalizeLocalizedDataAsync(\n context,\n resolvedLocaleData\n );\n fileInfo.translations.set(resolvedLocaleName, translatedLocFileData);\n }\n }\n }\n }\n\n for (const [pseudolocaleName, pseudolocalizer] of this._pseudolocalizers) {\n const pseudolocFileData: Map<string, string> = new Map();\n\n for (const [stringName, stringValue] of locFileData) {\n pseudolocFileData.set(stringName, pseudolocalizer(stringValue));\n }\n\n fileInfo.translations.set(pseudolocaleName, pseudolocFileData);\n }\n\n markEntity(context._module!, true);\n\n return fileInfo.renderedPlacholders;\n }\n\n /**\n * @public\n */\n public getPlaceholder(localizedFileKey: string, stringName: string): IStringPlaceholder | undefined {\n const file: IFileTranslationInfo | undefined = this._locFiles.get(localizedFileKey);\n if (!file) {\n return undefined;\n }\n return file.placeholders.get(stringName);\n }\n\n /**\n * @internal\n */\n public getDataForSerialNumber(serialNumber: string): IStringPlaceholder | undefined {\n return this._stringPlaceholderMap.get(serialNumber);\n }\n\n private _addLocFileAndGetPlaceholders(\n localeName: string,\n localizedFileKey: string,\n localizedFileData: ReadonlyMap<string, string>\n ): IFileTranslationInfo {\n let fileInfo: IFileTranslationInfo | undefined = this._locFiles.get(localizedFileKey);\n if (!fileInfo) {\n fileInfo = {\n placeholders: new Map(),\n translations: new Map(),\n renderedPlacholders: {}\n };\n this._locFiles.set(localizedFileKey, fileInfo);\n }\n const { placeholders, translations } = fileInfo;\n const locFilePrefix: string = Buffer.from(localizedFileKey, 'utf-8').toString('hex') + '$';\n\n const resultObject: Record<string, string> = {};\n for (const stringName of localizedFileData.keys()) {\n let placeholder: IStringPlaceholder | undefined = placeholders.get(stringName);\n if (!placeholder) {\n const suffix: string = `${locFilePrefix}${Buffer.from(stringName, 'utf-8').toString('hex')}`;\n\n placeholder = {\n value: `${Constants.STRING_PLACEHOLDER_PREFIX}_${Constants.STRING_PLACEHOLDER_LABEL}_\\\\_${suffix}_`,\n suffix,\n translations,\n locFilePath: localizedFileKey,\n stringName\n };\n\n placeholders.set(stringName, placeholder);\n this._stringPlaceholderMap.set(suffix, placeholder);\n }\n\n resultObject[stringName] = placeholder.value;\n }\n\n translations.set(localeName, localizedFileData);\n fileInfo.renderedPlacholders = resultObject;\n\n return fileInfo;\n }\n\n private _addTranslations(\n localeName: string,\n fileInfo: IFileTranslationInfo,\n localizedFileData: ReadonlyMap<string, string>\n ): void {\n fileInfo.translations.set(localeName, localizedFileData);\n }\n\n private _initializeAndValidateOptions(\n compiler: Compiler,\n isWebpackDevServer: boolean\n ): { errors: WebpackError[]; warnings: WebpackError[] } {\n const errors: WebpackError[] = [];\n const warnings: WebpackError[] = [];\n\n const { WebpackError } = compiler.webpack;\n const { options: configuration } = compiler;\n\n const LOCALE_NAME_REGEX: RegExp = /[a-z-]/i;\n function ensureValidLocaleName(localeName: string): boolean {\n if (!localeName.match(LOCALE_NAME_REGEX)) {\n errors.push(\n new WebpackError(\n `Invalid locale name: ${localeName}. Locale names may only contain letters and hyphens.`\n )\n );\n return false;\n } else {\n return true;\n }\n }\n\n // START configuration\n if (\n !configuration.output ||\n !configuration.output.filename ||\n typeof configuration.output.filename !== 'string' ||\n configuration.output.filename.indexOf(Constants.LOCALE_FILENAME_TOKEN) === -1\n ) {\n errors.push(\n new WebpackError(\n 'The configuration.output.filename property must be provided, must be a string, and must include ' +\n `the ${Constants.LOCALE_FILENAME_TOKEN} placeholder`\n )\n );\n }\n // END configuration\n\n // START misc options\n // START options.localizedData\n const { localizedData } = this._options;\n if (localizedData) {\n // START options.localizedData.passthroughLocale\n const { passthroughLocale } = localizedData;\n if (passthroughLocale) {\n const { usePassthroughLocale, passthroughLocaleName = 'passthrough' } = passthroughLocale;\n if (usePassthroughLocale) {\n this._passthroughLocaleName = passthroughLocaleName;\n this._translatedLocales.add(passthroughLocaleName);\n }\n }\n // END options.localizedData.passthroughLocale\n\n // START options.localizedData.translatedStrings\n const resolveRelativeToContext: (relative: string) => string = (\n configuration.context?.startsWith('/') ? path.posix.resolve : path.resolve\n ).bind(0, configuration.context!);\n const { translatedStrings } = localizedData;\n this._resolvedTranslatedStringsFromOptions.clear();\n if (translatedStrings) {\n for (const [localeName, locale] of Object.entries(translatedStrings)) {\n if (this._translatedLocales.has(localeName)) {\n errors.push(\n new WebpackError(\n `The locale \"${localeName}\" appears multiple times. ` +\n 'There may be multiple instances with different casing.'\n )\n );\n return { errors, warnings };\n }\n\n if (!ensureValidLocaleName(localeName)) {\n return { errors, warnings };\n }\n\n this._translatedLocales.add(localeName);\n const resolvedFromOptionsForLocale: Map<string, ILocaleFileData> = new Map();\n this._resolvedTranslatedStringsFromOptions.set(localeName, resolvedFromOptionsForLocale);\n\n for (const [locFilePath, locFileDataFromOptions] of Object.entries(locale)) {\n const normalizedLocFilePath: string = resolveRelativeToContext(locFilePath);\n\n if (resolvedFromOptionsForLocale.has(normalizedLocFilePath)) {\n errors.push(\n new WebpackError(\n `The localization file path \"${locFilePath}\" appears multiple times in locale ${localeName}. ` +\n 'There may be multiple instances with different casing.'\n )\n );\n return { errors, warnings };\n }\n\n const normalizedLocFileDataFromOptions: ILocaleFileData =\n typeof locFileDataFromOptions === 'string'\n ? resolveRelativeToContext(locFileDataFromOptions)\n : locFileDataFromOptions;\n\n resolvedFromOptionsForLocale.set(normalizedLocFilePath, normalizedLocFileDataFromOptions);\n }\n }\n }\n // END options.localizedData.translatedStrings\n\n // START options.localizedData.defaultLocale\n const { defaultLocale } = localizedData;\n if (defaultLocale) {\n const { localeName, fillMissingTranslationStrings } = defaultLocale;\n if (localeName) {\n if (this._translatedLocales.has(localeName)) {\n errors.push(new WebpackError('The default locale is also specified in the translated strings.'));\n return { errors, warnings };\n } else if (!ensureValidLocaleName(localeName)) {\n return { errors, warnings };\n }\n\n this._translatedLocales.add(localeName);\n this._defaultLocale = localeName;\n this._fillMissingTranslationStrings = !!fillMissingTranslationStrings;\n } else {\n errors.push(new WebpackError('Missing default locale name'));\n return { errors, warnings };\n }\n } else {\n errors.push(new WebpackError('Missing default locale options.'));\n return { errors, warnings };\n }\n // END options.localizedData.defaultLocale\n\n // START options.localizedData.pseudoLocales\n const { pseudolocales } = localizedData;\n if (pseudolocales) {\n for (const [pseudolocaleName, pseudoLocaleOpts] of Object.entries(pseudolocales)) {\n if (this._defaultLocale === pseudolocaleName) {\n errors.push(\n new WebpackError(`A pseudolocale (${pseudolocaleName}) name is also the default locale name.`)\n );\n return { errors, warnings };\n }\n\n if (this._translatedLocales.has(pseudolocaleName)) {\n errors.push(\n new WebpackError(\n `A pseudolocale (${pseudolocaleName}) name is also specified in the translated strings.`\n )\n );\n return { errors, warnings };\n }\n\n this._pseudolocalizers.set(pseudolocaleName, getPseudolocalizer(pseudoLocaleOpts));\n this._translatedLocales.add(pseudolocaleName);\n }\n }\n // END options.localizedData.pseudoLocales\n } else if (!isWebpackDevServer) {\n throw new Error('Localized data must be provided unless webpack dev server is running.');\n }\n // END options.localizedData\n\n // START options.noStringsLocaleName\n const { noStringsLocaleName } = this._options;\n if (\n noStringsLocaleName === undefined ||\n noStringsLocaleName === null ||\n !ensureValidLocaleName(noStringsLocaleName)\n ) {\n this._noStringsLocaleName = 'none';\n } else {\n this._noStringsLocaleName = noStringsLocaleName;\n }\n // END options.noStringsLocaleName\n\n // START options.formatLocaleForFilename\n const { formatLocaleForFilename = (localeName: string) => localeName } = this._options;\n this._formatLocaleForFilename = formatLocaleForFilename;\n // END options.formatLocaleForFilename\n return { errors, warnings };\n }\n}\n\nfunction _chunkHasLocalizedModules(\n chunkGraph: ChunkGraph,\n chunk: Chunk,\n runtimeLocaleExpression: string | undefined\n): boolean {\n let chunkHasAnyLocModules: boolean | undefined = getMark(chunk);\n if (chunkHasAnyLocModules === undefined) {\n chunkHasAnyLocModules = false;\n const candidateModules: Iterable<Module> | undefined = chunkGraph.getChunkModulesIterableBySourceType(\n chunk,\n 'javascript'\n );\n if (candidateModules) {\n outer: for (const module of candidateModules) {\n const moduleMark: boolean | undefined = getMark(module);\n if (moduleMark) {\n chunkHasAnyLocModules = true;\n break;\n } else if (moduleMark === false) {\n continue;\n }\n\n // Is this a concatenated module?\n const { _modules: modules } = module as { _modules?: Iterable<Module> };\n if (modules) {\n for (const nestedModule of modules) {\n if (getMark(nestedModule)) {\n markEntity(module, true);\n chunkHasAnyLocModules = true;\n break outer;\n }\n }\n markEntity(module, false);\n }\n }\n }\n\n // If this chunk doesn't directly contain any localized resources, it still\n // needs to be localized if it's an entrypoint chunk (i.e. - it has a runtime)\n // and it loads localized async chunks.\n // In that case, the generated chunk URL generation code needs to contain\n // the locale name.\n if (!chunkHasAnyLocModules && !runtimeLocaleExpression && chunk.hasRuntime()) {\n for (const asyncChunk of chunk.getAllAsyncChunks()) {\n if (_chunkHasLocalizedModules(chunkGraph, asyncChunk, runtimeLocaleExpression)) {\n chunkHasAnyLocModules = true;\n break;\n }\n }\n }\n\n markEntity(chunk, chunkHasAnyLocModules);\n }\n\n return chunkHasAnyLocModules;\n}\n\nfunction convertLocalizationFileToLocData(locFile: ILocalizationFile): ReadonlyMap<string, string> {\n const locFileData: Map<string, string> = new Map();\n for (const [stringName, locFileEntry] of Object.entries(locFile)) {\n locFileData.set(stringName, locFileEntry.value);\n }\n\n return locFileData;\n}\n\nasync function normalizeLocalizedDataAsync(\n context: LoaderContext<{}>,\n localizedData: ILocaleFileData\n): Promise<ReadonlyMap<string, string>> {\n if (typeof localizedData === 'string') {\n // The value is the path to a file. Add it as a file dependency\n context.addDependency(localizedData);\n const content: string = await new Promise((resolve, reject) => {\n // Use context.fs so that the plugin is compatible with overriding compiler.inputFileSystem\n context.fs.readFile(localizedData, (err, data) => {\n if (err) {\n return reject(err);\n } else if (!data) {\n return reject(new Error(`No data in ${localizedData}`));\n }\n resolve(data.toString());\n });\n });\n\n const localizationFile: ILocalizationFile = parseResJson({\n filePath: localizedData,\n content\n });\n\n return convertLocalizationFileToLocData(localizationFile);\n } else {\n return localizedData instanceof Map ? localizedData : new Map(Object.entries(localizedData));\n }\n}\n"]}
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import type { Compiler, WebpackPluginInstance } from 'webpack';
4
2
  /**
5
3
  * @public
@@ -1 +1 @@
1
- {"version":3,"file":"TrueHashPlugin.d.ts","sourceRoot":"","sources":["../src/TrueHashPlugin.ts"],"names":[],"mappings":";;AAGA,OAAO,KAAK,EAAe,QAAQ,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAM5E;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM,CAAC;IAErD;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,qBAAa,cAAe,YAAW,qBAAqB;IAC1D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyB;gBAE/B,OAAO,GAAE,sBAA2B;IAIhD,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAqBvC"}
1
+ {"version":3,"file":"TrueHashPlugin.d.ts","sourceRoot":"","sources":["../src/TrueHashPlugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAe,QAAQ,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAM5E;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM,CAAC;IAErD;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,qBAAa,cAAe,YAAW,qBAAqB;IAC1D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyB;gBAE/B,OAAO,GAAE,sBAA2B;IAIhD,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAqBvC"}
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" preserve="true" />
1
2
  export { LocalizationPlugin, type IStringPlaceholder as _IStringPlaceholder } from './LocalizationPlugin';
2
3
  export { TrueHashPlugin, type ITrueHashPluginOptions } from './TrueHashPlugin';
3
4
  export type { IDefaultLocaleOptions, ILocaleData, ILocaleElementMap, ILocaleFileData, ILocaleFileObject, ILocalizationPluginOptions, ILocalizationStats, ILocalizationStatsChunkGroup, ILocalizationStatsEntrypoint, ILocalizationStatsOptions, ILocalizedData, ILocalizedStrings, IPassthroughLocaleOptions, IPseudolocalesOptions, IResolvedMissingTranslations } from './interfaces';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,KAAK,kBAAkB,IAAI,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC1G,OAAO,EAAE,cAAc,EAAE,KAAK,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,YAAY,EACV,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,0BAA0B,EAC1B,kBAAkB,EAClB,4BAA4B,EAC5B,4BAA4B,EAC5B,yBAAyB,EACzB,cAAc,EACd,iBAAiB,EACjB,yBAAyB,EACzB,qBAAqB,EACrB,4BAA4B,EAC7B,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,kBAAkB,EAAE,KAAK,kBAAkB,IAAI,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC1G,OAAO,EAAE,cAAc,EAAE,KAAK,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,YAAY,EACV,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,0BAA0B,EAC1B,kBAAkB,EAClB,4BAA4B,EAC5B,4BAA4B,EAC5B,yBAAyB,EACzB,cAAc,EACd,iBAAiB,EACjB,yBAAyB,EACzB,qBAAqB,EACrB,4BAA4B,EAC7B,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC"}
package/lib/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  // See LICENSE in the project root for license information.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.TrueHashPlugin = exports.LocalizationPlugin = void 0;
6
+ /// <reference types="node" preserve="true" />
6
7
  var LocalizationPlugin_1 = require("./LocalizationPlugin");
7
8
  Object.defineProperty(exports, "LocalizationPlugin", { enumerable: true, get: function () { return LocalizationPlugin_1.LocalizationPlugin; } });
8
9
  var TrueHashPlugin_1 = require("./TrueHashPlugin");
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,2DAA0G;AAAjG,wHAAA,kBAAkB,OAAA;AAC3B,mDAA+E;AAAtE,gHAAA,cAAc,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nexport { LocalizationPlugin, type IStringPlaceholder as _IStringPlaceholder } from './LocalizationPlugin';\nexport { TrueHashPlugin, type ITrueHashPluginOptions } from './TrueHashPlugin';\n\nexport type {\n IDefaultLocaleOptions,\n ILocaleData,\n ILocaleElementMap,\n ILocaleFileData,\n ILocaleFileObject,\n ILocalizationPluginOptions,\n ILocalizationStats,\n ILocalizationStatsChunkGroup,\n ILocalizationStatsEntrypoint,\n ILocalizationStatsOptions,\n ILocalizedData,\n ILocalizedStrings,\n IPassthroughLocaleOptions,\n IPseudolocalesOptions,\n IResolvedMissingTranslations\n} from './interfaces';\nexport type { ILocalizedWebpackChunk } from './webpackInterfaces';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,8CAA8C;AAE9C,2DAA0G;AAAjG,wHAAA,kBAAkB,OAAA;AAC3B,mDAA+E;AAAtE,gHAAA,cAAc,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/// <reference types=\"node\" preserve=\"true\" />\n\nexport { LocalizationPlugin, type IStringPlaceholder as _IStringPlaceholder } from './LocalizationPlugin';\nexport { TrueHashPlugin, type ITrueHashPluginOptions } from './TrueHashPlugin';\n\nexport type {\n IDefaultLocaleOptions,\n ILocaleData,\n ILocaleElementMap,\n ILocaleFileData,\n ILocaleFileObject,\n ILocalizationPluginOptions,\n ILocalizationStats,\n ILocalizationStatsChunkGroup,\n ILocalizationStatsEntrypoint,\n ILocalizationStatsOptions,\n ILocalizedData,\n ILocalizedStrings,\n IPassthroughLocaleOptions,\n IPseudolocalesOptions,\n IResolvedMissingTranslations\n} from './interfaces';\nexport type { ILocalizedWebpackChunk } from './webpackInterfaces';\n"]}
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
3
3
  // See LICENSE in the project root for license information.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.createLoader = void 0;
5
+ exports.createLoader = createLoader;
6
6
  const LocalizationPlugin_1 = require("../LocalizationPlugin");
7
7
  function createLoader(parseFile) {
8
8
  // eslint-disable-next-line func-style
@@ -25,5 +25,4 @@ function createLoader(parseFile) {
25
25
  };
26
26
  return loader;
27
27
  }
28
- exports.createLoader = createLoader;
29
28
  //# sourceMappingURL=LoaderFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LoaderFactory.js","sourceRoot":"","sources":["../../src/loaders/LoaderFactory.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAM3D,8DAAmF;AAMnF,SAAgB,YAAY,CAC1B,SAA8F;IAE9F,sCAAsC;IACtC,MAAM,MAAM,GAAgC,KAAK,WAE/C,OAAe;QAEf,MAAM,WAAW,GAAW,IAAI,CAAC,YAAY,CAAC;QAE9C,MAAM,cAAc,GAAuB,IAAA,sCAAiB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAE7E,MAAM,WAAW,GAAsB,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;QAE7E,MAAM,OAAO,GAA2B,MAAM,cAAc,CAAC,sBAAsB,CACjF,IAAI,EACJ,WAAW,EACX,WAAW,CACZ,CAAC;QAEF,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,OAAQ,CAAC;QAE/B,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,MAAM;gBACT,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YACjC,KAAK,iBAAiB,CAAC;YACvB,KAAK,gBAAgB;gBACnB,OAAO,mBAAmB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,4BAA4B,CAAC;YAChF;gBACE,IAAI,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,oCAAoC,IAAI,eAAe,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;gBACtG,OAAO,EAAE,CAAC;QACd,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AAnCD,oCAmCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { LoaderContext, LoaderDefinitionFunction } from 'webpack';\n\nimport type { ILocalizationFile } from '@rushstack/localization-utilities';\n\nimport { getPluginInstance, type LocalizationPlugin } from '../LocalizationPlugin';\n\nexport interface IBaseLocLoaderOptions {\n ignoreString?: (key: string) => boolean;\n}\n\nexport function createLoader<T extends IBaseLocLoaderOptions>(\n parseFile: (content: string, filePath: string, context: LoaderContext<T>) => ILocalizationFile\n): LoaderDefinitionFunction<T> {\n // eslint-disable-next-line func-style\n const loader: LoaderDefinitionFunction<T> = async function (\n this: LoaderContext<T>,\n content: string\n ): Promise<string> {\n const locFilePath: string = this.resourcePath;\n\n const pluginInstance: LocalizationPlugin = getPluginInstance(this._compiler);\n\n const locFileData: ILocalizationFile = parseFile(content, locFilePath, this);\n\n const strings: Record<string, string> = await pluginInstance.addDefaultLocFileAsync(\n this,\n locFilePath,\n locFileData\n );\n\n const { type } = this._module!;\n\n switch (type) {\n case 'json':\n return JSON.stringify(strings);\n case 'javascript/auto':\n case 'javascript/esm':\n return `const strings = ${JSON.stringify(strings)};\\nexport default strings;`;\n default:\n this.emitError(new Error(`Unexpected localized module type ${type} for module ${this.resourcePath}`));\n return '';\n }\n };\n\n return loader;\n}\n"]}
1
+ {"version":3,"file":"LoaderFactory.js","sourceRoot":"","sources":["../../src/loaders/LoaderFactory.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAY3D,oCAmCC;AAzCD,8DAAmF;AAMnF,SAAgB,YAAY,CAC1B,SAA8F;IAE9F,sCAAsC;IACtC,MAAM,MAAM,GAAgC,KAAK,WAE/C,OAAe;QAEf,MAAM,WAAW,GAAW,IAAI,CAAC,YAAY,CAAC;QAE9C,MAAM,cAAc,GAAuB,IAAA,sCAAiB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAE7E,MAAM,WAAW,GAAsB,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;QAE7E,MAAM,OAAO,GAA2B,MAAM,cAAc,CAAC,sBAAsB,CACjF,IAAI,EACJ,WAAW,EACX,WAAW,CACZ,CAAC;QAEF,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,OAAQ,CAAC;QAE/B,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,MAAM;gBACT,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YACjC,KAAK,iBAAiB,CAAC;YACvB,KAAK,gBAAgB;gBACnB,OAAO,mBAAmB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,4BAA4B,CAAC;YAChF;gBACE,IAAI,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,oCAAoC,IAAI,eAAe,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;gBACtG,OAAO,EAAE,CAAC;QACd,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { LoaderContext, LoaderDefinitionFunction } from 'webpack';\n\nimport type { ILocalizationFile } from '@rushstack/localization-utilities';\n\nimport { getPluginInstance, type LocalizationPlugin } from '../LocalizationPlugin';\n\nexport interface IBaseLocLoaderOptions {\n ignoreString?: (key: string) => boolean;\n}\n\nexport function createLoader<T extends IBaseLocLoaderOptions>(\n parseFile: (content: string, filePath: string, context: LoaderContext<T>) => ILocalizationFile\n): LoaderDefinitionFunction<T> {\n // eslint-disable-next-line func-style\n const loader: LoaderDefinitionFunction<T> = async function (\n this: LoaderContext<T>,\n content: string\n ): Promise<string> {\n const locFilePath: string = this.resourcePath;\n\n const pluginInstance: LocalizationPlugin = getPluginInstance(this._compiler);\n\n const locFileData: ILocalizationFile = parseFile(content, locFilePath, this);\n\n const strings: Record<string, string> = await pluginInstance.addDefaultLocFileAsync(\n this,\n locFilePath,\n locFileData\n );\n\n const { type } = this._module!;\n\n switch (type) {\n case 'json':\n return JSON.stringify(strings);\n case 'javascript/auto':\n case 'javascript/esm':\n return `const strings = ${JSON.stringify(strings)};\\nexport default strings;`;\n default:\n this.emitError(new Error(`Unexpected localized module type ${type} for module ${this.resourcePath}`));\n return '';\n }\n };\n\n return loader;\n}\n"]}
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import type { default as webpack, Compilation } from 'webpack';
4
2
  export type HashFn = (contents: string | Buffer) => string;
5
3
  export interface IGetHashFunctionOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"trueHashes.d.ts","sourceRoot":"","sources":["../src/trueHashes.ts"],"names":[],"mappings":";;AAGA,OAAO,KAAK,EAAE,OAAO,IAAI,OAAO,EAAE,WAAW,EAA+B,MAAM,SAAS,CAAC;AAa5F,MAAM,MAAM,MAAM,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM,CAAC;AAE3D,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,OAAO,OAAO,CAAC;IAC5B,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED,wBAAgB,eAAe,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,uBAAuB,GAAG,MAAM,CAU7F;AAED,MAAM,WAAW,yBAAyB;IACxC,WAAW,EAAE,OAAO,OAAO,CAAC;IAC5B,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACxD;AAOD,wBAAgB,iBAAiB,CAAC,EAChC,WAAW,EACX,WAAW,EACX,MAAM,EACN,gBAAgB,EACjB,EAAE,yBAAyB,GAAG,IAAI,CA2PlC"}
1
+ {"version":3,"file":"trueHashes.d.ts","sourceRoot":"","sources":["../src/trueHashes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,IAAI,OAAO,EAAE,WAAW,EAA+B,MAAM,SAAS,CAAC;AAa5F,MAAM,MAAM,MAAM,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM,CAAC;AAE3D,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,OAAO,OAAO,CAAC;IAC5B,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED,wBAAgB,eAAe,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,uBAAuB,GAAG,MAAM,CAU7F;AAED,MAAM,WAAW,yBAAyB;IACxC,WAAW,EAAE,OAAO,OAAO,CAAC;IAC5B,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACxD;AAOD,wBAAgB,iBAAiB,CAAC,EAChC,WAAW,EACX,WAAW,EACX,MAAM,EACN,gBAAgB,EACjB,EAAE,yBAAyB,GAAG,IAAI,CA2PlC"}
package/lib/trueHashes.js CHANGED
@@ -2,7 +2,8 @@
2
2
  // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
3
3
  // See LICENSE in the project root for license information.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.updateAssetHashes = exports.getHashFunction = void 0;
5
+ exports.getHashFunction = getHashFunction;
6
+ exports.updateAssetHashes = updateAssetHashes;
6
7
  const node_core_library_1 = require("@rushstack/node-core-library");
7
8
  const chunkUtilities_1 = require("./utilities/chunkUtilities");
8
9
  function getHashFunction({ thisWebpack, compilation }) {
@@ -15,7 +16,6 @@ function getHashFunction({ thisWebpack, compilation }) {
15
16
  return hash.update(contents).digest(hashDigest).toString().slice(0, hashDigestLength);
16
17
  };
17
18
  }
18
- exports.getHashFunction = getHashFunction;
19
19
  function updateAssetHashes({ thisWebpack, compilation, hashFn, filesByChunkName }) {
20
20
  var _a, _b, _c;
21
21
  const unprocessedDependenciesByChunk = new Map();
@@ -214,5 +214,4 @@ function updateAssetHashes({ thisWebpack, compilation, hashFn, filesByChunkName
214
214
  }
215
215
  }
216
216
  }
217
- exports.updateAssetHashes = updateAssetHashes;
218
217
  //# sourceMappingURL=trueHashes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"trueHashes.js","sourceRoot":"","sources":["../src/trueHashes.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,oEAAoD;AAGpD,+DAAuD;AAgBvD,SAAgB,eAAe,CAAC,EAAE,WAAW,EAAE,W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,EAAE,CAAC;oCAClB,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;oCAChC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;gCACjC,CAAC;4BACH,CAAC;wBACH,CAAC;oBACH,CAAC;oBAED,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;oBAChC,MAAM,UAAU,GAA2B,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;oBACxE,IAAI,UAAU,EAAE,CAAC;wBACf,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;4BACnC,MAAA,8BAA8B,CAAC,GAAG,CAAC,SAAS,CAAC,0CAAE,MAAM,CAAC,KAAK,CAAC,CAAC;wBAC/D,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAhQD,8CAgQC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { default as webpack, Compilation, Chunk, Asset, sources, util } from 'webpack';\nimport { Text } from '@rushstack/node-core-library';\n\nimport type { ILocalizedWebpackChunk } from './webpackInterfaces';\nimport { chunkIsJs } from './utilities/chunkUtilities';\n\ninterface IHashReplacement {\n existingHash: string;\n trueHashByLocale: string | Record<string, string> | undefined;\n}\n\ntype WebpackHash = ReturnType<typeof util.createHash>;\n\nexport type HashFn = (contents: string | Buffer) => string;\n\nexport interface IGetHashFunctionOptions {\n thisWebpack: typeof webpack;\n compilation: Compilation;\n}\n\nexport function getHashFunction({ thisWebpack, compilation }: IGetHashFunctionOptions): HashFn {\n const { hashFunction = 'md5', hashDigest = 'hex', hashDigestLength, hashSalt } = compilation.outputOptions;\n return (contents: string | Buffer) => {\n const hash: WebpackHash = thisWebpack.util.createHash(hashFunction);\n if (hashSalt) {\n hash.update(hashSalt, 'utf-8');\n }\n\n return hash.update(contents).digest(hashDigest).toString().slice(0, hashDigestLength);\n };\n}\n\nexport interface IUpdateAssetHashesOptions {\n thisWebpack: typeof webpack;\n compilation: Compilation;\n hashFn: HashFn;\n filesByChunkName?: Map<string, Record<string, string>>;\n}\n\ninterface IProcessChunkAssetResult {\n trueHash: string;\n newJsFilename: string;\n}\n\nexport function updateAssetHashes({\n thisWebpack,\n compilation,\n hashFn,\n filesByChunkName\n}: IUpdateAssetHashesOptions): void {\n const unprocessedDependenciesByChunk: Map<Chunk, Set<Chunk>> = new Map();\n const dependenciesByChunk: Map<Chunk, Set<Chunk>> = new Map();\n const dependentsByChunk: Map<Chunk, Set<Chunk>> = new Map();\n const unprocessedChunks: Set<Chunk> = new Set();\n const nonJsChunks: Set<Chunk> = new Set();\n\n for (const chunk of compilation.chunks) {\n if (!chunkIsJs(chunk, compilation.chunkGraph)) {\n nonJsChunks.add(chunk);\n } else {\n unprocessedChunks.add(chunk);\n }\n }\n\n for (const chunk of compilation.chunks) {\n let unprocessedDependencies: Set<Chunk> | undefined = unprocessedDependenciesByChunk.get(chunk);\n if (!unprocessedDependencies) {\n unprocessedDependencies = new Set();\n unprocessedDependenciesByChunk.set(chunk, unprocessedDependencies);\n }\n\n let dependencies: Set<Chunk> | undefined = dependenciesByChunk.get(chunk);\n if (!dependencies) {\n dependencies = new Set();\n dependenciesByChunk.set(chunk, dependencies);\n }\n\n if (chunk.hasRuntime()) {\n for (const asyncChunk of chunk.getAllAsyncChunks()) {\n if (!nonJsChunks.has(asyncChunk)) {\n unprocessedDependencies.add(asyncChunk);\n dependencies.add(asyncChunk);\n\n let dependents: Set<Chunk> | undefined = dependentsByChunk.get(asyncChunk);\n if (!dependents) {\n dependents = new Set();\n dependentsByChunk.set(asyncChunk, dependents);\n }\n\n dependents.add(chunk);\n\n if (!unprocessedChunks.has(asyncChunk)) {\n compilation.errors.push(\n new thisWebpack.WebpackError(\n `Found an async chunk that was not included in the compilation: ${asyncChunk.id} ` +\n `(reason: ${asyncChunk.chunkReason}).`\n )\n );\n }\n }\n }\n }\n }\n\n const hashReplacementsByChunk: Map<Chunk, IHashReplacement> = new Map();\n let previousSize: number = -1;\n while (unprocessedChunks.size > 0) {\n const currentSize: number = unprocessedChunks.size;\n if (currentSize === previousSize) {\n compilation.errors.push(\n new thisWebpack.WebpackError(\n `Detected a cycle in the chunk dependencies. This should not be possible.`\n )\n );\n\n break;\n }\n\n previousSize = currentSize;\n\n for (const chunk of unprocessedChunks) {\n if (unprocessedDependenciesByChunk.get(chunk)?.size === 0) {\n // TODO: do we need to check if the chunk is rendered?\n if (!chunk.renderedHash) {\n compilation.errors.push(\n new thisWebpack.WebpackError(`Could not find the hash for chunk ${chunk.id}.`)\n );\n } else {\n const existingHash: string = chunk.contentHash.javascript;\n const chunkDependencies: Set<Chunk> | undefined = dependenciesByChunk.get(chunk);\n if (!chunkDependencies) {\n compilation.errors.push(\n new thisWebpack.WebpackError(`Could not find dependencies for chunk ${chunk.id}.`)\n );\n } else {\n function processChunkAsset(\n jsAssetName: string,\n locale: string | undefined\n ): IProcessChunkAssetResult | undefined {\n const asset: Readonly<Asset> | undefined = compilation.getAsset(jsAssetName);\n if (!asset) {\n compilation.errors.push(\n new thisWebpack.WebpackError(`Could not find asset \"${jsAssetName}\" for chunk ${chunk.id}.`)\n );\n } else {\n let assetSource: sources.Source = asset.source;\n const assetName: string = asset.name;\n if (chunkDependencies!.size > 0) {\n const relevantHashReplacements: Map<string, string> = new Map();\n let hasAnyReplacements: boolean = false;\n for (const dependency of chunkDependencies!) {\n const asyncChunkHashReplacements: IHashReplacement | undefined =\n hashReplacementsByChunk.get(dependency);\n if (!asyncChunkHashReplacements) {\n compilation.errors.push(\n new thisWebpack.WebpackError(\n `Could not find hash replacements for chunk ${dependency.id}.`\n )\n );\n } else {\n const { existingHash: otherChunkExistingHash, trueHashByLocale } =\n asyncChunkHashReplacements;\n let replacementHash: string | undefined;\n if (typeof trueHashByLocale === 'object') {\n if (locale) {\n replacementHash = trueHashByLocale[locale];\n }\n } else {\n replacementHash = trueHashByLocale;\n }\n\n if (replacementHash) {\n if (relevantHashReplacements.has(otherChunkExistingHash)) {\n compilation.errors.push(\n new thisWebpack.WebpackError(\n `Found multiple replacements for hash ${otherChunkExistingHash} ` +\n `in chunk ${chunk.id}.`\n )\n );\n } else {\n relevantHashReplacements.set(otherChunkExistingHash, replacementHash);\n hasAnyReplacements = true;\n }\n }\n }\n }\n\n if (hasAnyReplacements) {\n const sourceString: string = assetSource.source().toString();\n const replaceSource: sources.ReplaceSource = new thisWebpack.sources.ReplaceSource(\n assetSource,\n assetName\n );\n\n const regexp: RegExp = new RegExp(\n Array.from(relevantHashReplacements.keys(), (hashToReplace) =>\n Text.escapeRegExp(hashToReplace)\n ).join('|'),\n 'g'\n );\n let match: RegExpMatchArray | null;\n while ((match = regexp.exec(sourceString)) !== null) {\n const { 0: originalHash, index } = match;\n const matchStart: number = index!;\n const matchEnd: number = matchStart + originalHash.length - 1;\n const replacement: string = relevantHashReplacements.get(originalHash)!;\n replaceSource.replace(matchStart, matchEnd, replacement);\n }\n\n assetSource = new thisWebpack.sources.CachedSource(replaceSource);\n compilation.updateAsset(jsAssetName, assetSource);\n }\n }\n\n if (jsAssetName.includes(existingHash)) {\n const trueHash: string = hashFn(assetSource.buffer());\n if (trueHash !== existingHash) {\n const newJsFilename: string = jsAssetName.replace(existingHash, trueHash);\n\n compilation.renameAsset(jsAssetName, newJsFilename);\n\n if (locale) {\n const filesForChunkName: Record<string, string> | undefined = chunk.name\n ? filesByChunkName?.get(chunk.name)\n : undefined;\n\n if (filesForChunkName) {\n filesForChunkName[locale] = newJsFilename;\n }\n }\n\n return {\n trueHash,\n newJsFilename\n };\n }\n }\n }\n }\n\n const localizedFiles: Record<string, string> | undefined = (chunk as ILocalizedWebpackChunk)\n .localizedFiles;\n if (localizedFiles) {\n const trueHashByLocale: Record<string, string> = {};\n hashReplacementsByChunk.set(chunk, {\n existingHash,\n trueHashByLocale\n });\n for (const [locale, jsAssetName] of Object.entries(localizedFiles)) {\n const processAssetResult: IProcessChunkAssetResult | undefined = processChunkAsset(\n jsAssetName,\n locale\n );\n if (processAssetResult) {\n const { trueHash, newJsFilename } = processAssetResult;\n trueHashByLocale[locale] = trueHash;\n localizedFiles[locale] = newJsFilename;\n }\n }\n } else {\n const assetNames: string[] = Array.from(chunk.files);\n let jsAssetName: string | undefined;\n for (const assetName of assetNames) {\n if (assetName.endsWith('.js')) {\n if (jsAssetName) {\n compilation.errors.push(\n new thisWebpack.WebpackError(`Found multiple .js assets for chunk ${chunk.id}.`)\n );\n } else {\n jsAssetName = assetName;\n }\n }\n }\n\n if (!jsAssetName) {\n compilation.errors.push(\n new thisWebpack.WebpackError(`Could not find a .js asset for chunk ${chunk.id}.`)\n );\n } else {\n const { trueHash, newJsFilename } = processChunkAsset(jsAssetName, undefined) ?? {};\n hashReplacementsByChunk.set(chunk, { existingHash, trueHashByLocale: trueHash });\n if (newJsFilename) {\n chunk.files.delete(jsAssetName);\n chunk.files.add(newJsFilename);\n }\n }\n }\n }\n\n unprocessedChunks.delete(chunk);\n const dependents: Set<Chunk> | undefined = dependentsByChunk.get(chunk);\n if (dependents) {\n for (const dependent of dependents) {\n unprocessedDependenciesByChunk.get(dependent)?.delete(chunk);\n }\n }\n }\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"trueHashes.js","sourceRoot":"","sources":["../src/trueHashes.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAsB3D,0CAUC;AAcD,8CAgQC;AA3SD,oEAAoD;AAGpD,+DAAuD;AAgBvD,SAAgB,eAAe,CAAC,EAAE,WAAW,EAAE,WAAW,EAA2B;IACnF,MAAM,EAAE,YAAY,GAAG,KAAK,EAAE,UAAU,GAAG,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,GAAG,WAAW,CAAC,aAAa,CAAC;IAC3G,OAAO,CAAC,QAAyB,EAAE,EAAE;QACnC,MAAM,IAAI,GAAgB,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,YA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AU,GAA2B,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;oBACxE,IAAI,UAAU,EAAE,CAAC;wBACf,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;4BACnC,MAAA,8BAA8B,CAAC,GAAG,CAAC,SAAS,CAAC,0CAAE,MAAM,CAAC,KAAK,CAAC,CAAC;wBAC/D,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { default as webpack, Compilation, Chunk, Asset, sources, util } from 'webpack';\nimport { Text } from '@rushstack/node-core-library';\n\nimport type { ILocalizedWebpackChunk } from './webpackInterfaces';\nimport { chunkIsJs } from './utilities/chunkUtilities';\n\ninterface IHashReplacement {\n existingHash: string;\n trueHashByLocale: string | Record<string, string> | undefined;\n}\n\ntype WebpackHash = ReturnType<typeof util.createHash>;\n\nexport type HashFn = (contents: string | Buffer) => string;\n\nexport interface IGetHashFunctionOptions {\n thisWebpack: typeof webpack;\n compilation: Compilation;\n}\n\nexport function getHashFunction({ thisWebpack, compilation }: IGetHashFunctionOptions): HashFn {\n const { hashFunction = 'md5', hashDigest = 'hex', hashDigestLength, hashSalt } = compilation.outputOptions;\n return (contents: string | Buffer) => {\n const hash: WebpackHash = thisWebpack.util.createHash(hashFunction);\n if (hashSalt) {\n hash.update(hashSalt, 'utf-8');\n }\n\n return hash.update(contents).digest(hashDigest).toString().slice(0, hashDigestLength);\n };\n}\n\nexport interface IUpdateAssetHashesOptions {\n thisWebpack: typeof webpack;\n compilation: Compilation;\n hashFn: HashFn;\n filesByChunkName?: Map<string, Record<string, string>>;\n}\n\ninterface IProcessChunkAssetResult {\n trueHash: string;\n newJsFilename: string;\n}\n\nexport function updateAssetHashes({\n thisWebpack,\n compilation,\n hashFn,\n filesByChunkName\n}: IUpdateAssetHashesOptions): void {\n const unprocessedDependenciesByChunk: Map<Chunk, Set<Chunk>> = new Map();\n const dependenciesByChunk: Map<Chunk, Set<Chunk>> = new Map();\n const dependentsByChunk: Map<Chunk, Set<Chunk>> = new Map();\n const unprocessedChunks: Set<Chunk> = new Set();\n const nonJsChunks: Set<Chunk> = new Set();\n\n for (const chunk of compilation.chunks) {\n if (!chunkIsJs(chunk, compilation.chunkGraph)) {\n nonJsChunks.add(chunk);\n } else {\n unprocessedChunks.add(chunk);\n }\n }\n\n for (const chunk of compilation.chunks) {\n let unprocessedDependencies: Set<Chunk> | undefined = unprocessedDependenciesByChunk.get(chunk);\n if (!unprocessedDependencies) {\n unprocessedDependencies = new Set();\n unprocessedDependenciesByChunk.set(chunk, unprocessedDependencies);\n }\n\n let dependencies: Set<Chunk> | undefined = dependenciesByChunk.get(chunk);\n if (!dependencies) {\n dependencies = new Set();\n dependenciesByChunk.set(chunk, dependencies);\n }\n\n if (chunk.hasRuntime()) {\n for (const asyncChunk of chunk.getAllAsyncChunks()) {\n if (!nonJsChunks.has(asyncChunk)) {\n unprocessedDependencies.add(asyncChunk);\n dependencies.add(asyncChunk);\n\n let dependents: Set<Chunk> | undefined = dependentsByChunk.get(asyncChunk);\n if (!dependents) {\n dependents = new Set();\n dependentsByChunk.set(asyncChunk, dependents);\n }\n\n dependents.add(chunk);\n\n if (!unprocessedChunks.has(asyncChunk)) {\n compilation.errors.push(\n new thisWebpack.WebpackError(\n `Found an async chunk that was not included in the compilation: ${asyncChunk.id} ` +\n `(reason: ${asyncChunk.chunkReason}).`\n )\n );\n }\n }\n }\n }\n }\n\n const hashReplacementsByChunk: Map<Chunk, IHashReplacement> = new Map();\n let previousSize: number = -1;\n while (unprocessedChunks.size > 0) {\n const currentSize: number = unprocessedChunks.size;\n if (currentSize === previousSize) {\n compilation.errors.push(\n new thisWebpack.WebpackError(\n `Detected a cycle in the chunk dependencies. This should not be possible.`\n )\n );\n\n break;\n }\n\n previousSize = currentSize;\n\n for (const chunk of unprocessedChunks) {\n if (unprocessedDependenciesByChunk.get(chunk)?.size === 0) {\n // TODO: do we need to check if the chunk is rendered?\n if (!chunk.renderedHash) {\n compilation.errors.push(\n new thisWebpack.WebpackError(`Could not find the hash for chunk ${chunk.id}.`)\n );\n } else {\n const existingHash: string = chunk.contentHash.javascript;\n const chunkDependencies: Set<Chunk> | undefined = dependenciesByChunk.get(chunk);\n if (!chunkDependencies) {\n compilation.errors.push(\n new thisWebpack.WebpackError(`Could not find dependencies for chunk ${chunk.id}.`)\n );\n } else {\n function processChunkAsset(\n jsAssetName: string,\n locale: string | undefined\n ): IProcessChunkAssetResult | undefined {\n const asset: Readonly<Asset> | undefined = compilation.getAsset(jsAssetName);\n if (!asset) {\n compilation.errors.push(\n new thisWebpack.WebpackError(`Could not find asset \"${jsAssetName}\" for chunk ${chunk.id}.`)\n );\n } else {\n let assetSource: sources.Source = asset.source;\n const assetName: string = asset.name;\n if (chunkDependencies!.size > 0) {\n const relevantHashReplacements: Map<string, string> = new Map();\n let hasAnyReplacements: boolean = false;\n for (const dependency of chunkDependencies!) {\n const asyncChunkHashReplacements: IHashReplacement | undefined =\n hashReplacementsByChunk.get(dependency);\n if (!asyncChunkHashReplacements) {\n compilation.errors.push(\n new thisWebpack.WebpackError(\n `Could not find hash replacements for chunk ${dependency.id}.`\n )\n );\n } else {\n const { existingHash: otherChunkExistingHash, trueHashByLocale } =\n asyncChunkHashReplacements;\n let replacementHash: string | undefined;\n if (typeof trueHashByLocale === 'object') {\n if (locale) {\n replacementHash = trueHashByLocale[locale];\n }\n } else {\n replacementHash = trueHashByLocale;\n }\n\n if (replacementHash) {\n if (relevantHashReplacements.has(otherChunkExistingHash)) {\n compilation.errors.push(\n new thisWebpack.WebpackError(\n `Found multiple replacements for hash ${otherChunkExistingHash} ` +\n `in chunk ${chunk.id}.`\n )\n );\n } else {\n relevantHashReplacements.set(otherChunkExistingHash, replacementHash);\n hasAnyReplacements = true;\n }\n }\n }\n }\n\n if (hasAnyReplacements) {\n const sourceString: string = assetSource.source().toString();\n const replaceSource: sources.ReplaceSource = new thisWebpack.sources.ReplaceSource(\n assetSource,\n assetName\n );\n\n const regexp: RegExp = new RegExp(\n Array.from(relevantHashReplacements.keys(), (hashToReplace) =>\n Text.escapeRegExp(hashToReplace)\n ).join('|'),\n 'g'\n );\n let match: RegExpMatchArray | null;\n while ((match = regexp.exec(sourceString)) !== null) {\n const { 0: originalHash, index } = match;\n const matchStart: number = index!;\n const matchEnd: number = matchStart + originalHash.length - 1;\n const replacement: string = relevantHashReplacements.get(originalHash)!;\n replaceSource.replace(matchStart, matchEnd, replacement);\n }\n\n assetSource = new thisWebpack.sources.CachedSource(replaceSource);\n compilation.updateAsset(jsAssetName, assetSource);\n }\n }\n\n if (jsAssetName.includes(existingHash)) {\n const trueHash: string = hashFn(assetSource.buffer());\n if (trueHash !== existingHash) {\n const newJsFilename: string = jsAssetName.replace(existingHash, trueHash);\n\n compilation.renameAsset(jsAssetName, newJsFilename);\n\n if (locale) {\n const filesForChunkName: Record<string, string> | undefined = chunk.name\n ? filesByChunkName?.get(chunk.name)\n : undefined;\n\n if (filesForChunkName) {\n filesForChunkName[locale] = newJsFilename;\n }\n }\n\n return {\n trueHash,\n newJsFilename\n };\n }\n }\n }\n }\n\n const localizedFiles: Record<string, string> | undefined = (chunk as ILocalizedWebpackChunk)\n .localizedFiles;\n if (localizedFiles) {\n const trueHashByLocale: Record<string, string> = {};\n hashReplacementsByChunk.set(chunk, {\n existingHash,\n trueHashByLocale\n });\n for (const [locale, jsAssetName] of Object.entries(localizedFiles)) {\n const processAssetResult: IProcessChunkAssetResult | undefined = processChunkAsset(\n jsAssetName,\n locale\n );\n if (processAssetResult) {\n const { trueHash, newJsFilename } = processAssetResult;\n trueHashByLocale[locale] = trueHash;\n localizedFiles[locale] = newJsFilename;\n }\n }\n } else {\n const assetNames: string[] = Array.from(chunk.files);\n let jsAssetName: string | undefined;\n for (const assetName of assetNames) {\n if (assetName.endsWith('.js')) {\n if (jsAssetName) {\n compilation.errors.push(\n new thisWebpack.WebpackError(`Found multiple .js assets for chunk ${chunk.id}.`)\n );\n } else {\n jsAssetName = assetName;\n }\n }\n }\n\n if (!jsAssetName) {\n compilation.errors.push(\n new thisWebpack.WebpackError(`Could not find a .js asset for chunk ${chunk.id}.`)\n );\n } else {\n const { trueHash, newJsFilename } = processChunkAsset(jsAssetName, undefined) ?? {};\n hashReplacementsByChunk.set(chunk, { existingHash, trueHashByLocale: trueHash });\n if (newJsFilename) {\n chunk.files.delete(jsAssetName);\n chunk.files.add(newJsFilename);\n }\n }\n }\n }\n\n unprocessedChunks.delete(chunk);\n const dependents: Set<Chunk> | undefined = dependentsByChunk.get(chunk);\n if (dependents) {\n for (const dependent of dependents) {\n unprocessedDependenciesByChunk.get(dependent)?.delete(chunk);\n }\n }\n }\n }\n }\n }\n}\n"]}
@@ -2,7 +2,8 @@
2
2
  // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
3
3
  // See LICENSE in the project root for license information.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.getMark = exports.markEntity = void 0;
5
+ exports.markEntity = markEntity;
6
+ exports.getMark = getMark;
6
7
  const MARKS = new WeakMap();
7
8
  /**
8
9
  * Marks a webpack entity as containing or not containing localized resources.
@@ -10,12 +11,10 @@ const MARKS = new WeakMap();
10
11
  function markEntity(entity, value) {
11
12
  MARKS.set(entity, value);
12
13
  }
13
- exports.markEntity = markEntity;
14
14
  /**
15
15
  * Read the cache marker for whether or not the entity contains localized resources.
16
16
  */
17
17
  function getMark(entity) {
18
18
  return MARKS.get(entity);
19
19
  }
20
- exports.getMark = getMark;
21
20
  //# sourceMappingURL=EntityMarker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EntityMarker.js","sourceRoot":"","sources":["../../src/utilities/EntityMarker.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,MAAM,KAAK,GAA6B,IAAI,OAAO,EAAE,CAAC;AAEtD;;GAEG;AACH,SAAgB,UAAU,CAAC,MAAc,EAAE,KAAc;IACvD,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAC3B,CAAC;AAFD,gCAEC;AAED;;GAEG;AACH,SAAgB,OAAO,CAAC,MAAc;IACpC,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC;AAFD,0BAEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nconst MARKS: WeakMap<object, boolean> = new WeakMap();\n\n/**\n * Marks a webpack entity as containing or not containing localized resources.\n */\nexport function markEntity(entity: object, value: boolean): void {\n MARKS.set(entity, value);\n}\n\n/**\n * Read the cache marker for whether or not the entity contains localized resources.\n */\nexport function getMark(entity: object): boolean | undefined {\n return MARKS.get(entity);\n}\n"]}
1
+ {"version":3,"file":"EntityMarker.js","sourceRoot":"","sources":["../../src/utilities/EntityMarker.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAO3D,gCAEC;AAKD,0BAEC;AAdD,MAAM,KAAK,GAA6B,IAAI,OAAO,EAAE,CAAC;AAEtD;;GAEG;AACH,SAAgB,UAAU,CAAC,MAAc,EAAE,KAAc;IACvD,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,SAAgB,OAAO,CAAC,MAAc;IACpC,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nconst MARKS: WeakMap<object, boolean> = new WeakMap();\n\n/**\n * Marks a webpack entity as containing or not containing localized resources.\n */\nexport function markEntity(entity: object, value: boolean): void {\n MARKS.set(entity, value);\n}\n\n/**\n * Read the cache marker for whether or not the entity contains localized resources.\n */\nexport function getMark(entity: object): boolean | undefined {\n return MARKS.get(entity);\n}\n"]}
@@ -2,9 +2,8 @@
2
2
  // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
3
3
  // See LICENSE in the project root for license information.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.chunkIsJs = void 0;
5
+ exports.chunkIsJs = chunkIsJs;
6
6
  function chunkIsJs(chunk, chunkGraph) {
7
7
  return !!chunkGraph.getChunkModulesIterableBySourceType(chunk, 'javascript');
8
8
  }
9
- exports.chunkIsJs = chunkIsJs;
10
9
  //# sourceMappingURL=chunkUtilities.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chunkUtilities.js","sourceRoot":"","sources":["../../src/utilities/chunkUtilities.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D,SAAgB,SAAS,CAAC,KAAY,EAAE,UAAsB;IAC5D,OAAO,CAAC,CAAC,UAAU,CAAC,mCAAmC,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AAC/E,CAAC;AAFD,8BAEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { Chunk, ChunkGraph } from 'webpack';\n\nexport function chunkIsJs(chunk: Chunk, chunkGraph: ChunkGraph): boolean {\n return !!chunkGraph.getChunkModulesIterableBySourceType(chunk, 'javascript');\n}\n"]}
1
+ {"version":3,"file":"chunkUtilities.js","sourceRoot":"","sources":["../../src/utilities/chunkUtilities.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAI3D,8BAEC;AAFD,SAAgB,SAAS,CAAC,KAAY,EAAE,UAAsB;IAC5D,OAAO,CAAC,CAAC,UAAU,CAAC,mCAAmC,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AAC/E,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { Chunk, ChunkGraph } from 'webpack';\n\nexport function chunkIsJs(chunk: Chunk, chunkGraph: ChunkGraph): boolean {\n return !!chunkGraph.getChunkModulesIterableBySourceType(chunk, 'javascript');\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/webpack5-localization-plugin",
3
- "version": "0.13.0",
3
+ "version": "0.13.2",
4
4
  "description": "This plugin facilitates localization with Webpack.",
5
5
  "main": "lib/index.js",
6
6
  "typings": "dist/webpack5-localization-plugin.d.ts",
@@ -15,15 +15,16 @@
15
15
  "@types/node": "*"
16
16
  },
17
17
  "dependencies": {
18
- "@rushstack/localization-utilities": "0.13.0",
18
+ "@rushstack/localization-utilities": "0.13.2",
19
19
  "@rushstack/node-core-library": "5.11.0",
20
20
  "@rushstack/terminal": "0.15.0"
21
21
  },
22
22
  "devDependencies": {
23
+ "@types/node": "20.17.19",
23
24
  "memfs": "4.12.0",
24
- "webpack": "~5.95.0",
25
- "local-node-rig": "1.0.0",
26
- "@rushstack/heft": "0.69.1"
25
+ "webpack": "~5.98.0",
26
+ "@rushstack/heft": "0.69.3",
27
+ "local-node-rig": "1.0.0"
27
28
  },
28
29
  "peerDependenciesMeta": {
29
30
  "@types/node": {