@rushstack/webpack4-localization-plugin 0.18.92 → 0.18.94

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,42 @@
1
1
  {
2
2
  "name": "@rushstack/webpack4-localization-plugin",
3
3
  "entries": [
4
+ {
5
+ "version": "0.18.94",
6
+ "tag": "@rushstack/webpack4-localization-plugin_v0.18.94",
7
+ "date": "Tue, 11 Mar 2025 02:12:34 GMT",
8
+ "comments": {
9
+ "dependency": [
10
+ {
11
+ "comment": "Updating dependency \"@rushstack/localization-utilities\" to `0.13.3`"
12
+ },
13
+ {
14
+ "comment": "Updating dependency \"@rushstack/node-core-library\" to `5.12.0`"
15
+ },
16
+ {
17
+ "comment": "Updating dependency \"@rushstack/terminal\" to `0.15.1`"
18
+ },
19
+ {
20
+ "comment": "Updating dependency \"@rushstack/heft\" to `0.70.0`"
21
+ }
22
+ ]
23
+ }
24
+ },
25
+ {
26
+ "version": "0.18.93",
27
+ "tag": "@rushstack/webpack4-localization-plugin_v0.18.93",
28
+ "date": "Tue, 11 Mar 2025 00:11:25 GMT",
29
+ "comments": {
30
+ "dependency": [
31
+ {
32
+ "comment": "Updating dependency \"@rushstack/localization-utilities\" to `0.13.2`"
33
+ },
34
+ {
35
+ "comment": "Updating dependency \"@rushstack/heft\" to `0.69.3`"
36
+ }
37
+ ]
38
+ }
39
+ },
4
40
  {
5
41
  "version": "0.18.92",
6
42
  "tag": "@rushstack/webpack4-localization-plugin_v0.18.92",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,16 @@
1
1
  # Change Log - @rushstack/webpack4-localization-plugin
2
2
 
3
- This log was last generated on Sat, 01 Mar 2025 05:00:09 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 11 Mar 2025 02:12:34 GMT and should not be manually modified.
4
+
5
+ ## 0.18.94
6
+ Tue, 11 Mar 2025 02:12:34 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 0.18.93
11
+ Tue, 11 Mar 2025 00:11:25 GMT
12
+
13
+ _Version update only_
4
14
 
5
15
  ## 0.18.92
6
16
  Sat, 01 Mar 2025 05:00:09 GMT
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.51.0"
8
+ "packageVersion": "7.52.0"
9
9
  }
10
10
  ]
11
11
  }
@@ -16,7 +16,7 @@ class AssetProcessor {
16
16
  const reconstructedAssetName = AssetProcessor._reconstructLocalized(parsedAssetName.reconstructionSeries, options.locales, options.fillMissingTranslationStrings, options.defaultLocale, options.assetName.length);
17
17
  const result = new Map();
18
18
  for (const [locale, { source, size }] of reconstructedAsset.result) {
19
- const newAsset = Object.assign({}, options.asset);
19
+ const newAsset = { ...options.asset };
20
20
  newAsset.source = () => source;
21
21
  newAsset.size = () => size;
22
22
  result.set(locale, {
@@ -52,7 +52,7 @@ class AssetProcessor {
52
52
  if (issues.length > 0) {
53
53
  options.compilation.errors.push(Error(`localization:\n${issues.map((issue) => ` ${issue}`).join('\n')}`));
54
54
  }
55
- const newAsset = Object.assign({}, options.asset);
55
+ const newAsset = { ...options.asset };
56
56
  newAsset.source = () => reconstructedAsset.result.source;
57
57
  newAsset.size = () => reconstructedAsset.result.size;
58
58
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"AssetProcessor.js","sourceRoot":"","sources":["../src/AssetProcessor.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D,qDAAkD;AA8ErC,QAAA,iBAAiB,GAAW,IAAI,MAAM,CACjD,GAAG,qBAAS,CAAC,yBAAyB,uCAAuC,EAC7E,GAAG,CACJ,CAAC;AAEF,MAAa,cAAc;IAClB,MAAM,CAAC,qBAAqB,CACjC,OAAsC;QAEtC,MAAM,WAAW,GAAW,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAEnD,MAAM,WAAW,GAAiB,cAAc,CAAC,oCA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,MAAM,EAAE,CAAC;oBACZ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;gBAC1C,CAAC;gBAED,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,KAAK,IAAI,CAAC,SAAS,CACzE,YAAY,CACb,IAAI,YAAY,IAAI,CAAC;YACxB,CAAC,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAlYD,wCAkYC","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 * as Webpack from 'webpack';\n\nimport { Constants } from './utilities/Constants';\nimport type { ILocaleElementMap } from './interfaces';\nimport type { LocalizationPlugin, IStringSerialNumberData as IStringData } from './LocalizationPlugin';\n\ninterface IReconstructionElement {\n kind: 'static' | 'localized' | 'dynamic';\n}\n\ninterface IStaticReconstructionElement extends IReconstructionElement {\n kind: 'static';\n staticString: string;\n}\n\ninterface ILocalizedReconstructionElement extends IReconstructionElement {\n kind: 'localized';\n values: ILocaleElementMap;\n size: number;\n stringName: string;\n escapedBackslash: string;\n locFilePath: string;\n}\n\ninterface IDynamicReconstructionElement extends IReconstructionElement {\n kind: 'dynamic';\n valueFn: (locale: string, token: string | undefined) => string;\n size: number;\n escapedBackslash: string;\n token?: string;\n}\n\ninterface IParseResult {\n issues: string[];\n reconstructionSeries: IReconstructionElement[];\n}\n\ninterface IReconstructedString {\n source: string;\n size: number;\n}\n\ninterface ILocalizedReconstructionResult {\n result: Map<string, IReconstructedString>;\n issues: string[];\n}\n\ninterface INonLocalizedReconstructionResult {\n result: IReconstructedString;\n issues: string[];\n}\n\nexport interface IProcessAssetOptionsBase {\n plugin: LocalizationPlugin;\n compilation: Webpack.compilation.Compilation;\n assetName: string;\n asset: IAsset;\n chunk: Webpack.compilation.Chunk;\n noStringsLocaleName: string;\n chunkHasLocalizedModules: (chunk: Webpack.compilation.Chunk) => boolean;\n}\n\nexport interface IProcessNonLocalizedAssetOptions extends IProcessAssetOptionsBase {}\n\nexport interface IProcessLocalizedAssetOptions extends IProcessAssetOptionsBase {\n locales: Set<string>;\n fillMissingTranslationStrings: boolean;\n defaultLocale: string;\n}\n\nexport interface IAsset {\n size(): number;\n source(): string;\n}\n\nexport interface IProcessAssetResult {\n filename: string;\n asset: IAsset;\n}\n\nexport const PLACEHOLDER_REGEX: RegExp = new RegExp(\n `${Constants.STRING_PLACEHOLDER_PREFIX}_(\\\\\\\\*)_([A-C])(\\\\+[^+]+\\\\+)?_(\\\\d+)`,\n 'g'\n);\n\nexport class AssetProcessor {\n public static processLocalizedAsset(\n options: IProcessLocalizedAssetOptions\n ): Map<string, IProcessAssetResult> {\n const assetSource: string = options.asset.source();\n\n const parsedAsset: IParseResult = AssetProcessor._parseStringToReconstructionSequence(\n options.plugin,\n assetSource,\n this._getJsonpFunction(options.chunk, options.chunkHasLocalizedModules, options.noStringsLocaleName)\n );\n const reconstructedAsset: ILocalizedReconstructionResult = AssetProcessor._reconstructLocalized(\n parsedAsset.reconstructionSeries,\n options.locales,\n options.fillMissingTranslationStrings,\n options.defaultLocale,\n options.asset.size()\n );\n\n const parsedAssetName: IParseResult = AssetProcessor._parseStringToReconstructionSequence(\n options.plugin,\n options.assetName,\n () => {\n throw new Error('unsupported');\n }\n );\n const reconstructedAssetName: ILocalizedReconstructionResult = AssetProcessor._reconstructLocalized(\n parsedAssetName.reconstructionSeries,\n options.locales,\n options.fillMissingTranslationStrings,\n options.defaultLocale,\n options.assetName.length\n );\n\n const result: Map<string, IProcessAssetResult> = new Map<string, IProcessAssetResult>();\n for (const [locale, { source, size }] of reconstructedAsset.result) {\n const newAsset: IAsset = { ...options.asset };\n newAsset.source = () => source;\n newAsset.size = () => size;\n\n result.set(locale, {\n filename: reconstructedAssetName.result.get(locale)!.source,\n asset: newAsset\n });\n }\n\n const issues: string[] = [\n ...parsedAsset.issues,\n ...reconstructedAsset.issues,\n ...parsedAssetName.issues,\n ...reconstructedAssetName.issues\n ];\n\n if (issues.length > 0) {\n options.compilation.errors.push(\n Error(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n\n return result;\n }\n\n public static processNonLocalizedAsset(options: IProcessNonLocalizedAssetOptions): IProcessAssetResult {\n const assetSource: string = options.asset.source();\n\n const parsedAsset: IParseResult = AssetProcessor._parseStringToReconstructionSequence(\n options.plugin,\n assetSource,\n this._getJsonpFunction(options.chunk, options.chunkHasLocalizedModules, options.noStringsLocaleName)\n );\n const reconstructedAsset: INonLocalizedReconstructionResult = AssetProcessor._reconstructNonLocalized(\n parsedAsset.reconstructionSeries,\n options.asset.size(),\n options.noStringsLocaleName\n );\n\n const parsedAssetName: IParseResult = AssetProcessor._parseStringToReconstructionSequence(\n options.plugin,\n options.assetName,\n () => {\n throw new Error('unsupported');\n }\n );\n const reconstructedAssetName: INonLocalizedReconstructionResult = AssetProcessor._reconstructNonLocalized(\n parsedAssetName.reconstructionSeries,\n options.assetName.length,\n options.noStringsLocaleName\n );\n\n const issues: string[] = [\n ...parsedAsset.issues,\n ...reconstructedAsset.issues,\n ...parsedAssetName.issues,\n ...reconstructedAssetName.issues\n ];\n\n if (issues.length > 0) {\n options.compilation.errors.push(\n Error(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n\n const newAsset: IAsset = { ...options.asset };\n newAsset.source = () => reconstructedAsset.result.source;\n newAsset.size = () => reconstructedAsset.result.size;\n return {\n filename: reconstructedAssetName.result.source,\n asset: newAsset\n };\n }\n\n private static _reconstructLocalized(\n reconstructionSeries: IReconstructionElement[],\n locales: Set<string>,\n fillMissingTranslationStrings: boolean,\n defaultLocale: string,\n initialSize: number\n ): ILocalizedReconstructionResult {\n const localizedResults: Map<string, IReconstructedString> = new Map<string, IReconstructedString>();\n const issues: string[] = [];\n\n for (const locale of locales) {\n const reconstruction: string[] = [];\n\n let sizeDiff: number = 0;\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'static': {\n reconstruction.push((element as IStaticReconstructionElement).staticString);\n break;\n }\n\n case 'localized': {\n const localizedElement: ILocalizedReconstructionElement =\n element as ILocalizedReconstructionElement;\n let newValue: string | undefined = localizedElement.values[locale];\n if (!newValue) {\n if (fillMissingTranslationStrings) {\n newValue = localizedElement.values[defaultLocale];\n } else {\n issues.push(\n `The string \"${localizedElement.stringName}\" in \"${localizedElement.locFilePath}\" is missing in ` +\n `the locale ${locale}`\n );\n\n newValue = '-- MISSING STRING --';\n }\n }\n\n const escapedBackslash: string = localizedElement.escapedBackslash || '\\\\';\n\n // Replace backslashes with the properly escaped backslash\n newValue = newValue.replace(/\\\\/g, escapedBackslash);\n\n // @todo: look into using JSON.parse(...) to get the escaping characters\n const escapingCharacterSequence: string = escapedBackslash.substr(escapedBackslash.length / 2);\n\n // Ensure the the quotemark, apostrophe, tab, and newline characters are properly escaped\n newValue = newValue.replace(/\\r/g, `${escapingCharacterSequence}r`);\n newValue = newValue.replace(/\\n/g, `${escapingCharacterSequence}n`);\n newValue = newValue.replace(/\\t/g, `${escapingCharacterSequence}t`);\n newValue = newValue.replace(/\\\"/g, `${escapingCharacterSequence}u0022`);\n newValue = newValue.replace(/\\'/g, `${escapingCharacterSequence}u0027`);\n\n reconstruction.push(newValue);\n sizeDiff += newValue.length - localizedElement.size;\n break;\n }\n\n case 'dynamic': {\n const dynamicElement: IDynamicReconstructionElement = element as IDynamicReconstructionElement;\n const newValue: string = dynamicElement.valueFn(locale, dynamicElement.token);\n reconstruction.push(newValue);\n sizeDiff += newValue.length - dynamicElement.size;\n break;\n }\n }\n }\n\n const newAssetSource: string = reconstruction.join('');\n localizedResults.set(locale, {\n source: newAssetSource,\n size: initialSize + sizeDiff\n });\n }\n\n return {\n issues,\n result: localizedResults\n };\n }\n\n private static _reconstructNonLocalized(\n reconstructionSeries: IReconstructionElement[],\n initialSize: number,\n noStringsLocaleName: string\n ): INonLocalizedReconstructionResult {\n const issues: string[] = [];\n\n const reconstruction: string[] = [];\n\n let sizeDiff: number = 0;\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'static': {\n reconstruction.push((element as IStaticReconstructionElement).staticString);\n break;\n }\n\n case 'localized': {\n const localizedElement: ILocalizedReconstructionElement =\n element as ILocalizedReconstructionElement;\n issues.push(\n `The string \"${localizedElement.stringName}\" in \"${localizedElement.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 reconstruction.push(newValue);\n sizeDiff += newValue.length - localizedElement.size;\n break;\n }\n\n case 'dynamic': {\n const dynamicElement: IDynamicReconstructionElement = element as IDynamicReconstructionElement;\n const newValue: string = dynamicElement.valueFn(noStringsLocaleName, dynamicElement.token);\n reconstruction.push(newValue);\n sizeDiff += newValue.length - dynamicElement.size;\n break;\n }\n }\n }\n\n const newAssetSource: string = reconstruction.join('');\n return {\n issues,\n result: {\n source: newAssetSource,\n size: initialSize + sizeDiff\n }\n };\n }\n\n private static _parseStringToReconstructionSequence(\n plugin: LocalizationPlugin,\n source: string,\n jsonpFunction: (locale: string, chunkIdToken: string | undefined) => string\n ): IParseResult {\n const issues: string[] = [];\n const reconstructionSeries: IReconstructionElement[] = [];\n\n let lastIndex: number = 0;\n let regexResult: RegExpExecArray | null;\n while ((regexResult = PLACEHOLDER_REGEX.exec(source))) {\n // eslint-disable-line no-cond-assign\n const staticElement: IStaticReconstructionElement = {\n kind: 'static',\n staticString: source.substring(lastIndex, regexResult.index)\n };\n reconstructionSeries.push(staticElement);\n\n const [placeholder, escapedBackslash, elementLabel, token, placeholderSerialNumber] = regexResult;\n\n let localizedReconstructionElement: IReconstructionElement;\n switch (elementLabel) {\n case Constants.STRING_PLACEHOLDER_LABEL: {\n const stringData: IStringData | undefined = plugin.getDataForSerialNumber(placeholderSerialNumber);\n if (!stringData) {\n issues.push(`Missing placeholder ${placeholder}`);\n const brokenLocalizedElement: IStaticReconstructionElement = {\n kind: 'static',\n staticString: placeholder\n };\n localizedReconstructionElement = brokenLocalizedElement;\n } else {\n const localizedElement: ILocalizedReconstructionElement = {\n kind: 'localized',\n values: stringData.values,\n size: placeholder.length,\n locFilePath: stringData.locFilePath,\n escapedBackslash: escapedBackslash,\n stringName: stringData.stringName\n };\n localizedReconstructionElement = localizedElement;\n }\n break;\n }\n\n case Constants.LOCALE_NAME_PLACEHOLDER_LABEL: {\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n valueFn: (locale: string) => locale,\n size: placeholder.length,\n escapedBackslash: escapedBackslash\n };\n localizedReconstructionElement = dynamicElement;\n break;\n }\n\n case Constants.JSONP_PLACEHOLDER_LABEL: {\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n valueFn: jsonpFunction,\n size: placeholder.length,\n escapedBackslash: escapedBackslash,\n token: token.substring(1, token.length - 1)\n };\n localizedReconstructionElement = dynamicElement;\n break;\n }\n\n default: {\n throw new Error(`Unexpected label ${elementLabel}`);\n }\n }\n\n reconstructionSeries.push(localizedReconstructionElement);\n lastIndex = regexResult.index + placeholder.length;\n }\n\n const lastElement: IStaticReconstructionElement = {\n kind: 'static',\n staticString: source.substr(lastIndex)\n };\n reconstructionSeries.push(lastElement);\n\n return {\n issues,\n reconstructionSeries\n };\n }\n\n private static _getJsonpFunction(\n chunk: Webpack.compilation.Chunk,\n chunkHasLocalizedModules: (chunk: Webpack.compilation.Chunk) => boolean,\n noStringsLocaleName: string\n ): (locale: string, chunkIdToken: string | undefined) => string {\n const idsWithStrings: Set<number | string> = new Set<number | string>();\n const idsWithoutStrings: Set<number | string> = new Set<number | string>();\n\n const asyncChunks: Set<Webpack.compilation.Chunk> = chunk.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(asyncChunk)) {\n idsWithStrings.add(chunkId);\n } else {\n idsWithoutStrings.add(chunkId);\n }\n }\n\n if (idsWithStrings.size === 0) {\n return () => JSON.stringify(noStringsLocaleName);\n } else if (idsWithoutStrings.size === 0) {\n return (locale: string) => JSON.stringify(locale);\n } else {\n // Generate an array [<locale>, <nostrings locale>] and an object that is used as an indexer into that\n // object that maps chunk IDs to 0s for chunks with localized strings and 1s for chunks without localized\n // strings\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]: number } = {};\n for (const idWithStrings of idsWithStrings) {\n chunkMapping[idWithStrings] = 0;\n }\n\n for (const idWithoutStrings of idsWithoutStrings) {\n chunkMapping[idWithoutStrings] = 1;\n }\n\n return (locale: string, chunkIdToken: string | undefined) => {\n if (!locale) {\n throw new Error('Missing locale name.');\n }\n\n return `(${JSON.stringify([locale, noStringsLocaleName])})[${JSON.stringify(\n chunkMapping\n )}[${chunkIdToken}]]`;\n };\n }\n }\n}\n"]}
1
+ {"version":3,"file":"AssetProcessor.js","sourceRoot":"","sources":["../src/AssetProcessor.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D,qDAAkD;AA8ErC,QAAA,iBAAiB,GAAW,IAAI,MAAM,CACjD,GAAG,qBAAS,CAAC,yBAAyB,uCAAuC,EAC7E,GAAG,CACJ,CAAC;AAEF,MAAa,cAAc;IAClB,MAAM,CAAC,qBAAqB,CACjC,OAAsC;QAEtC,MAAM,WAAW,GAAW,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAEnD,MAAM,WAAW,GAAiB,cAAc,CAAC,oCAAoC,CACnF,OAAO,CAAC,MAAM,EACd,WAAW,EACX,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,wBAAwB,EAAE,OAAO,CAAC,mBAAmB,CAAC,CACrG,CAAC;QACF,MAAM,kBAAkB,GAAmC,cAAc,CAAC,qBAAqB,CAC7F,WAAW,C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CACb,IAAI,YAAY,IAAI,CAAC;YACxB,CAAC,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAlYD,wCAkYC","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 * as Webpack from 'webpack';\n\nimport { Constants } from './utilities/Constants';\nimport type { ILocaleElementMap } from './interfaces';\nimport type { LocalizationPlugin, IStringSerialNumberData as IStringData } from './LocalizationPlugin';\n\ninterface IReconstructionElement {\n kind: 'static' | 'localized' | 'dynamic';\n}\n\ninterface IStaticReconstructionElement extends IReconstructionElement {\n kind: 'static';\n staticString: string;\n}\n\ninterface ILocalizedReconstructionElement extends IReconstructionElement {\n kind: 'localized';\n values: ILocaleElementMap;\n size: number;\n stringName: string;\n escapedBackslash: string;\n locFilePath: string;\n}\n\ninterface IDynamicReconstructionElement extends IReconstructionElement {\n kind: 'dynamic';\n valueFn: (locale: string, token: string | undefined) => string;\n size: number;\n escapedBackslash: string;\n token?: string;\n}\n\ninterface IParseResult {\n issues: string[];\n reconstructionSeries: IReconstructionElement[];\n}\n\ninterface IReconstructedString {\n source: string;\n size: number;\n}\n\ninterface ILocalizedReconstructionResult {\n result: Map<string, IReconstructedString>;\n issues: string[];\n}\n\ninterface INonLocalizedReconstructionResult {\n result: IReconstructedString;\n issues: string[];\n}\n\nexport interface IProcessAssetOptionsBase {\n plugin: LocalizationPlugin;\n compilation: Webpack.compilation.Compilation;\n assetName: string;\n asset: IAsset;\n chunk: Webpack.compilation.Chunk;\n noStringsLocaleName: string;\n chunkHasLocalizedModules: (chunk: Webpack.compilation.Chunk) => boolean;\n}\n\nexport interface IProcessNonLocalizedAssetOptions extends IProcessAssetOptionsBase {}\n\nexport interface IProcessLocalizedAssetOptions extends IProcessAssetOptionsBase {\n locales: Set<string>;\n fillMissingTranslationStrings: boolean;\n defaultLocale: string;\n}\n\nexport interface IAsset {\n size(): number;\n source(): string;\n}\n\nexport interface IProcessAssetResult {\n filename: string;\n asset: IAsset;\n}\n\nexport const PLACEHOLDER_REGEX: RegExp = new RegExp(\n `${Constants.STRING_PLACEHOLDER_PREFIX}_(\\\\\\\\*)_([A-C])(\\\\+[^+]+\\\\+)?_(\\\\d+)`,\n 'g'\n);\n\nexport class AssetProcessor {\n public static processLocalizedAsset(\n options: IProcessLocalizedAssetOptions\n ): Map<string, IProcessAssetResult> {\n const assetSource: string = options.asset.source();\n\n const parsedAsset: IParseResult = AssetProcessor._parseStringToReconstructionSequence(\n options.plugin,\n assetSource,\n this._getJsonpFunction(options.chunk, options.chunkHasLocalizedModules, options.noStringsLocaleName)\n );\n const reconstructedAsset: ILocalizedReconstructionResult = AssetProcessor._reconstructLocalized(\n parsedAsset.reconstructionSeries,\n options.locales,\n options.fillMissingTranslationStrings,\n options.defaultLocale,\n options.asset.size()\n );\n\n const parsedAssetName: IParseResult = AssetProcessor._parseStringToReconstructionSequence(\n options.plugin,\n options.assetName,\n () => {\n throw new Error('unsupported');\n }\n );\n const reconstructedAssetName: ILocalizedReconstructionResult = AssetProcessor._reconstructLocalized(\n parsedAssetName.reconstructionSeries,\n options.locales,\n options.fillMissingTranslationStrings,\n options.defaultLocale,\n options.assetName.length\n );\n\n const result: Map<string, IProcessAssetResult> = new Map<string, IProcessAssetResult>();\n for (const [locale, { source, size }] of reconstructedAsset.result) {\n const newAsset: IAsset = { ...options.asset };\n newAsset.source = () => source;\n newAsset.size = () => size;\n\n result.set(locale, {\n filename: reconstructedAssetName.result.get(locale)!.source,\n asset: newAsset\n });\n }\n\n const issues: string[] = [\n ...parsedAsset.issues,\n ...reconstructedAsset.issues,\n ...parsedAssetName.issues,\n ...reconstructedAssetName.issues\n ];\n\n if (issues.length > 0) {\n options.compilation.errors.push(\n Error(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n\n return result;\n }\n\n public static processNonLocalizedAsset(options: IProcessNonLocalizedAssetOptions): IProcessAssetResult {\n const assetSource: string = options.asset.source();\n\n const parsedAsset: IParseResult = AssetProcessor._parseStringToReconstructionSequence(\n options.plugin,\n assetSource,\n this._getJsonpFunction(options.chunk, options.chunkHasLocalizedModules, options.noStringsLocaleName)\n );\n const reconstructedAsset: INonLocalizedReconstructionResult = AssetProcessor._reconstructNonLocalized(\n parsedAsset.reconstructionSeries,\n options.asset.size(),\n options.noStringsLocaleName\n );\n\n const parsedAssetName: IParseResult = AssetProcessor._parseStringToReconstructionSequence(\n options.plugin,\n options.assetName,\n () => {\n throw new Error('unsupported');\n }\n );\n const reconstructedAssetName: INonLocalizedReconstructionResult = AssetProcessor._reconstructNonLocalized(\n parsedAssetName.reconstructionSeries,\n options.assetName.length,\n options.noStringsLocaleName\n );\n\n const issues: string[] = [\n ...parsedAsset.issues,\n ...reconstructedAsset.issues,\n ...parsedAssetName.issues,\n ...reconstructedAssetName.issues\n ];\n\n if (issues.length > 0) {\n options.compilation.errors.push(\n Error(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n\n const newAsset: IAsset = { ...options.asset };\n newAsset.source = () => reconstructedAsset.result.source;\n newAsset.size = () => reconstructedAsset.result.size;\n return {\n filename: reconstructedAssetName.result.source,\n asset: newAsset\n };\n }\n\n private static _reconstructLocalized(\n reconstructionSeries: IReconstructionElement[],\n locales: Set<string>,\n fillMissingTranslationStrings: boolean,\n defaultLocale: string,\n initialSize: number\n ): ILocalizedReconstructionResult {\n const localizedResults: Map<string, IReconstructedString> = new Map<string, IReconstructedString>();\n const issues: string[] = [];\n\n for (const locale of locales) {\n const reconstruction: string[] = [];\n\n let sizeDiff: number = 0;\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'static': {\n reconstruction.push((element as IStaticReconstructionElement).staticString);\n break;\n }\n\n case 'localized': {\n const localizedElement: ILocalizedReconstructionElement =\n element as ILocalizedReconstructionElement;\n let newValue: string | undefined = localizedElement.values[locale];\n if (!newValue) {\n if (fillMissingTranslationStrings) {\n newValue = localizedElement.values[defaultLocale];\n } else {\n issues.push(\n `The string \"${localizedElement.stringName}\" in \"${localizedElement.locFilePath}\" is missing in ` +\n `the locale ${locale}`\n );\n\n newValue = '-- MISSING STRING --';\n }\n }\n\n const escapedBackslash: string = localizedElement.escapedBackslash || '\\\\';\n\n // Replace backslashes with the properly escaped backslash\n newValue = newValue.replace(/\\\\/g, escapedBackslash);\n\n // @todo: look into using JSON.parse(...) to get the escaping characters\n const escapingCharacterSequence: string = escapedBackslash.substr(escapedBackslash.length / 2);\n\n // Ensure the the quotemark, apostrophe, tab, and newline characters are properly escaped\n newValue = newValue.replace(/\\r/g, `${escapingCharacterSequence}r`);\n newValue = newValue.replace(/\\n/g, `${escapingCharacterSequence}n`);\n newValue = newValue.replace(/\\t/g, `${escapingCharacterSequence}t`);\n newValue = newValue.replace(/\\\"/g, `${escapingCharacterSequence}u0022`);\n newValue = newValue.replace(/\\'/g, `${escapingCharacterSequence}u0027`);\n\n reconstruction.push(newValue);\n sizeDiff += newValue.length - localizedElement.size;\n break;\n }\n\n case 'dynamic': {\n const dynamicElement: IDynamicReconstructionElement = element as IDynamicReconstructionElement;\n const newValue: string = dynamicElement.valueFn(locale, dynamicElement.token);\n reconstruction.push(newValue);\n sizeDiff += newValue.length - dynamicElement.size;\n break;\n }\n }\n }\n\n const newAssetSource: string = reconstruction.join('');\n localizedResults.set(locale, {\n source: newAssetSource,\n size: initialSize + sizeDiff\n });\n }\n\n return {\n issues,\n result: localizedResults\n };\n }\n\n private static _reconstructNonLocalized(\n reconstructionSeries: IReconstructionElement[],\n initialSize: number,\n noStringsLocaleName: string\n ): INonLocalizedReconstructionResult {\n const issues: string[] = [];\n\n const reconstruction: string[] = [];\n\n let sizeDiff: number = 0;\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'static': {\n reconstruction.push((element as IStaticReconstructionElement).staticString);\n break;\n }\n\n case 'localized': {\n const localizedElement: ILocalizedReconstructionElement =\n element as ILocalizedReconstructionElement;\n issues.push(\n `The string \"${localizedElement.stringName}\" in \"${localizedElement.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 reconstruction.push(newValue);\n sizeDiff += newValue.length - localizedElement.size;\n break;\n }\n\n case 'dynamic': {\n const dynamicElement: IDynamicReconstructionElement = element as IDynamicReconstructionElement;\n const newValue: string = dynamicElement.valueFn(noStringsLocaleName, dynamicElement.token);\n reconstruction.push(newValue);\n sizeDiff += newValue.length - dynamicElement.size;\n break;\n }\n }\n }\n\n const newAssetSource: string = reconstruction.join('');\n return {\n issues,\n result: {\n source: newAssetSource,\n size: initialSize + sizeDiff\n }\n };\n }\n\n private static _parseStringToReconstructionSequence(\n plugin: LocalizationPlugin,\n source: string,\n jsonpFunction: (locale: string, chunkIdToken: string | undefined) => string\n ): IParseResult {\n const issues: string[] = [];\n const reconstructionSeries: IReconstructionElement[] = [];\n\n let lastIndex: number = 0;\n let regexResult: RegExpExecArray | null;\n while ((regexResult = PLACEHOLDER_REGEX.exec(source))) {\n // eslint-disable-line no-cond-assign\n const staticElement: IStaticReconstructionElement = {\n kind: 'static',\n staticString: source.substring(lastIndex, regexResult.index)\n };\n reconstructionSeries.push(staticElement);\n\n const [placeholder, escapedBackslash, elementLabel, token, placeholderSerialNumber] = regexResult;\n\n let localizedReconstructionElement: IReconstructionElement;\n switch (elementLabel) {\n case Constants.STRING_PLACEHOLDER_LABEL: {\n const stringData: IStringData | undefined = plugin.getDataForSerialNumber(placeholderSerialNumber);\n if (!stringData) {\n issues.push(`Missing placeholder ${placeholder}`);\n const brokenLocalizedElement: IStaticReconstructionElement = {\n kind: 'static',\n staticString: placeholder\n };\n localizedReconstructionElement = brokenLocalizedElement;\n } else {\n const localizedElement: ILocalizedReconstructionElement = {\n kind: 'localized',\n values: stringData.values,\n size: placeholder.length,\n locFilePath: stringData.locFilePath,\n escapedBackslash: escapedBackslash,\n stringName: stringData.stringName\n };\n localizedReconstructionElement = localizedElement;\n }\n break;\n }\n\n case Constants.LOCALE_NAME_PLACEHOLDER_LABEL: {\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n valueFn: (locale: string) => locale,\n size: placeholder.length,\n escapedBackslash: escapedBackslash\n };\n localizedReconstructionElement = dynamicElement;\n break;\n }\n\n case Constants.JSONP_PLACEHOLDER_LABEL: {\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n valueFn: jsonpFunction,\n size: placeholder.length,\n escapedBackslash: escapedBackslash,\n token: token.substring(1, token.length - 1)\n };\n localizedReconstructionElement = dynamicElement;\n break;\n }\n\n default: {\n throw new Error(`Unexpected label ${elementLabel}`);\n }\n }\n\n reconstructionSeries.push(localizedReconstructionElement);\n lastIndex = regexResult.index + placeholder.length;\n }\n\n const lastElement: IStaticReconstructionElement = {\n kind: 'static',\n staticString: source.substr(lastIndex)\n };\n reconstructionSeries.push(lastElement);\n\n return {\n issues,\n reconstructionSeries\n };\n }\n\n private static _getJsonpFunction(\n chunk: Webpack.compilation.Chunk,\n chunkHasLocalizedModules: (chunk: Webpack.compilation.Chunk) => boolean,\n noStringsLocaleName: string\n ): (locale: string, chunkIdToken: string | undefined) => string {\n const idsWithStrings: Set<number | string> = new Set<number | string>();\n const idsWithoutStrings: Set<number | string> = new Set<number | string>();\n\n const asyncChunks: Set<Webpack.compilation.Chunk> = chunk.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(asyncChunk)) {\n idsWithStrings.add(chunkId);\n } else {\n idsWithoutStrings.add(chunkId);\n }\n }\n\n if (idsWithStrings.size === 0) {\n return () => JSON.stringify(noStringsLocaleName);\n } else if (idsWithoutStrings.size === 0) {\n return (locale: string) => JSON.stringify(locale);\n } else {\n // Generate an array [<locale>, <nostrings locale>] and an object that is used as an indexer into that\n // object that maps chunk IDs to 0s for chunks with localized strings and 1s for chunks without localized\n // strings\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]: number } = {};\n for (const idWithStrings of idsWithStrings) {\n chunkMapping[idWithStrings] = 0;\n }\n\n for (const idWithoutStrings of idsWithoutStrings) {\n chunkMapping[idWithoutStrings] = 1;\n }\n\n return (locale: string, chunkIdToken: string | undefined) => {\n if (!locale) {\n throw new Error('Missing locale name.');\n }\n\n return `(${JSON.stringify([locale, noStringsLocaleName])})[${JSON.stringify(\n chunkMapping\n )}[${chunkIdToken}]]`;\n };\n }\n }\n}\n"]}
@@ -17,13 +17,23 @@ 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
38
  exports.LocalizationPlugin = void 0;
29
39
  const node_core_library_1 = require("@rushstack/node-core-library");
@@ -1 +1 @@
1
- {"version":3,"file":"LocalizationPlugin.js","sourceRoot":"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UAAU,IAAI,KAAK,CAAC,iBAAiB,EAAE,EAAE,CAAC;oBACnD,IAAI,IAAI,CAAC,yBAAyB,CAAC,UAAU,CAAC,EAAE,CAAC;wBAC/C,qBAAqB,GAAG,IAAI,CAAC;wBAC7B,MAAM;oBACR,CAAC;gBACH,CAAC;YACH,CAAC;YAED,2BAAY,CAAC,UAAU,CAAC,KAAK,EAAE,qBAAqB,CAAC,CAAC;QACxD,CAAC;QAED,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IAEO,iCAAiC,CAAC,OAA0B;QAClE,MAAM,WAAW,GAAoB,EAAE,CAAC;QACxC,KAAK,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACjE,WAAW,CAAC,UAAU,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC;QAC/C,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AAxwBD,gDAwwBC","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 { JsonFile, FileSystem, NewlineKind } from '@rushstack/node-core-library';\nimport type { ITerminal } from '@rushstack/terminal';\nimport * as Webpack from 'webpack';\nimport * as path from 'path';\nimport type * as Tapable from 'tapable';\nimport {\n getPseudolocalizer,\n type ILocalizationFile,\n parseLocFile,\n TypingsGenerator\n} from '@rushstack/localization-utilities';\n\nimport { Constants } from './utilities/Constants';\nimport {\n type IWebpackConfigurationUpdaterOptions,\n WebpackConfigurationUpdater\n} from './WebpackConfigurationUpdater';\nimport type {\n ILocalizationPluginOptions,\n ILocalizationStats,\n ILocaleFileData,\n ILocaleElementMap,\n ILocalizedStrings,\n IResolvedMissingTranslations\n} from './interfaces';\nimport type { ILocalizedWebpackChunk } from './webpackInterfaces';\nimport { EntityMarker } from './utilities/EntityMarker';\nimport { type IAsset, type IProcessAssetResult, AssetProcessor, PLACEHOLDER_REGEX } from './AssetProcessor';\n\n/**\n * @internal\n */\nexport interface IStringPlaceholder {\n value: string;\n suffix: string;\n}\n\n/**\n * @internal\n */\nexport interface IAddDefaultLocFileResult {\n /**\n * A list of paths to translation files that were loaded\n */\n additionalLoadedFilePaths: string[];\n\n errors: Error[];\n}\n\ninterface IExtendedMainTemplate {\n hooks: {\n assetPath: Tapable.SyncHook<string, IAssetPathOptions>;\n };\n}\n\ninterface IExtendedConfiguration extends Webpack.compilation.Compilation {\n options: Webpack.Configuration;\n}\n\ninterface IExtendedChunkGroup extends Webpack.compilation.ChunkGroup {\n getChildren(): Webpack.compilation.Chunk[];\n}\n\ninterface IExtendedChunk extends Webpack.compilation.Chunk {\n filenameTemplate: string;\n}\n\ninterface IAssetPathOptions {\n chunk: Webpack.compilation.Chunk;\n contentHashType: string;\n filename: string;\n}\n\n/**\n * @internal\n */\nexport interface IStringSerialNumberData {\n values: ILocaleElementMap;\n locFilePath: string;\n stringName: string;\n}\n\nconst PLUGIN_NAME: string = 'localization';\n\n/**\n * This plugin facilitates localization in webpack.\n *\n * @public\n */\nexport class LocalizationPlugin implements Webpack.Plugin {\n /**\n * @internal\n */\n public stringKeys: Map<string, IStringPlaceholder> = new Map<string, IStringPlaceholder>();\n\n private _options: ILocalizationPluginOptions;\n private _resolvedTranslatedStringsFromOptions!: ILocalizedStrings;\n private _globsToIgnore: string[] | undefined;\n private _stringPlaceholderCounter: number = 0;\n private _stringPlaceholderMap: Map<string, IStringSerialNumberData> = new Map<\n string,\n IStringSerialNumberData\n >();\n private _locales: Set<string> = new Set<string>();\n private _passthroughLocaleName!: string;\n private _defaultLocale!: string;\n private _noStringsLocaleName!: string;\n private _fillMissingTranslationStrings!: boolean;\n private _pseudolocalizers: Map<string, (str: string) => string> = new Map<\n string,\n (str: string) => string\n >();\n private _resxNewlineNormalization: NewlineKind | undefined;\n private _ignoreMissingResxComments: boolean | undefined;\n\n /**\n * The outermost map's keys are the locale names.\n * The middle map's keys are the resolved, file names.\n * The innermost map's keys are the string identifiers and its values are the string values.\n */\n private _resolvedLocalizedStrings: Map<string, Map<string, Map<string, string>>> = new Map<\n string,\n Map<string, Map<string, string>>\n >();\n\n public constructor(options: ILocalizationPluginOptions) {\n if (options.filesToIgnore) {\n throw new Error('The filesToIgnore option is no longer supported. Please use globsToIgnore instead.');\n }\n\n if (options.typingsOptions?.ignoreString) {\n throw new Error(\n 'The typingsOptions.ignoreString option is no longer supported. Please use the ignoreString ' +\n 'option directly on the constructor options object instead.'\n );\n }\n\n this._options = options;\n }\n\n public apply(compiler: Webpack.Compiler): void {\n const isWebpack4: boolean = !!compiler.hooks;\n\n if (!isWebpack4) {\n throw new Error(`The ${LocalizationPlugin.name} plugin requires Webpack 4`);\n }\n\n if (this._options.typingsOptions && compiler.context) {\n if (\n this._options.typingsOptions.generatedTsFolder &&\n !path.isAbsolute(this._options.typingsOptions.generatedTsFolder)\n ) {\n this._options.typingsOptions.generatedTsFolder = path.resolve(\n compiler.context,\n this._options.typingsOptions.generatedTsFolder\n );\n }\n\n if (\n this._options.typingsOptions.sourceRoot &&\n !path.isAbsolute(this._options.typingsOptions.sourceRoot)\n ) {\n this._options.typingsOptions.sourceRoot = path.resolve(\n compiler.context,\n this._options.typingsOptions.sourceRoot\n );\n }\n\n const secondaryGeneratedTsFolders: string[] | undefined =\n this._options.typingsOptions.secondaryGeneratedTsFolders;\n if (secondaryGeneratedTsFolders) {\n for (let i: number = 0; i < secondaryGeneratedTsFolders.length; i++) {\n const secondaryGeneratedTsFolder: string = secondaryGeneratedTsFolders[i];\n if (!path.isAbsolute(secondaryGeneratedTsFolder)) {\n secondaryGeneratedTsFolders[i] = path.resolve(compiler.context, secondaryGeneratedTsFolder);\n }\n }\n }\n }\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.options, isWebpackDevServer);\n\n let typingsPreprocessor: TypingsGenerator | undefined;\n if (this._options.typingsOptions) {\n typingsPreprocessor = new TypingsGenerator({\n srcFolder: this._options.typingsOptions.sourceRoot || compiler.context,\n generatedTsFolder: this._options.typingsOptions.generatedTsFolder,\n secondaryGeneratedTsFolders: this._options.typingsOptions.secondaryGeneratedTsFolders,\n exportAsDefault: this._options.typingsOptions.exportAsDefault,\n globsToIgnore: this._options.globsToIgnore,\n ignoreString: this._options.ignoreString,\n processComment: this._options.typingsOptions.processComment\n });\n } else {\n typingsPreprocessor = undefined;\n }\n\n const webpackConfigurationUpdaterOptions: IWebpackConfigurationUpdaterOptions = {\n pluginInstance: this,\n configuration: compiler.options,\n globsToIgnore: this._globsToIgnore,\n localeNameOrPlaceholder: Constants.LOCALE_NAME_PLACEHOLDER,\n resxNewlineNormalization: this._resxNewlineNormalization,\n ignoreMissingResxComments: this._ignoreMissingResxComments,\n ignoreString: this._options.ignoreString\n };\n\n if (errors.length > 0 || warnings.length > 0) {\n compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation: Webpack.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 WebpackConfigurationUpdater.amendWebpackConfigurationForInPlaceLocFiles(\n webpackConfigurationUpdaterOptions\n );\n return;\n }\n }\n\n if (isWebpackDevServer) {\n if (typingsPreprocessor) {\n compiler.hooks.afterEnvironment.tap(PLUGIN_NAME, () => typingsPreprocessor!.runWatcherAsync());\n\n if (!compiler.options.plugins) {\n compiler.options.plugins = [];\n }\n\n compiler.options.plugins.push(\n new Webpack.WatchIgnorePlugin([this._options.typingsOptions!.generatedTsFolder])\n );\n }\n\n WebpackConfigurationUpdater.amendWebpackConfigurationForInPlaceLocFiles(\n webpackConfigurationUpdaterOptions\n );\n } else {\n if (typingsPreprocessor) {\n compiler.hooks.beforeRun.tapPromise(\n PLUGIN_NAME,\n async () => await typingsPreprocessor!.generateTypingsAsync()\n );\n }\n\n WebpackConfigurationUpdater.amendWebpackConfigurationForMultiLocale(webpackConfigurationUpdaterOptions);\n\n if (errors.length === 0) {\n compiler.hooks.thisCompilation.tap(\n PLUGIN_NAME,\n (untypedCompilation: Webpack.compilation.Compilation) => {\n const compilation: IExtendedConfiguration = untypedCompilation as IExtendedConfiguration;\n (compilation.mainTemplate as unknown as IExtendedMainTemplate).hooks.assetPath.tap(\n PLUGIN_NAME,\n (assetPath: string, options: IAssetPathOptions) => {\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 as string).match(/^\\\" \\+/)) {\n return assetPath.replace(\n Constants.LOCALE_FILENAME_TOKEN_REGEX,\n `\" + ${Constants.JSONP_PLACEHOLDER} + \"`\n );\n } else {\n return assetPath.replace(\n Constants.LOCALE_FILENAME_TOKEN_REGEX,\n Constants.LOCALE_NAME_PLACEHOLDER\n );\n }\n } else if (assetPath.match(Constants.NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN_REGEX)) {\n // Replace the placeholder with the [locale] token for sourcemaps\n const deLocalizedFilename: string = options.filename.replace(\n PLACEHOLDER_REGEX,\n Constants.LOCALE_FILENAME_TOKEN\n );\n return assetPath.replace(\n Constants.NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN_REGEX,\n deLocalizedFilename\n );\n } else {\n return assetPath;\n }\n }\n );\n\n compilation.hooks.optimizeChunks.tap(\n PLUGIN_NAME,\n (\n untypedChunks: Webpack.compilation.Chunk[],\n untypedChunkGroups: Webpack.compilation.ChunkGroup[]\n ) => {\n const chunks: IExtendedChunk[] = untypedChunks as IExtendedChunk[];\n const chunkGroups: IExtendedChunkGroup[] = untypedChunkGroups as IExtendedChunkGroup[];\n\n let chunksHaveAnyChildren: boolean = false;\n for (const chunkGroup of chunkGroups) {\n const children: Webpack.compilation.Chunk[] = chunkGroup.getChildren();\n if (children.length > 0) {\n chunksHaveAnyChildren = true;\n break;\n }\n }\n\n if (\n chunksHaveAnyChildren &&\n (!compilation.options.output ||\n !compilation.options.output.chunkFilename ||\n compilation.options.output.chunkFilename.indexOf(Constants.LOCALE_FILENAME_TOKEN) === -1)\n ) {\n compilation.errors.push(\n new Error(\n 'The configuration.output.chunkFilename property must be provided and must include ' +\n `the ${Constants.LOCALE_FILENAME_TOKEN} placeholder`\n )\n );\n\n return;\n }\n\n for (const chunk of chunks) {\n // See if the chunk contains any localized modules or loads any localized chunks\n const localizedChunk: boolean = this._chunkHasLocalizedModules(chunk);\n\n // Change the chunk's name to include either the locale name or the locale name for chunks without strings\n const replacementValue: string = localizedChunk\n ? Constants.LOCALE_NAME_PLACEHOLDER\n : this._noStringsLocaleName;\n if (chunk.hasRuntime()) {\n chunk.filenameTemplate = (compilation.options.output!.filename as string).replace(\n Constants.LOCALE_FILENAME_TOKEN_REGEX,\n replacementValue\n );\n } else {\n chunk.filenameTemplate = compilation.options.output!.chunkFilename!.replace(\n Constants.LOCALE_FILENAME_TOKEN_REGEX,\n replacementValue\n );\n }\n }\n }\n );\n }\n );\n\n compiler.hooks.emit.tap(PLUGIN_NAME, (compilation: Webpack.compilation.Compilation) => {\n const localizationStats: ILocalizationStats = {\n entrypoints: {},\n namedChunkGroups: {}\n };\n\n const alreadyProcessedAssets: Set<string> = new Set<string>();\n const hotUpdateRegex: RegExp = /\\.hot-update\\.js$/;\n\n for (const untypedChunk of compilation.chunks) {\n const chunk: ILocalizedWebpackChunk = untypedChunk;\n const chunkFilesSet: Set<string> = new Set(chunk.files);\n function processChunkJsFile(callback: (chunkFilename: string) => void): void {\n let alreadyProcessedAFileInThisChunk: boolean = false;\n for (const chunkFilename of chunk.files) {\n if (\n chunkFilename.endsWith('.js') && // Ensure this is a JS file\n !hotUpdateRegex.test(chunkFilename) && // Ensure this is not a webpack hot update\n !alreadyProcessedAssets.has(chunkFilename) // Ensure this isn't a vendor chunk we've already processed\n ) {\n if (alreadyProcessedAFileInThisChunk) {\n throw new Error(\n `Found more than one JS file in chunk \"${chunk.name}\". This is not expected.`\n );\n }\n\n alreadyProcessedAFileInThisChunk = true;\n alreadyProcessedAssets.add(chunkFilename);\n callback(chunkFilename);\n }\n }\n }\n\n if (this._chunkHasLocalizedModules(chunk)) {\n processChunkJsFile((chunkFilename) => {\n if (chunkFilename.indexOf(Constants.LOCALE_NAME_PLACEHOLDER) === -1) {\n throw new Error(\n `Asset ${chunkFilename} is expected to be localized, but is missing a locale placeholder`\n );\n }\n\n const asset: IAsset = compilation.assets[chunkFilename];\n\n const resultingAssets: Map<string, IProcessAssetResult> =\n AssetProcessor.processLocalizedAsset({\n plugin: this,\n compilation,\n assetName: chunkFilename,\n asset,\n chunk,\n chunkHasLocalizedModules: this._chunkHasLocalizedModules.bind(this),\n locales: this._locales,\n noStringsLocaleName: this._noStringsLocaleName,\n fillMissingTranslationStrings: this._fillMissingTranslationStrings,\n defaultLocale: this._defaultLocale\n });\n\n // Delete the existing asset because it's been renamed\n delete compilation.assets[chunkFilename];\n chunkFilesSet.delete(chunkFilename);\n\n const localizedChunkAssets: ILocaleElementMap = {};\n for (const [locale, newAsset] of resultingAssets) {\n compilation.assets[newAsset.filename] = newAsset.asset;\n localizedChunkAssets[locale] = newAsset.filename;\n chunkFilesSet.add(newAsset.filename);\n }\n\n if (chunk.hasRuntime()) {\n // This is an entrypoint\n localizationStats.entrypoints[chunk.name] = {\n localizedAssets: localizedChunkAssets\n };\n } else {\n // This is a secondary chunk\n if (chunk.name) {\n localizationStats.namedChunkGroups[chunk.name] = {\n localizedAssets: localizedChunkAssets\n };\n }\n }\n\n chunk.localizedFiles = localizedChunkAssets;\n });\n } else {\n processChunkJsFile((chunkFilename) => {\n const asset: IAsset = compilation.assets[chunkFilename];\n\n const resultingAsset: IProcessAssetResult = AssetProcessor.processNonLocalizedAsset({\n plugin: this,\n compilation,\n assetName: chunkFilename,\n asset,\n chunk,\n noStringsLocaleName: this._noStringsLocaleName,\n chunkHasLocalizedModules: this._chunkHasLocalizedModules.bind(this)\n });\n\n // Delete the existing asset because it's been renamed\n delete compilation.assets[chunkFilename];\n chunkFilesSet.delete(chunkFilename);\n\n compilation.assets[resultingAsset.filename] = resultingAsset.asset;\n chunkFilesSet.add(resultingAsset.filename);\n });\n }\n\n chunk.files = Array.from(chunkFilesSet);\n }\n\n if (this._options.localizationStats) {\n if (this._options.localizationStats.dropPath) {\n const resolvedLocalizationStatsDropPath: string = path.resolve(\n compiler.outputPath,\n this._options.localizationStats.dropPath\n );\n JsonFile.save(localizationStats, resolvedLocalizationStatsDropPath, {\n ensureFolderExists: true\n });\n }\n\n if (this._options.localizationStats.callback) {\n try {\n this._options.localizationStats.callback(localizationStats);\n } catch (e) {\n /* swallow errors from the callback */\n }\n }\n }\n });\n }\n }\n }\n\n /**\n * @internal\n *\n * @returns\n */\n public addDefaultLocFile(\n terminal: ITerminal,\n localizedResourcePath: string,\n localizedResourceData: ILocalizationFile\n ): IAddDefaultLocFileResult {\n const additionalLoadedFilePaths: string[] = [];\n const errors: Error[] = [];\n\n const locFileData: ILocaleFileData = this._convertLocalizationFileToLocData(localizedResourceData);\n this._addLocFile(this._defaultLocale, localizedResourcePath, locFileData);\n\n const normalizeLocalizedData: (localizedData: ILocaleFileData | string) => ILocaleFileData = (\n localizedData\n ) => {\n if (typeof localizedData === 'string') {\n additionalLoadedFilePaths.push(localizedData);\n const localizationFile: ILocalizationFile = parseLocFile({\n filePath: localizedData,\n content: FileSystem.readFile(localizedData),\n terminal: terminal,\n resxNewlineNormalization: this._resxNewlineNormalization,\n ignoreMissingResxComments: this._ignoreMissingResxComments\n });\n\n return this._convertLocalizationFileToLocData(localizationFile);\n } else {\n return localizedData;\n }\n };\n\n const missingLocales: string[] = [];\n for (const [translatedLocaleName, translatedStrings] of Object.entries(\n this._resolvedTranslatedStringsFromOptions\n )) {\n const translatedLocFileFromOptions: ILocaleFileData | string | undefined =\n translatedStrings[localizedResourcePath];\n if (!translatedLocFileFromOptions) {\n missingLocales.push(translatedLocaleName);\n } else {\n const translatedLocFileData: ILocaleFileData = normalizeLocalizedData(translatedLocFileFromOptions);\n this._addLocFile(translatedLocaleName, localizedResourcePath, translatedLocFileData);\n }\n }\n\n if (missingLocales.length > 0 && this._options.localizedData.resolveMissingTranslatedStrings) {\n let resolvedTranslatedData: IResolvedMissingTranslations | undefined = undefined;\n try {\n resolvedTranslatedData = this._options.localizedData.resolveMissingTranslatedStrings(\n missingLocales,\n localizedResourcePath\n );\n } catch (e) {\n errors.push(e as Error);\n }\n\n if (resolvedTranslatedData) {\n for (const [resolvedLocaleName, resolvedLocaleData] of Object.entries(resolvedTranslatedData)) {\n if (resolvedLocaleData) {\n const translatedLocFileData: ILocaleFileData = normalizeLocalizedData(resolvedLocaleData);\n this._addLocFile(resolvedLocaleName, localizedResourcePath, translatedLocFileData);\n }\n }\n }\n }\n\n this._pseudolocalizers.forEach((pseudolocalizer: (str: string) => string, pseudolocaleName: string) => {\n const pseudolocFileData: ILocaleFileData = {};\n\n for (const [stringName, stringValue] of Object.entries(locFileData)) {\n pseudolocFileData[stringName] = pseudolocalizer(stringValue);\n }\n\n this._addLocFile(pseudolocaleName, localizedResourcePath, pseudolocFileData);\n });\n\n return { additionalLoadedFilePaths, errors };\n }\n\n /**\n * @internal\n */\n public getDataForSerialNumber(serialNumber: string): IStringSerialNumberData | undefined {\n return this._stringPlaceholderMap.get(serialNumber);\n }\n\n private _addLocFile(\n localeName: string,\n localizedFilePath: string,\n localizedFileData: ILocaleFileData\n ): void {\n const filesMap: Map<string, Map<string, string>> = this._resolvedLocalizedStrings.get(localeName)!;\n\n const stringsMap: Map<string, string> = new Map<string, string>();\n filesMap.set(localizedFilePath, stringsMap);\n\n for (const [stringName, stringValue] of Object.entries(localizedFileData)) {\n const stringKey: string = `${localizedFilePath}?${stringName}`;\n if (!this.stringKeys.has(stringKey)) {\n const placeholder: IStringPlaceholder = this._getPlaceholderString();\n this.stringKeys.set(stringKey, placeholder);\n }\n\n const placeholder: IStringPlaceholder = this.stringKeys.get(stringKey)!;\n if (!this._stringPlaceholderMap.has(placeholder.suffix)) {\n this._stringPlaceholderMap.set(placeholder.suffix, {\n values: {\n [this._passthroughLocaleName]: stringName\n },\n locFilePath: localizedFilePath,\n stringName: stringName\n });\n }\n\n this._stringPlaceholderMap.get(placeholder.suffix)!.values[localeName] = stringValue;\n\n stringsMap.set(stringName, stringValue);\n }\n }\n\n private _initializeAndValidateOptions(\n configuration: Webpack.Configuration,\n isWebpackDevServer: boolean\n ): { errors: Error[]; warnings: Error[] } {\n const errors: Error[] = [];\n const warnings: Error[] = [];\n\n function ensureValidLocaleName(localeName: string): boolean {\n const LOCALE_NAME_REGEX: RegExp = /[a-z-]/i;\n if (!localeName.match(LOCALE_NAME_REGEX)) {\n errors.push(\n new Error(`Invalid locale name: ${localeName}. Locale names may only contain letters and hyphens.`)\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 Error(\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 // eslint-disable-next-line no-lone-blocks\n {\n this._globsToIgnore = this._options.globsToIgnore;\n }\n // END misc options\n\n // START options.localizedData\n if (this._options.localizedData) {\n this._ignoreMissingResxComments = this._options.localizedData.ignoreMissingResxComments;\n\n // START options.localizedData.passthroughLocale\n if (this._options.localizedData.passthroughLocale) {\n const { usePassthroughLocale, passthroughLocaleName = 'passthrough' } =\n this._options.localizedData.passthroughLocale;\n if (usePassthroughLocale) {\n this._passthroughLocaleName = passthroughLocaleName;\n this._locales.add(passthroughLocaleName);\n }\n }\n // END options.localizedData.passthroughLocale\n\n // START options.localizedData.translatedStrings\n const { translatedStrings } = this._options.localizedData;\n this._resolvedTranslatedStringsFromOptions = {};\n if (translatedStrings) {\n for (const [localeName, locale] of Object.entries(translatedStrings)) {\n if (this._locales.has(localeName)) {\n errors.push(\n Error(\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._locales.add(localeName);\n this._resolvedLocalizedStrings.set(localeName, new Map<string, Map<string, string>>());\n this._resolvedTranslatedStringsFromOptions[localeName] = {};\n\n const locFilePathsInLocale: Set<string> = new Set<string>();\n\n for (const [locFilePath, locFileDataFromOptions] of Object.entries(locale)) {\n if (locale.hasOwnProperty(locFilePath)) {\n const normalizedLocFilePath: string = path.resolve(configuration.context!, locFilePath);\n\n if (locFilePathsInLocale.has(normalizedLocFilePath)) {\n errors.push(\n new Error(\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 locFilePathsInLocale.add(normalizedLocFilePath);\n\n const normalizedLocFileDataFromOptions: string | ILocaleFileData =\n typeof locFileDataFromOptions === 'string'\n ? path.resolve(configuration.context!, locFileDataFromOptions)\n : locFileDataFromOptions;\n\n this._resolvedTranslatedStringsFromOptions[localeName][normalizedLocFilePath] =\n normalizedLocFileDataFromOptions;\n }\n }\n }\n }\n // END options.localizedData.translatedStrings\n\n // START options.localizedData.defaultLocale\n if (this._options.localizedData.defaultLocale) {\n const { localeName, fillMissingTranslationStrings } = this._options.localizedData.defaultLocale;\n if (this._options.localizedData.defaultLocale.localeName) {\n if (this._locales.has(localeName)) {\n errors.push(new Error('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._locales.add(localeName);\n this._resolvedLocalizedStrings.set(localeName, new Map<string, Map<string, string>>());\n this._defaultLocale = localeName;\n this._fillMissingTranslationStrings = !!fillMissingTranslationStrings;\n } else {\n errors.push(new Error('Missing default locale name'));\n return { errors, warnings };\n }\n } else {\n errors.push(new Error('Missing default locale options.'));\n return { errors, warnings };\n }\n // END options.localizedData.defaultLocale\n\n // START options.localizedData.pseudoLocales\n if (this._options.localizedData.pseudolocales) {\n for (const [pseudolocaleName, pseudoLocaleOpts] of Object.entries(\n this._options.localizedData.pseudolocales\n )) {\n if (this._defaultLocale === pseudolocaleName) {\n errors.push(\n new Error(`A pseudolocale (${pseudolocaleName}) name is also the default locale name.`)\n );\n return { errors, warnings };\n }\n\n if (this._locales.has(pseudolocaleName)) {\n errors.push(\n new Error(\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._locales.add(pseudolocaleName);\n this._resolvedLocalizedStrings.set(pseudolocaleName, new Map<string, Map<string, string>>());\n }\n }\n // END options.localizedData.pseudoLocales\n\n // START options.localizedData.normalizeResxNewlines\n if (this._options.localizedData.normalizeResxNewlines) {\n switch (this._options.localizedData.normalizeResxNewlines) {\n case 'crlf': {\n this._resxNewlineNormalization = NewlineKind.CrLf;\n break;\n }\n\n case 'lf': {\n this._resxNewlineNormalization = NewlineKind.Lf;\n break;\n }\n\n default: {\n errors.push(\n new Error(\n `Unexpected value \"${this._options.localizedData.normalizeResxNewlines}\" for option ` +\n '\"localizedData.normalizeResxNewlines\"'\n )\n );\n break;\n }\n }\n }\n // END options.localizedData.normalizeResxNewlines\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 if (\n this._options.noStringsLocaleName === undefined ||\n this._options.noStringsLocaleName === null ||\n !ensureValidLocaleName(this._options.noStringsLocaleName)\n ) {\n this._noStringsLocaleName = 'none';\n } else {\n this._noStringsLocaleName = this._options.noStringsLocaleName;\n }\n // END options.noStringsLocaleName\n\n return { errors, warnings };\n }\n\n private _getPlaceholderString(): IStringPlaceholder {\n const suffix: string = (this._stringPlaceholderCounter++).toString();\n return {\n value: `${Constants.STRING_PLACEHOLDER_PREFIX}_\\\\_${Constants.STRING_PLACEHOLDER_LABEL}_${suffix}`,\n suffix: suffix\n };\n }\n\n private _chunkHasLocalizedModules(chunk: Webpack.compilation.Chunk): boolean {\n let chunkHasAnyLocModules: boolean | undefined = EntityMarker.getMark(chunk);\n if (chunkHasAnyLocModules === undefined) {\n chunkHasAnyLocModules = false;\n for (const module of chunk.getModules()) {\n if (EntityMarker.getMark(module)) {\n chunkHasAnyLocModules = true;\n break;\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 && chunk.hasRuntime()) {\n for (const asyncChunk of chunk.getAllAsyncChunks()) {\n if (this._chunkHasLocalizedModules(asyncChunk)) {\n chunkHasAnyLocModules = true;\n break;\n }\n }\n }\n\n EntityMarker.markEntity(chunk, chunkHasAnyLocModules);\n }\n\n return chunkHasAnyLocModules;\n }\n\n private _convertLocalizationFileToLocData(locFile: ILocalizationFile): ILocaleFileData {\n const locFileData: ILocaleFileData = {};\n for (const [stringName, locFileEntry] of Object.entries(locFile)) {\n locFileData[stringName] = locFileEntry.value;\n }\n\n return locFileData;\n }\n}\n"]}
1
+ {"version":3,"file":"LocalizationPlugin.js","sourceRoot":"","sources":["../src/LocalizationPlugin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,oEAAiF;AAEjF,iDAAmC;AACnC,2CAA6B;AAE7B,8EAK2C;AAE3C,qDAAkD;AAClD,+EAGuC;AAUvC,2DAAwD;AACxD,qDAA4G;AAuD5G,MAAM,WAAW,GAAW,cAAc,CAAC;AAE3C;;;;G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;QAED,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IAEO,iCAAiC,CAAC,OAA0B;QAClE,MAAM,WAAW,GAAoB,EAAE,CAAC;QACxC,KAAK,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACjE,WAAW,CAAC,UAAU,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC;QAC/C,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AAxwBD,gDAwwBC","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 { JsonFile, FileSystem, NewlineKind } from '@rushstack/node-core-library';\nimport type { ITerminal } from '@rushstack/terminal';\nimport * as Webpack from 'webpack';\nimport * as path from 'path';\nimport type * as Tapable from 'tapable';\nimport {\n getPseudolocalizer,\n type ILocalizationFile,\n parseLocFile,\n TypingsGenerator\n} from '@rushstack/localization-utilities';\n\nimport { Constants } from './utilities/Constants';\nimport {\n type IWebpackConfigurationUpdaterOptions,\n WebpackConfigurationUpdater\n} from './WebpackConfigurationUpdater';\nimport type {\n ILocalizationPluginOptions,\n ILocalizationStats,\n ILocaleFileData,\n ILocaleElementMap,\n ILocalizedStrings,\n IResolvedMissingTranslations\n} from './interfaces';\nimport type { ILocalizedWebpackChunk } from './webpackInterfaces';\nimport { EntityMarker } from './utilities/EntityMarker';\nimport { type IAsset, type IProcessAssetResult, AssetProcessor, PLACEHOLDER_REGEX } from './AssetProcessor';\n\n/**\n * @internal\n */\nexport interface IStringPlaceholder {\n value: string;\n suffix: string;\n}\n\n/**\n * @internal\n */\nexport interface IAddDefaultLocFileResult {\n /**\n * A list of paths to translation files that were loaded\n */\n additionalLoadedFilePaths: string[];\n\n errors: Error[];\n}\n\ninterface IExtendedMainTemplate {\n hooks: {\n assetPath: Tapable.SyncHook<string, IAssetPathOptions>;\n };\n}\n\ninterface IExtendedConfiguration extends Webpack.compilation.Compilation {\n options: Webpack.Configuration;\n}\n\ninterface IExtendedChunkGroup extends Webpack.compilation.ChunkGroup {\n getChildren(): Webpack.compilation.Chunk[];\n}\n\ninterface IExtendedChunk extends Webpack.compilation.Chunk {\n filenameTemplate: string;\n}\n\ninterface IAssetPathOptions {\n chunk: Webpack.compilation.Chunk;\n contentHashType: string;\n filename: string;\n}\n\n/**\n * @internal\n */\nexport interface IStringSerialNumberData {\n values: ILocaleElementMap;\n locFilePath: string;\n stringName: string;\n}\n\nconst PLUGIN_NAME: string = 'localization';\n\n/**\n * This plugin facilitates localization in webpack.\n *\n * @public\n */\nexport class LocalizationPlugin implements Webpack.Plugin {\n /**\n * @internal\n */\n public stringKeys: Map<string, IStringPlaceholder> = new Map<string, IStringPlaceholder>();\n\n private _options: ILocalizationPluginOptions;\n private _resolvedTranslatedStringsFromOptions!: ILocalizedStrings;\n private _globsToIgnore: string[] | undefined;\n private _stringPlaceholderCounter: number = 0;\n private _stringPlaceholderMap: Map<string, IStringSerialNumberData> = new Map<\n string,\n IStringSerialNumberData\n >();\n private _locales: Set<string> = new Set<string>();\n private _passthroughLocaleName!: string;\n private _defaultLocale!: string;\n private _noStringsLocaleName!: string;\n private _fillMissingTranslationStrings!: boolean;\n private _pseudolocalizers: Map<string, (str: string) => string> = new Map<\n string,\n (str: string) => string\n >();\n private _resxNewlineNormalization: NewlineKind | undefined;\n private _ignoreMissingResxComments: boolean | undefined;\n\n /**\n * The outermost map's keys are the locale names.\n * The middle map's keys are the resolved, file names.\n * The innermost map's keys are the string identifiers and its values are the string values.\n */\n private _resolvedLocalizedStrings: Map<string, Map<string, Map<string, string>>> = new Map<\n string,\n Map<string, Map<string, string>>\n >();\n\n public constructor(options: ILocalizationPluginOptions) {\n if (options.filesToIgnore) {\n throw new Error('The filesToIgnore option is no longer supported. Please use globsToIgnore instead.');\n }\n\n if (options.typingsOptions?.ignoreString) {\n throw new Error(\n 'The typingsOptions.ignoreString option is no longer supported. Please use the ignoreString ' +\n 'option directly on the constructor options object instead.'\n );\n }\n\n this._options = options;\n }\n\n public apply(compiler: Webpack.Compiler): void {\n const isWebpack4: boolean = !!compiler.hooks;\n\n if (!isWebpack4) {\n throw new Error(`The ${LocalizationPlugin.name} plugin requires Webpack 4`);\n }\n\n if (this._options.typingsOptions && compiler.context) {\n if (\n this._options.typingsOptions.generatedTsFolder &&\n !path.isAbsolute(this._options.typingsOptions.generatedTsFolder)\n ) {\n this._options.typingsOptions.generatedTsFolder = path.resolve(\n compiler.context,\n this._options.typingsOptions.generatedTsFolder\n );\n }\n\n if (\n this._options.typingsOptions.sourceRoot &&\n !path.isAbsolute(this._options.typingsOptions.sourceRoot)\n ) {\n this._options.typingsOptions.sourceRoot = path.resolve(\n compiler.context,\n this._options.typingsOptions.sourceRoot\n );\n }\n\n const secondaryGeneratedTsFolders: string[] | undefined =\n this._options.typingsOptions.secondaryGeneratedTsFolders;\n if (secondaryGeneratedTsFolders) {\n for (let i: number = 0; i < secondaryGeneratedTsFolders.length; i++) {\n const secondaryGeneratedTsFolder: string = secondaryGeneratedTsFolders[i];\n if (!path.isAbsolute(secondaryGeneratedTsFolder)) {\n secondaryGeneratedTsFolders[i] = path.resolve(compiler.context, secondaryGeneratedTsFolder);\n }\n }\n }\n }\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.options, isWebpackDevServer);\n\n let typingsPreprocessor: TypingsGenerator | undefined;\n if (this._options.typingsOptions) {\n typingsPreprocessor = new TypingsGenerator({\n srcFolder: this._options.typingsOptions.sourceRoot || compiler.context,\n generatedTsFolder: this._options.typingsOptions.generatedTsFolder,\n secondaryGeneratedTsFolders: this._options.typingsOptions.secondaryGeneratedTsFolders,\n exportAsDefault: this._options.typingsOptions.exportAsDefault,\n globsToIgnore: this._options.globsToIgnore,\n ignoreString: this._options.ignoreString,\n processComment: this._options.typingsOptions.processComment\n });\n } else {\n typingsPreprocessor = undefined;\n }\n\n const webpackConfigurationUpdaterOptions: IWebpackConfigurationUpdaterOptions = {\n pluginInstance: this,\n configuration: compiler.options,\n globsToIgnore: this._globsToIgnore,\n localeNameOrPlaceholder: Constants.LOCALE_NAME_PLACEHOLDER,\n resxNewlineNormalization: this._resxNewlineNormalization,\n ignoreMissingResxComments: this._ignoreMissingResxComments,\n ignoreString: this._options.ignoreString\n };\n\n if (errors.length > 0 || warnings.length > 0) {\n compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation: Webpack.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 WebpackConfigurationUpdater.amendWebpackConfigurationForInPlaceLocFiles(\n webpackConfigurationUpdaterOptions\n );\n return;\n }\n }\n\n if (isWebpackDevServer) {\n if (typingsPreprocessor) {\n compiler.hooks.afterEnvironment.tap(PLUGIN_NAME, () => typingsPreprocessor!.runWatcherAsync());\n\n if (!compiler.options.plugins) {\n compiler.options.plugins = [];\n }\n\n compiler.options.plugins.push(\n new Webpack.WatchIgnorePlugin([this._options.typingsOptions!.generatedTsFolder])\n );\n }\n\n WebpackConfigurationUpdater.amendWebpackConfigurationForInPlaceLocFiles(\n webpackConfigurationUpdaterOptions\n );\n } else {\n if (typingsPreprocessor) {\n compiler.hooks.beforeRun.tapPromise(\n PLUGIN_NAME,\n async () => await typingsPreprocessor!.generateTypingsAsync()\n );\n }\n\n WebpackConfigurationUpdater.amendWebpackConfigurationForMultiLocale(webpackConfigurationUpdaterOptions);\n\n if (errors.length === 0) {\n compiler.hooks.thisCompilation.tap(\n PLUGIN_NAME,\n (untypedCompilation: Webpack.compilation.Compilation) => {\n const compilation: IExtendedConfiguration = untypedCompilation as IExtendedConfiguration;\n (compilation.mainTemplate as unknown as IExtendedMainTemplate).hooks.assetPath.tap(\n PLUGIN_NAME,\n (assetPath: string, options: IAssetPathOptions) => {\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 as string).match(/^\\\" \\+/)) {\n return assetPath.replace(\n Constants.LOCALE_FILENAME_TOKEN_REGEX,\n `\" + ${Constants.JSONP_PLACEHOLDER} + \"`\n );\n } else {\n return assetPath.replace(\n Constants.LOCALE_FILENAME_TOKEN_REGEX,\n Constants.LOCALE_NAME_PLACEHOLDER\n );\n }\n } else if (assetPath.match(Constants.NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN_REGEX)) {\n // Replace the placeholder with the [locale] token for sourcemaps\n const deLocalizedFilename: string = options.filename.replace(\n PLACEHOLDER_REGEX,\n Constants.LOCALE_FILENAME_TOKEN\n );\n return assetPath.replace(\n Constants.NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN_REGEX,\n deLocalizedFilename\n );\n } else {\n return assetPath;\n }\n }\n );\n\n compilation.hooks.optimizeChunks.tap(\n PLUGIN_NAME,\n (\n untypedChunks: Webpack.compilation.Chunk[],\n untypedChunkGroups: Webpack.compilation.ChunkGroup[]\n ) => {\n const chunks: IExtendedChunk[] = untypedChunks as IExtendedChunk[];\n const chunkGroups: IExtendedChunkGroup[] = untypedChunkGroups as IExtendedChunkGroup[];\n\n let chunksHaveAnyChildren: boolean = false;\n for (const chunkGroup of chunkGroups) {\n const children: Webpack.compilation.Chunk[] = chunkGroup.getChildren();\n if (children.length > 0) {\n chunksHaveAnyChildren = true;\n break;\n }\n }\n\n if (\n chunksHaveAnyChildren &&\n (!compilation.options.output ||\n !compilation.options.output.chunkFilename ||\n compilation.options.output.chunkFilename.indexOf(Constants.LOCALE_FILENAME_TOKEN) === -1)\n ) {\n compilation.errors.push(\n new Error(\n 'The configuration.output.chunkFilename property must be provided and must include ' +\n `the ${Constants.LOCALE_FILENAME_TOKEN} placeholder`\n )\n );\n\n return;\n }\n\n for (const chunk of chunks) {\n // See if the chunk contains any localized modules or loads any localized chunks\n const localizedChunk: boolean = this._chunkHasLocalizedModules(chunk);\n\n // Change the chunk's name to include either the locale name or the locale name for chunks without strings\n const replacementValue: string = localizedChunk\n ? Constants.LOCALE_NAME_PLACEHOLDER\n : this._noStringsLocaleName;\n if (chunk.hasRuntime()) {\n chunk.filenameTemplate = (compilation.options.output!.filename as string).replace(\n Constants.LOCALE_FILENAME_TOKEN_REGEX,\n replacementValue\n );\n } else {\n chunk.filenameTemplate = compilation.options.output!.chunkFilename!.replace(\n Constants.LOCALE_FILENAME_TOKEN_REGEX,\n replacementValue\n );\n }\n }\n }\n );\n }\n );\n\n compiler.hooks.emit.tap(PLUGIN_NAME, (compilation: Webpack.compilation.Compilation) => {\n const localizationStats: ILocalizationStats = {\n entrypoints: {},\n namedChunkGroups: {}\n };\n\n const alreadyProcessedAssets: Set<string> = new Set<string>();\n const hotUpdateRegex: RegExp = /\\.hot-update\\.js$/;\n\n for (const untypedChunk of compilation.chunks) {\n const chunk: ILocalizedWebpackChunk = untypedChunk;\n const chunkFilesSet: Set<string> = new Set(chunk.files);\n function processChunkJsFile(callback: (chunkFilename: string) => void): void {\n let alreadyProcessedAFileInThisChunk: boolean = false;\n for (const chunkFilename of chunk.files) {\n if (\n chunkFilename.endsWith('.js') && // Ensure this is a JS file\n !hotUpdateRegex.test(chunkFilename) && // Ensure this is not a webpack hot update\n !alreadyProcessedAssets.has(chunkFilename) // Ensure this isn't a vendor chunk we've already processed\n ) {\n if (alreadyProcessedAFileInThisChunk) {\n throw new Error(\n `Found more than one JS file in chunk \"${chunk.name}\". This is not expected.`\n );\n }\n\n alreadyProcessedAFileInThisChunk = true;\n alreadyProcessedAssets.add(chunkFilename);\n callback(chunkFilename);\n }\n }\n }\n\n if (this._chunkHasLocalizedModules(chunk)) {\n processChunkJsFile((chunkFilename) => {\n if (chunkFilename.indexOf(Constants.LOCALE_NAME_PLACEHOLDER) === -1) {\n throw new Error(\n `Asset ${chunkFilename} is expected to be localized, but is missing a locale placeholder`\n );\n }\n\n const asset: IAsset = compilation.assets[chunkFilename];\n\n const resultingAssets: Map<string, IProcessAssetResult> =\n AssetProcessor.processLocalizedAsset({\n plugin: this,\n compilation,\n assetName: chunkFilename,\n asset,\n chunk,\n chunkHasLocalizedModules: this._chunkHasLocalizedModules.bind(this),\n locales: this._locales,\n noStringsLocaleName: this._noStringsLocaleName,\n fillMissingTranslationStrings: this._fillMissingTranslationStrings,\n defaultLocale: this._defaultLocale\n });\n\n // Delete the existing asset because it's been renamed\n delete compilation.assets[chunkFilename];\n chunkFilesSet.delete(chunkFilename);\n\n const localizedChunkAssets: ILocaleElementMap = {};\n for (const [locale, newAsset] of resultingAssets) {\n compilation.assets[newAsset.filename] = newAsset.asset;\n localizedChunkAssets[locale] = newAsset.filename;\n chunkFilesSet.add(newAsset.filename);\n }\n\n if (chunk.hasRuntime()) {\n // This is an entrypoint\n localizationStats.entrypoints[chunk.name] = {\n localizedAssets: localizedChunkAssets\n };\n } else {\n // This is a secondary chunk\n if (chunk.name) {\n localizationStats.namedChunkGroups[chunk.name] = {\n localizedAssets: localizedChunkAssets\n };\n }\n }\n\n chunk.localizedFiles = localizedChunkAssets;\n });\n } else {\n processChunkJsFile((chunkFilename) => {\n const asset: IAsset = compilation.assets[chunkFilename];\n\n const resultingAsset: IProcessAssetResult = AssetProcessor.processNonLocalizedAsset({\n plugin: this,\n compilation,\n assetName: chunkFilename,\n asset,\n chunk,\n noStringsLocaleName: this._noStringsLocaleName,\n chunkHasLocalizedModules: this._chunkHasLocalizedModules.bind(this)\n });\n\n // Delete the existing asset because it's been renamed\n delete compilation.assets[chunkFilename];\n chunkFilesSet.delete(chunkFilename);\n\n compilation.assets[resultingAsset.filename] = resultingAsset.asset;\n chunkFilesSet.add(resultingAsset.filename);\n });\n }\n\n chunk.files = Array.from(chunkFilesSet);\n }\n\n if (this._options.localizationStats) {\n if (this._options.localizationStats.dropPath) {\n const resolvedLocalizationStatsDropPath: string = path.resolve(\n compiler.outputPath,\n this._options.localizationStats.dropPath\n );\n JsonFile.save(localizationStats, resolvedLocalizationStatsDropPath, {\n ensureFolderExists: true\n });\n }\n\n if (this._options.localizationStats.callback) {\n try {\n this._options.localizationStats.callback(localizationStats);\n } catch (e) {\n /* swallow errors from the callback */\n }\n }\n }\n });\n }\n }\n }\n\n /**\n * @internal\n *\n * @returns\n */\n public addDefaultLocFile(\n terminal: ITerminal,\n localizedResourcePath: string,\n localizedResourceData: ILocalizationFile\n ): IAddDefaultLocFileResult {\n const additionalLoadedFilePaths: string[] = [];\n const errors: Error[] = [];\n\n const locFileData: ILocaleFileData = this._convertLocalizationFileToLocData(localizedResourceData);\n this._addLocFile(this._defaultLocale, localizedResourcePath, locFileData);\n\n const normalizeLocalizedData: (localizedData: ILocaleFileData | string) => ILocaleFileData = (\n localizedData\n ) => {\n if (typeof localizedData === 'string') {\n additionalLoadedFilePaths.push(localizedData);\n const localizationFile: ILocalizationFile = parseLocFile({\n filePath: localizedData,\n content: FileSystem.readFile(localizedData),\n terminal: terminal,\n resxNewlineNormalization: this._resxNewlineNormalization,\n ignoreMissingResxComments: this._ignoreMissingResxComments\n });\n\n return this._convertLocalizationFileToLocData(localizationFile);\n } else {\n return localizedData;\n }\n };\n\n const missingLocales: string[] = [];\n for (const [translatedLocaleName, translatedStrings] of Object.entries(\n this._resolvedTranslatedStringsFromOptions\n )) {\n const translatedLocFileFromOptions: ILocaleFileData | string | undefined =\n translatedStrings[localizedResourcePath];\n if (!translatedLocFileFromOptions) {\n missingLocales.push(translatedLocaleName);\n } else {\n const translatedLocFileData: ILocaleFileData = normalizeLocalizedData(translatedLocFileFromOptions);\n this._addLocFile(translatedLocaleName, localizedResourcePath, translatedLocFileData);\n }\n }\n\n if (missingLocales.length > 0 && this._options.localizedData.resolveMissingTranslatedStrings) {\n let resolvedTranslatedData: IResolvedMissingTranslations | undefined = undefined;\n try {\n resolvedTranslatedData = this._options.localizedData.resolveMissingTranslatedStrings(\n missingLocales,\n localizedResourcePath\n );\n } catch (e) {\n errors.push(e as Error);\n }\n\n if (resolvedTranslatedData) {\n for (const [resolvedLocaleName, resolvedLocaleData] of Object.entries(resolvedTranslatedData)) {\n if (resolvedLocaleData) {\n const translatedLocFileData: ILocaleFileData = normalizeLocalizedData(resolvedLocaleData);\n this._addLocFile(resolvedLocaleName, localizedResourcePath, translatedLocFileData);\n }\n }\n }\n }\n\n this._pseudolocalizers.forEach((pseudolocalizer: (str: string) => string, pseudolocaleName: string) => {\n const pseudolocFileData: ILocaleFileData = {};\n\n for (const [stringName, stringValue] of Object.entries(locFileData)) {\n pseudolocFileData[stringName] = pseudolocalizer(stringValue);\n }\n\n this._addLocFile(pseudolocaleName, localizedResourcePath, pseudolocFileData);\n });\n\n return { additionalLoadedFilePaths, errors };\n }\n\n /**\n * @internal\n */\n public getDataForSerialNumber(serialNumber: string): IStringSerialNumberData | undefined {\n return this._stringPlaceholderMap.get(serialNumber);\n }\n\n private _addLocFile(\n localeName: string,\n localizedFilePath: string,\n localizedFileData: ILocaleFileData\n ): void {\n const filesMap: Map<string, Map<string, string>> = this._resolvedLocalizedStrings.get(localeName)!;\n\n const stringsMap: Map<string, string> = new Map<string, string>();\n filesMap.set(localizedFilePath, stringsMap);\n\n for (const [stringName, stringValue] of Object.entries(localizedFileData)) {\n const stringKey: string = `${localizedFilePath}?${stringName}`;\n if (!this.stringKeys.has(stringKey)) {\n const placeholder: IStringPlaceholder = this._getPlaceholderString();\n this.stringKeys.set(stringKey, placeholder);\n }\n\n const placeholder: IStringPlaceholder = this.stringKeys.get(stringKey)!;\n if (!this._stringPlaceholderMap.has(placeholder.suffix)) {\n this._stringPlaceholderMap.set(placeholder.suffix, {\n values: {\n [this._passthroughLocaleName]: stringName\n },\n locFilePath: localizedFilePath,\n stringName: stringName\n });\n }\n\n this._stringPlaceholderMap.get(placeholder.suffix)!.values[localeName] = stringValue;\n\n stringsMap.set(stringName, stringValue);\n }\n }\n\n private _initializeAndValidateOptions(\n configuration: Webpack.Configuration,\n isWebpackDevServer: boolean\n ): { errors: Error[]; warnings: Error[] } {\n const errors: Error[] = [];\n const warnings: Error[] = [];\n\n function ensureValidLocaleName(localeName: string): boolean {\n const LOCALE_NAME_REGEX: RegExp = /[a-z-]/i;\n if (!localeName.match(LOCALE_NAME_REGEX)) {\n errors.push(\n new Error(`Invalid locale name: ${localeName}. Locale names may only contain letters and hyphens.`)\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 Error(\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 // eslint-disable-next-line no-lone-blocks\n {\n this._globsToIgnore = this._options.globsToIgnore;\n }\n // END misc options\n\n // START options.localizedData\n if (this._options.localizedData) {\n this._ignoreMissingResxComments = this._options.localizedData.ignoreMissingResxComments;\n\n // START options.localizedData.passthroughLocale\n if (this._options.localizedData.passthroughLocale) {\n const { usePassthroughLocale, passthroughLocaleName = 'passthrough' } =\n this._options.localizedData.passthroughLocale;\n if (usePassthroughLocale) {\n this._passthroughLocaleName = passthroughLocaleName;\n this._locales.add(passthroughLocaleName);\n }\n }\n // END options.localizedData.passthroughLocale\n\n // START options.localizedData.translatedStrings\n const { translatedStrings } = this._options.localizedData;\n this._resolvedTranslatedStringsFromOptions = {};\n if (translatedStrings) {\n for (const [localeName, locale] of Object.entries(translatedStrings)) {\n if (this._locales.has(localeName)) {\n errors.push(\n Error(\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._locales.add(localeName);\n this._resolvedLocalizedStrings.set(localeName, new Map<string, Map<string, string>>());\n this._resolvedTranslatedStringsFromOptions[localeName] = {};\n\n const locFilePathsInLocale: Set<string> = new Set<string>();\n\n for (const [locFilePath, locFileDataFromOptions] of Object.entries(locale)) {\n if (locale.hasOwnProperty(locFilePath)) {\n const normalizedLocFilePath: string = path.resolve(configuration.context!, locFilePath);\n\n if (locFilePathsInLocale.has(normalizedLocFilePath)) {\n errors.push(\n new Error(\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 locFilePathsInLocale.add(normalizedLocFilePath);\n\n const normalizedLocFileDataFromOptions: string | ILocaleFileData =\n typeof locFileDataFromOptions === 'string'\n ? path.resolve(configuration.context!, locFileDataFromOptions)\n : locFileDataFromOptions;\n\n this._resolvedTranslatedStringsFromOptions[localeName][normalizedLocFilePath] =\n normalizedLocFileDataFromOptions;\n }\n }\n }\n }\n // END options.localizedData.translatedStrings\n\n // START options.localizedData.defaultLocale\n if (this._options.localizedData.defaultLocale) {\n const { localeName, fillMissingTranslationStrings } = this._options.localizedData.defaultLocale;\n if (this._options.localizedData.defaultLocale.localeName) {\n if (this._locales.has(localeName)) {\n errors.push(new Error('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._locales.add(localeName);\n this._resolvedLocalizedStrings.set(localeName, new Map<string, Map<string, string>>());\n this._defaultLocale = localeName;\n this._fillMissingTranslationStrings = !!fillMissingTranslationStrings;\n } else {\n errors.push(new Error('Missing default locale name'));\n return { errors, warnings };\n }\n } else {\n errors.push(new Error('Missing default locale options.'));\n return { errors, warnings };\n }\n // END options.localizedData.defaultLocale\n\n // START options.localizedData.pseudoLocales\n if (this._options.localizedData.pseudolocales) {\n for (const [pseudolocaleName, pseudoLocaleOpts] of Object.entries(\n this._options.localizedData.pseudolocales\n )) {\n if (this._defaultLocale === pseudolocaleName) {\n errors.push(\n new Error(`A pseudolocale (${pseudolocaleName}) name is also the default locale name.`)\n );\n return { errors, warnings };\n }\n\n if (this._locales.has(pseudolocaleName)) {\n errors.push(\n new Error(\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._locales.add(pseudolocaleName);\n this._resolvedLocalizedStrings.set(pseudolocaleName, new Map<string, Map<string, string>>());\n }\n }\n // END options.localizedData.pseudoLocales\n\n // START options.localizedData.normalizeResxNewlines\n if (this._options.localizedData.normalizeResxNewlines) {\n switch (this._options.localizedData.normalizeResxNewlines) {\n case 'crlf': {\n this._resxNewlineNormalization = NewlineKind.CrLf;\n break;\n }\n\n case 'lf': {\n this._resxNewlineNormalization = NewlineKind.Lf;\n break;\n }\n\n default: {\n errors.push(\n new Error(\n `Unexpected value \"${this._options.localizedData.normalizeResxNewlines}\" for option ` +\n '\"localizedData.normalizeResxNewlines\"'\n )\n );\n break;\n }\n }\n }\n // END options.localizedData.normalizeResxNewlines\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 if (\n this._options.noStringsLocaleName === undefined ||\n this._options.noStringsLocaleName === null ||\n !ensureValidLocaleName(this._options.noStringsLocaleName)\n ) {\n this._noStringsLocaleName = 'none';\n } else {\n this._noStringsLocaleName = this._options.noStringsLocaleName;\n }\n // END options.noStringsLocaleName\n\n return { errors, warnings };\n }\n\n private _getPlaceholderString(): IStringPlaceholder {\n const suffix: string = (this._stringPlaceholderCounter++).toString();\n return {\n value: `${Constants.STRING_PLACEHOLDER_PREFIX}_\\\\_${Constants.STRING_PLACEHOLDER_LABEL}_${suffix}`,\n suffix: suffix\n };\n }\n\n private _chunkHasLocalizedModules(chunk: Webpack.compilation.Chunk): boolean {\n let chunkHasAnyLocModules: boolean | undefined = EntityMarker.getMark(chunk);\n if (chunkHasAnyLocModules === undefined) {\n chunkHasAnyLocModules = false;\n for (const module of chunk.getModules()) {\n if (EntityMarker.getMark(module)) {\n chunkHasAnyLocModules = true;\n break;\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 && chunk.hasRuntime()) {\n for (const asyncChunk of chunk.getAllAsyncChunks()) {\n if (this._chunkHasLocalizedModules(asyncChunk)) {\n chunkHasAnyLocModules = true;\n break;\n }\n }\n }\n\n EntityMarker.markEntity(chunk, chunkHasAnyLocModules);\n }\n\n return chunkHasAnyLocModules;\n }\n\n private _convertLocalizationFileToLocData(locFile: ILocalizationFile): ILocaleFileData {\n const locFileData: ILocaleFileData = {};\n for (const [stringName, locFileEntry] of Object.entries(locFile)) {\n locFileData[stringName] = locFileEntry.value;\n }\n\n return locFileData;\n }\n}\n"]}
@@ -17,13 +17,23 @@ 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
  var __importDefault = (this && this.__importDefault) || function (mod) {
28
38
  return (mod && mod.__esModule) ? mod : { "default": mod };
29
39
  };
@@ -1 +1 @@
1
- {"version":3,"file":"WebpackConfigurationUpdater.js","sourceRoot":"","sources":["../src/WebpackConfigurationUpdater.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,0DAAkC;AAClC,2CAA6B;AAG7B,oEAAsE;AAGtE,qDAAkD;AAelD,MAAM,gBAAgB,GAAW,IAAI,MAAM,CAAC,wBAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;AAEzE,MAAa,2BAA2B;IAC/B,MAAM,CAAC,uCAAuC,CAAC,OAA4C;QAChG,MAAM,MAAM,GAAW,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;QAC1E,MAAM,aAAa,GAAsB;YACvC,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,wBAAwB,EAAE,OAAO,CAAC,wBAAwB;YAC1D,yBAAyB,EAAE,OAAO,CAAC,yBAAyB;YAC5D,YAAY,EAAE,OAAO,CAAC,YAAY;SACnC,CAAC;QAEF,2BAA2B,CAAC,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;QAEnF,2BAA2B,CAAC,uCAAuC,CAAC,OAAO,CAAC,CAAC;QAE7E,2BAA2B,CAAC,2BAA2B,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACjF,CAAC;IAEM,MAAM,CAAC,2CAA2C,CACvD,OAA4C;QAE5C,MAAM,MAAM,GAAW,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,yBAAyB,CAAC,CAAC;QACrF,MAAM,aAAa,GAAuB;YACxC,wBAAwB,EAAE,OAAO,CAAC,wBA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CAAC;QAED,IAAI,aAAa,CAAC,MAAM,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;YACzD,aAAa,CAAC,MAAM,CAAC,iBAAiB,GAAG,aAAa,CAAC,MAAM,CAAC,iBAAiB,CAAC,OAAO,CACrF,gBAAgB,EAChB,qBAAS,CAAC,mCAAmC,CAC9C,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAhID,kEAgIC","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 minimatch from 'minimatch';\nimport * as path from 'path';\nimport type * as Webpack from 'webpack';\nimport type * as SetPublicPathPluginPackageType from '@rushstack/set-webpack-public-path-plugin';\nimport { type NewlineKind, Text } from '@rushstack/node-core-library';\nimport type { IgnoreStringFunction } from '@rushstack/localization-utilities';\n\nimport { Constants } from './utilities/Constants';\nimport type { LocalizationPlugin } from './LocalizationPlugin';\nimport type { ILocLoaderOptions } from './loaders/LocLoader';\nimport type { IBaseLoaderOptions } from './loaders/LoaderFactory';\n\nexport interface IWebpackConfigurationUpdaterOptions {\n pluginInstance: LocalizationPlugin;\n configuration: Webpack.Configuration;\n globsToIgnore: string[] | undefined;\n localeNameOrPlaceholder: string;\n resxNewlineNormalization: NewlineKind | undefined;\n ignoreMissingResxComments: boolean | undefined;\n ignoreString: IgnoreStringFunction | undefined;\n}\n\nconst FILE_TOKEN_REGEX: RegExp = new RegExp(Text.escapeRegExp('[file]'));\n\nexport class WebpackConfigurationUpdater {\n public static amendWebpackConfigurationForMultiLocale(options: IWebpackConfigurationUpdaterOptions): void {\n const loader: string = path.resolve(__dirname, 'loaders', 'LocLoader.js');\n const loaderOptions: ILocLoaderOptions = {\n pluginInstance: options.pluginInstance,\n resxNewlineNormalization: options.resxNewlineNormalization,\n ignoreMissingResxComments: options.ignoreMissingResxComments,\n ignoreString: options.ignoreString\n };\n\n WebpackConfigurationUpdater._addLoadersForLocFiles(options, loader, loaderOptions);\n\n WebpackConfigurationUpdater._tryUpdateLocaleTokenInPublicPathPlugin(options);\n\n WebpackConfigurationUpdater._tryUpdateSourceMapFilename(options.configuration);\n }\n\n public static amendWebpackConfigurationForInPlaceLocFiles(\n options: IWebpackConfigurationUpdaterOptions\n ): void {\n const loader: string = path.resolve(__dirname, 'loaders', 'InPlaceLocFileLoader.js');\n const loaderOptions: IBaseLoaderOptions = {\n resxNewlineNormalization: options.resxNewlineNormalization,\n ignoreMissingResxComments: options.ignoreMissingResxComments,\n ignoreString: options.ignoreString\n };\n\n WebpackConfigurationUpdater._addRulesToConfiguration(options.configuration, [\n {\n test: Constants.RESOURCE_FILE_NAME_REGEXP,\n use: [\n {\n loader: loader,\n options: loaderOptions\n }\n ],\n type: 'json',\n sideEffects: false\n }\n ]);\n }\n\n private static _tryUpdateLocaleTokenInPublicPathPlugin(options: IWebpackConfigurationUpdaterOptions): void {\n let setPublicPathPlugin: typeof SetPublicPathPluginPackageType.SetPublicPathPlugin | undefined;\n try {\n const pluginPackage: typeof SetPublicPathPluginPackageType = require('@rushstack/set-webpack-public-path-plugin');\n setPublicPathPlugin = pluginPackage.SetPublicPathPlugin;\n } catch (e) {\n // public path plugin isn't present - ignore\n }\n\n if (setPublicPathPlugin && options.configuration.plugins) {\n for (const plugin of options.configuration.plugins) {\n if (plugin instanceof setPublicPathPlugin) {\n if (\n plugin.options &&\n plugin.options.scriptName &&\n plugin.options.scriptName.isTokenized &&\n plugin.options.scriptName.name\n ) {\n plugin.options.scriptName.name = plugin.options.scriptName.name.replace(\n /\\[locale\\]/g,\n options.localeNameOrPlaceholder\n );\n }\n }\n }\n }\n }\n\n private static _addLoadersForLocFiles(\n options: IWebpackConfigurationUpdaterOptions,\n loader: string,\n loaderOptions: IBaseLoaderOptions\n ): void {\n const { globsToIgnore, configuration } = options;\n const rules: Webpack.RuleSetCondition =\n globsToIgnore && globsToIgnore.length > 0\n ? {\n include: Constants.RESOURCE_FILE_NAME_REGEXP,\n exclude: (filePath: string): boolean =>\n globsToIgnore.some((glob: string): boolean => minimatch(filePath, glob))\n }\n : Constants.RESOURCE_FILE_NAME_REGEXP;\n WebpackConfigurationUpdater._addRulesToConfiguration(configuration, [\n {\n test: rules,\n use: [\n {\n loader: loader,\n options: loaderOptions\n }\n ],\n type: 'json',\n sideEffects: false\n }\n ]);\n }\n\n private static _addRulesToConfiguration(\n configuration: Webpack.Configuration,\n rules: Webpack.RuleSetRule[]\n ): void {\n if (!configuration.module) {\n configuration.module = {\n rules: []\n };\n }\n\n if (!configuration.module.rules) {\n configuration.module.rules = [];\n }\n\n configuration.module.rules.push(...rules);\n }\n\n private static _tryUpdateSourceMapFilename(configuration: Webpack.Configuration): void {\n if (!configuration.output) {\n configuration.output = {}; // This should never happen\n }\n\n if (configuration.output.sourceMapFilename !== undefined) {\n configuration.output.sourceMapFilename = configuration.output.sourceMapFilename.replace(\n FILE_TOKEN_REGEX,\n Constants.NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN\n );\n }\n }\n}\n"]}
1
+ {"version":3,"file":"WebpackConfigurationUpdater.js","sourceRoot":"","sources":["../src/WebpackConfigurationUpdater.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,0DAAkC;AAClC,2CAA6B;AAG7B,oEAAsE;AAGtE,qDAAkD;AAelD,MAAM,gBAAgB,GAAW,IAAI,MAAM,CAAC,wBAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;AAEzE,MAAa,2BAA2B;IAC/B,MAAM,CAAC,uCAAuC,CAAC,OAA4C;QAChG,MAAM,MAAM,GAAW,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;QAC1E,MAAM,aAAa,GAAsB;YACvC,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,wBAAwB,EAAE,OAAO,CAAC,wBAAwB;YAC1D,yBAAyB,EAAE,OAAO,CAAC,yBAA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AE,CAAC;YAC1B,aAAa,CAAC,MAAM,GAAG;gBACrB,KAAK,EAAE,EAAE;aACV,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAChC,aAAa,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC;QAClC,CAAC;QAED,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;IAC5C,CAAC;IAEO,MAAM,CAAC,2BAA2B,CAAC,aAAoC;QAC7E,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;YAC1B,aAAa,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,2BAA2B;QACxD,CAAC;QAED,IAAI,aAAa,CAAC,MAAM,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;YACzD,aAAa,CAAC,MAAM,CAAC,iBAAiB,GAAG,aAAa,CAAC,MAAM,CAAC,iBAAiB,CAAC,OAAO,CACrF,gBAAgB,EAChB,qBAAS,CAAC,mCAAmC,CAC9C,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAhID,kEAgIC","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 minimatch from 'minimatch';\nimport * as path from 'path';\nimport type * as Webpack from 'webpack';\nimport type * as SetPublicPathPluginPackageType from '@rushstack/set-webpack-public-path-plugin';\nimport { type NewlineKind, Text } from '@rushstack/node-core-library';\nimport type { IgnoreStringFunction } from '@rushstack/localization-utilities';\n\nimport { Constants } from './utilities/Constants';\nimport type { LocalizationPlugin } from './LocalizationPlugin';\nimport type { ILocLoaderOptions } from './loaders/LocLoader';\nimport type { IBaseLoaderOptions } from './loaders/LoaderFactory';\n\nexport interface IWebpackConfigurationUpdaterOptions {\n pluginInstance: LocalizationPlugin;\n configuration: Webpack.Configuration;\n globsToIgnore: string[] | undefined;\n localeNameOrPlaceholder: string;\n resxNewlineNormalization: NewlineKind | undefined;\n ignoreMissingResxComments: boolean | undefined;\n ignoreString: IgnoreStringFunction | undefined;\n}\n\nconst FILE_TOKEN_REGEX: RegExp = new RegExp(Text.escapeRegExp('[file]'));\n\nexport class WebpackConfigurationUpdater {\n public static amendWebpackConfigurationForMultiLocale(options: IWebpackConfigurationUpdaterOptions): void {\n const loader: string = path.resolve(__dirname, 'loaders', 'LocLoader.js');\n const loaderOptions: ILocLoaderOptions = {\n pluginInstance: options.pluginInstance,\n resxNewlineNormalization: options.resxNewlineNormalization,\n ignoreMissingResxComments: options.ignoreMissingResxComments,\n ignoreString: options.ignoreString\n };\n\n WebpackConfigurationUpdater._addLoadersForLocFiles(options, loader, loaderOptions);\n\n WebpackConfigurationUpdater._tryUpdateLocaleTokenInPublicPathPlugin(options);\n\n WebpackConfigurationUpdater._tryUpdateSourceMapFilename(options.configuration);\n }\n\n public static amendWebpackConfigurationForInPlaceLocFiles(\n options: IWebpackConfigurationUpdaterOptions\n ): void {\n const loader: string = path.resolve(__dirname, 'loaders', 'InPlaceLocFileLoader.js');\n const loaderOptions: IBaseLoaderOptions = {\n resxNewlineNormalization: options.resxNewlineNormalization,\n ignoreMissingResxComments: options.ignoreMissingResxComments,\n ignoreString: options.ignoreString\n };\n\n WebpackConfigurationUpdater._addRulesToConfiguration(options.configuration, [\n {\n test: Constants.RESOURCE_FILE_NAME_REGEXP,\n use: [\n {\n loader: loader,\n options: loaderOptions\n }\n ],\n type: 'json',\n sideEffects: false\n }\n ]);\n }\n\n private static _tryUpdateLocaleTokenInPublicPathPlugin(options: IWebpackConfigurationUpdaterOptions): void {\n let setPublicPathPlugin: typeof SetPublicPathPluginPackageType.SetPublicPathPlugin | undefined;\n try {\n const pluginPackage: typeof SetPublicPathPluginPackageType = require('@rushstack/set-webpack-public-path-plugin');\n setPublicPathPlugin = pluginPackage.SetPublicPathPlugin;\n } catch (e) {\n // public path plugin isn't present - ignore\n }\n\n if (setPublicPathPlugin && options.configuration.plugins) {\n for (const plugin of options.configuration.plugins) {\n if (plugin instanceof setPublicPathPlugin) {\n if (\n plugin.options &&\n plugin.options.scriptName &&\n plugin.options.scriptName.isTokenized &&\n plugin.options.scriptName.name\n ) {\n plugin.options.scriptName.name = plugin.options.scriptName.name.replace(\n /\\[locale\\]/g,\n options.localeNameOrPlaceholder\n );\n }\n }\n }\n }\n }\n\n private static _addLoadersForLocFiles(\n options: IWebpackConfigurationUpdaterOptions,\n loader: string,\n loaderOptions: IBaseLoaderOptions\n ): void {\n const { globsToIgnore, configuration } = options;\n const rules: Webpack.RuleSetCondition =\n globsToIgnore && globsToIgnore.length > 0\n ? {\n include: Constants.RESOURCE_FILE_NAME_REGEXP,\n exclude: (filePath: string): boolean =>\n globsToIgnore.some((glob: string): boolean => minimatch(filePath, glob))\n }\n : Constants.RESOURCE_FILE_NAME_REGEXP;\n WebpackConfigurationUpdater._addRulesToConfiguration(configuration, [\n {\n test: rules,\n use: [\n {\n loader: loader,\n options: loaderOptions\n }\n ],\n type: 'json',\n sideEffects: false\n }\n ]);\n }\n\n private static _addRulesToConfiguration(\n configuration: Webpack.Configuration,\n rules: Webpack.RuleSetRule[]\n ): void {\n if (!configuration.module) {\n configuration.module = {\n rules: []\n };\n }\n\n if (!configuration.module.rules) {\n configuration.module.rules = [];\n }\n\n configuration.module.rules.push(...rules);\n }\n\n private static _tryUpdateSourceMapFilename(configuration: Webpack.Configuration): void {\n if (!configuration.output) {\n configuration.output = {}; // This should never happen\n }\n\n if (configuration.output.sourceMapFilename !== undefined) {\n configuration.output.sourceMapFilename = configuration.output.sourceMapFilename.replace(\n FILE_TOKEN_REGEX,\n Constants.NO_LOCALE_SOURCE_MAP_FILENAME_TOKEN\n );\n }\n }\n}\n"]}
@@ -7,7 +7,12 @@ const localization_utilities_1 = require("@rushstack/localization-utilities");
7
7
  const LoaderFactory_1 = require("./LoaderFactory");
8
8
  const LoaderTerminalProvider_1 = require("../utilities/LoaderTerminalProvider");
9
9
  exports.default = (0, LoaderFactory_1.loaderFactory)(function (locFilePath, content, options) {
10
- const locFileData = (0, localization_utilities_1.parseLocFile)(Object.assign(Object.assign({}, options), { content, filePath: locFilePath, terminal: new terminal_1.Terminal(LoaderTerminalProvider_1.LoaderTerminalProvider.getTerminalProviderForLoader(this)) }));
10
+ const locFileData = (0, localization_utilities_1.parseLocFile)({
11
+ ...options,
12
+ content,
13
+ filePath: locFilePath,
14
+ terminal: new terminal_1.Terminal(LoaderTerminalProvider_1.LoaderTerminalProvider.getTerminalProviderForLoader(this))
15
+ });
11
16
  const resultObject = {};
12
17
  for (const [stringName, stringValue] of Object.entries(locFileData)) {
13
18
  resultObject[stringName] = stringValue.value;
@@ -1 +1 @@
1
- {"version":3,"file":"InPlaceLocFileLoader.js","sourceRoot":"","sources":["../../src/loaders/InPlaceLocFileLoader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAG3D,kDAA+C;AAC/C,8EAAyF;AAEzF,mDAAyE;AACzE,gFAA6E;AAE7E,kBAAe,IAAA,6BAAa,EAAC,UAE3B,WAAmB,EACnB,OAAe,EACf,OAA2B;IAE3B,MAAM,WAAW,GAAsB,IAAA,qCAAY,kCAC9C,OAAO,KACV,OAAO,EACP,QAAQ,EAAE,WAAW,EACrB,QAAQ,EAAE,IAAI,mBAAQ,CAAC,+CAAsB,CAAC,4BAA4B,CAAC,IAAI,CAAC,CAAC,IACjF,CAAC;IACH,MAAM,YAAY,GAAqC,EAAE,CAAC;IAC1D,KAAK,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QACpE,YAAY,CAAC,UAAU,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC;IAC/C,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC,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 { loader } from 'webpack';\nimport { Terminal } from '@rushstack/terminal';\nimport { type ILocalizationFile, parseLocFile } from '@rushstack/localization-utilities';\n\nimport { loaderFactory, type IBaseLoaderOptions } from './LoaderFactory';\nimport { LoaderTerminalProvider } from '../utilities/LoaderTerminalProvider';\n\nexport default loaderFactory(function (\n this: loader.LoaderContext,\n locFilePath: string,\n content: string,\n options: IBaseLoaderOptions\n) {\n const locFileData: ILocalizationFile = parseLocFile({\n ...options,\n content,\n filePath: locFilePath,\n terminal: new Terminal(LoaderTerminalProvider.getTerminalProviderForLoader(this))\n });\n const resultObject: { [stringName: string]: string } = {};\n for (const [stringName, stringValue] of Object.entries(locFileData)) {\n resultObject[stringName] = stringValue.value;\n }\n\n return resultObject;\n});\n"]}
1
+ {"version":3,"file":"InPlaceLocFileLoader.js","sourceRoot":"","sources":["../../src/loaders/InPlaceLocFileLoader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAG3D,kDAA+C;AAC/C,8EAAyF;AAEzF,mDAAyE;AACzE,gFAA6E;AAE7E,kBAAe,IAAA,6BAAa,EAAC,UAE3B,WAAmB,EACnB,OAAe,EACf,OAA2B;IAE3B,MAAM,WAAW,GAAsB,IAAA,qCAAY,EAAC;QAClD,GAAG,OAAO;QACV,OAAO;QACP,QAAQ,EAAE,WAAW;QACrB,QAAQ,EAAE,IAAI,mBAAQ,CAAC,+CAAsB,CAAC,4BAA4B,CAAC,IAAI,CAAC,CAAC;KAClF,CAAC,CAAC;IACH,MAAM,YAAY,GAAqC,EAAE,CAAC;IAC1D,KAAK,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QACpE,YAAY,CAAC,UAAU,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC;IAC/C,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC,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 { loader } from 'webpack';\nimport { Terminal } from '@rushstack/terminal';\nimport { type ILocalizationFile, parseLocFile } from '@rushstack/localization-utilities';\n\nimport { loaderFactory, type IBaseLoaderOptions } from './LoaderFactory';\nimport { LoaderTerminalProvider } from '../utilities/LoaderTerminalProvider';\n\nexport default loaderFactory(function (\n this: loader.LoaderContext,\n locFilePath: string,\n content: string,\n options: IBaseLoaderOptions\n) {\n const locFileData: ILocalizationFile = parseLocFile({\n ...options,\n content,\n filePath: locFilePath,\n terminal: new Terminal(LoaderTerminalProvider.getTerminalProviderForLoader(this))\n });\n const resultObject: { [stringName: string]: string } = {};\n for (const [stringName, stringValue] of Object.entries(locFileData)) {\n resultObject[stringName] = stringValue.value;\n }\n\n return resultObject;\n});\n"]}
@@ -17,15 +17,25 @@ 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.loaderFactory = void 0;
38
+ exports.loaderFactory = loaderFactory;
29
39
  const loaderUtils = __importStar(require("loader-utils"));
30
40
  function loaderFactory(innerLoader) {
31
41
  return function (content) {
@@ -37,5 +47,4 @@ function loaderFactory(innerLoader) {
37
47
  return JSON.stringify(resultObject);
38
48
  };
39
49
  }
40
- exports.loaderFactory = loaderFactory;
41
50
  //# sourceMappingURL=LoaderFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LoaderFactory.js","sourceRoot":"","sources":["../../src/loaders/LoaderFactory.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAG3D,0DAA4C;AAc5C,SAAgB,aAAa,CAC3B,WAAuF;IAEvF,OAAO,UAAsC,OAAwB;QACnE,MAAM,OAAO,GAAa,WAAW,CAAC,UAAU,CAAC,IAAI,CAAa,CAAC;QACnE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC/B,CAAC;QAED,MAAM,YAAY,GAAkB,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAChG,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IACtC,CAAC,CAAC;AACJ,CAAC;AAZD,sCAYC","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 { loader } from 'webpack';\nimport * as loaderUtils from 'loader-utils';\nimport type { NewlineKind } from '@rushstack/node-core-library';\nimport type { IgnoreStringFunction } from '@rushstack/localization-utilities';\n\nexport interface IBaseLoaderOptions {\n resxNewlineNormalization: NewlineKind | undefined;\n ignoreMissingResxComments: boolean | undefined;\n ignoreString: IgnoreStringFunction | undefined;\n}\n\nexport interface ILoaderResult {\n [stringName: string]: string;\n}\n\nexport function loaderFactory<TOptions extends IBaseLoaderOptions>(\n innerLoader: (locFilePath: string, content: string, options: TOptions) => ILoaderResult\n): loader.Loader {\n return function (this: loader.LoaderContext, content: string | Buffer): string {\n const options: TOptions = loaderUtils.getOptions(this) as TOptions;\n if (typeof content !== 'string') {\n content = content.toString();\n }\n\n const resultObject: ILoaderResult = innerLoader.call(this, this.resourcePath, content, options);\n return JSON.stringify(resultObject);\n };\n}\n"]}
1
+ {"version":3,"file":"LoaderFactory.js","sourceRoot":"","sources":["../../src/loaders/LoaderFactory.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiB3D,sCAYC;AA1BD,0DAA4C;AAc5C,SAAgB,aAAa,CAC3B,WAAuF;IAEvF,OAAO,UAAsC,OAAwB;QACnE,MAAM,OAAO,GAAa,WAAW,CAAC,UAAU,CAAC,IAAI,CAAa,CAAC;QACnE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC/B,CAAC;QAED,MAAM,YAAY,GAAkB,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAChG,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IACtC,CAAC,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 { loader } from 'webpack';\nimport * as loaderUtils from 'loader-utils';\nimport type { NewlineKind } from '@rushstack/node-core-library';\nimport type { IgnoreStringFunction } from '@rushstack/localization-utilities';\n\nexport interface IBaseLoaderOptions {\n resxNewlineNormalization: NewlineKind | undefined;\n ignoreMissingResxComments: boolean | undefined;\n ignoreString: IgnoreStringFunction | undefined;\n}\n\nexport interface ILoaderResult {\n [stringName: string]: string;\n}\n\nexport function loaderFactory<TOptions extends IBaseLoaderOptions>(\n innerLoader: (locFilePath: string, content: string, options: TOptions) => ILoaderResult\n): loader.Loader {\n return function (this: loader.LoaderContext, content: string | Buffer): string {\n const options: TOptions = loaderUtils.getOptions(this) as TOptions;\n if (typeof content !== 'string') {\n content = content.toString();\n }\n\n const resultObject: ILoaderResult = innerLoader.call(this, this.resourcePath, content, options);\n return JSON.stringify(resultObject);\n };\n}\n"]}
@@ -10,8 +10,12 @@ const LoaderTerminalProvider_1 = require("../utilities/LoaderTerminalProvider");
10
10
  exports.default = (0, LoaderFactory_1.loaderFactory)(function (locFilePath, content, options) {
11
11
  const { pluginInstance } = options;
12
12
  const terminal = new terminal_1.Terminal(LoaderTerminalProvider_1.LoaderTerminalProvider.getTerminalProviderForLoader(this));
13
- const locFileData = (0, localization_utilities_1.parseLocFile)(Object.assign(Object.assign({}, options), { content,
14
- terminal, filePath: locFilePath }));
13
+ const locFileData = (0, localization_utilities_1.parseLocFile)({
14
+ ...options,
15
+ content,
16
+ terminal,
17
+ filePath: locFilePath
18
+ });
15
19
  const { additionalLoadedFilePaths, errors } = pluginInstance.addDefaultLocFile(terminal, locFilePath, locFileData);
16
20
  for (const additionalFile of additionalLoadedFilePaths) {
17
21
  this.dependency(additionalFile);
@@ -1 +1 @@
1
- {"version":3,"file":"LocLoader.js","sourceRoot":"","sources":["../../src/loaders/LocLoader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAG3D,kDAA+C;AAC/C,8EAAyF;AAGzF,mDAAyE;AACzE,4DAAyD;AACzD,gFAA6E;AAM7E,kBAAe,IAAA,6BAAa,EAAC,UAE3B,WAAmB,EACnB,OAAe,EACf,OAA0B;IAE1B,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IACnC,MAAM,QAAQ,GAAa,IAAI,mBAAQ,CAAC,+CAAsB,CAAC,4BAA4B,CAAC,IAAI,CAAC,CAAC,CAAC;IACnG,MAAM,WAAW,GAAsB,IAAA,qCAAY,kCAC9C,OAAO,KACV,OAAO;QACP,QAAQ,EACR,QAAQ,EAAE,WAAW,IACrB,CAAC;IACH,MAAM,EAAE,yBAAyB,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC,iBAAiB,CAC5E,QAAQ,EACR,WAAW,EACX,WAAW,CACZ,CAAC;IACF,KAAK,MAAM,cAAc,IAAI,yBAAyB,EAAE,CAAC;QACvD,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IAED,MAAM,YAAY,GAAqC,EAAE,CAAC;IAC1D,wCAAwC;IACxC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,SAAS,GAAW,GAAG,WAAW,IAAI,UAAU,EAAE,CAAC;QACzD,IAAI,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7C,YAAY,CAAC,UAAU,CAAC,GAAG,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC,KAAK,CAAC;QAC7E,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,oDAAoD,SAAS,GAAG,CAAC,CAAC;QACpF,CAAC;IACH,CAAC;IAED,2BAAY,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAE5C,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC,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 { loader } from 'webpack';\nimport { Terminal } from '@rushstack/terminal';\nimport { type ILocalizationFile, parseLocFile } from '@rushstack/localization-utilities';\n\nimport type { LocalizationPlugin } from '../LocalizationPlugin';\nimport { loaderFactory, type IBaseLoaderOptions } from './LoaderFactory';\nimport { EntityMarker } from '../utilities/EntityMarker';\nimport { LoaderTerminalProvider } from '../utilities/LoaderTerminalProvider';\n\nexport interface ILocLoaderOptions extends IBaseLoaderOptions {\n pluginInstance: LocalizationPlugin;\n}\n\nexport default loaderFactory(function (\n this: loader.LoaderContext,\n locFilePath: string,\n content: string,\n options: ILocLoaderOptions\n) {\n const { pluginInstance } = options;\n const terminal: Terminal = new Terminal(LoaderTerminalProvider.getTerminalProviderForLoader(this));\n const locFileData: ILocalizationFile = parseLocFile({\n ...options,\n content,\n terminal,\n filePath: locFilePath\n });\n const { additionalLoadedFilePaths, errors } = pluginInstance.addDefaultLocFile(\n terminal,\n locFilePath,\n locFileData\n );\n for (const additionalFile of additionalLoadedFilePaths) {\n this.dependency(additionalFile);\n }\n\n for (const error of errors) {\n this.emitError(error);\n }\n\n const resultObject: { [stringName: string]: string } = {};\n // eslint-disable-next-line guard-for-in\n for (const stringName in locFileData) {\n const stringKey: string = `${locFilePath}?${stringName}`;\n if (pluginInstance.stringKeys.has(stringKey)) {\n resultObject[stringName] = pluginInstance.stringKeys.get(stringKey)!.value;\n } else {\n throw new Error(`Unexpected - missing placeholder for string key \"${stringKey}\"`);\n }\n }\n\n EntityMarker.markEntity(this._module, true);\n\n return resultObject;\n});\n"]}
1
+ {"version":3,"file":"LocLoader.js","sourceRoot":"","sources":["../../src/loaders/LocLoader.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAG3D,kDAA+C;AAC/C,8EAAyF;AAGzF,mDAAyE;AACzE,4DAAyD;AACzD,gFAA6E;AAM7E,kBAAe,IAAA,6BAAa,EAAC,UAE3B,WAAmB,EACnB,OAAe,EACf,OAA0B;IAE1B,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IACnC,MAAM,QAAQ,GAAa,IAAI,mBAAQ,CAAC,+CAAsB,CAAC,4BAA4B,CAAC,IAAI,CAAC,CAAC,CAAC;IACnG,MAAM,WAAW,GAAsB,IAAA,qCAAY,EAAC;QAClD,GAAG,OAAO;QACV,OAAO;QACP,QAAQ;QACR,QAAQ,EAAE,WAAW;KACtB,CAAC,CAAC;IACH,MAAM,EAAE,yBAAyB,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC,iBAAiB,CAC5E,QAAQ,EACR,WAAW,EACX,WAAW,CACZ,CAAC;IACF,KAAK,MAAM,cAAc,IAAI,yBAAyB,EAAE,CAAC;QACvD,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IAED,MAAM,YAAY,GAAqC,EAAE,CAAC;IAC1D,wCAAwC;IACxC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,SAAS,GAAW,GAAG,WAAW,IAAI,UAAU,EAAE,CAAC;QACzD,IAAI,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7C,YAAY,CAAC,UAAU,CAAC,GAAG,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC,KAAK,CAAC;QAC7E,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,oDAAoD,SAAS,GAAG,CAAC,CAAC;QACpF,CAAC;IACH,CAAC;IAED,2BAAY,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAE5C,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC,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 { loader } from 'webpack';\nimport { Terminal } from '@rushstack/terminal';\nimport { type ILocalizationFile, parseLocFile } from '@rushstack/localization-utilities';\n\nimport type { LocalizationPlugin } from '../LocalizationPlugin';\nimport { loaderFactory, type IBaseLoaderOptions } from './LoaderFactory';\nimport { EntityMarker } from '../utilities/EntityMarker';\nimport { LoaderTerminalProvider } from '../utilities/LoaderTerminalProvider';\n\nexport interface ILocLoaderOptions extends IBaseLoaderOptions {\n pluginInstance: LocalizationPlugin;\n}\n\nexport default loaderFactory(function (\n this: loader.LoaderContext,\n locFilePath: string,\n content: string,\n options: ILocLoaderOptions\n) {\n const { pluginInstance } = options;\n const terminal: Terminal = new Terminal(LoaderTerminalProvider.getTerminalProviderForLoader(this));\n const locFileData: ILocalizationFile = parseLocFile({\n ...options,\n content,\n terminal,\n filePath: locFilePath\n });\n const { additionalLoadedFilePaths, errors } = pluginInstance.addDefaultLocFile(\n terminal,\n locFilePath,\n locFileData\n );\n for (const additionalFile of additionalLoadedFilePaths) {\n this.dependency(additionalFile);\n }\n\n for (const error of errors) {\n this.emitError(error);\n }\n\n const resultObject: { [stringName: string]: string } = {};\n // eslint-disable-next-line guard-for-in\n for (const stringName in locFileData) {\n const stringKey: string = `${locFilePath}?${stringName}`;\n if (pluginInstance.stringKeys.has(stringKey)) {\n resultObject[stringName] = pluginInstance.stringKeys.get(stringKey)!.value;\n } else {\n throw new Error(`Unexpected - missing placeholder for string key \"${stringKey}\"`);\n }\n }\n\n EntityMarker.markEntity(this._module, true);\n\n return resultObject;\n});\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/webpack4-localization-plugin",
3
- "version": "0.18.92",
3
+ "version": "0.18.94",
4
4
  "description": "This plugin facilitates localization with Webpack.",
5
5
  "main": "lib/index.js",
6
6
  "typings": "dist/webpack4-localization-plugin.d.ts",
@@ -31,9 +31,9 @@
31
31
  "@types/tapable": "1.0.6",
32
32
  "loader-utils": "1.4.2",
33
33
  "minimatch": "~3.0.3",
34
- "@rushstack/localization-utilities": "0.13.1",
35
- "@rushstack/node-core-library": "5.11.0",
36
- "@rushstack/terminal": "0.15.0"
34
+ "@rushstack/localization-utilities": "0.13.3",
35
+ "@rushstack/node-core-library": "5.12.0",
36
+ "@rushstack/terminal": "0.15.1"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@rushstack/set-webpack-public-path-plugin": "^4.1.16",
@@ -42,8 +42,8 @@
42
42
  "@types/node": "20.17.19",
43
43
  "@types/webpack": "4.41.32",
44
44
  "webpack": "~4.47.0",
45
- "local-node-rig": "1.0.0",
46
- "@rushstack/heft": "0.69.2"
45
+ "@rushstack/heft": "0.70.0",
46
+ "local-node-rig": "1.0.0"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "heft build --clean",