@rushstack/webpack5-localization-plugin 0.12.0 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +30 -0
- package/CHANGELOG.md +13 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/AssetProcessor.d.ts.map +1 -1
- package/lib/AssetProcessor.js +5 -4
- package/lib/AssetProcessor.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.json
CHANGED
@@ -1,6 +1,36 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rushstack/webpack5-localization-plugin",
|
3
3
|
"entries": [
|
4
|
+
{
|
5
|
+
"version": "0.12.2",
|
6
|
+
"tag": "@rushstack/webpack5-localization-plugin_v0.12.2",
|
7
|
+
"date": "Fri, 14 Feb 2025 23:17:26 GMT",
|
8
|
+
"comments": {
|
9
|
+
"patch": [
|
10
|
+
{
|
11
|
+
"comment": "Fix a bug where `chunk.localizedFiles` was not set in incremental rebuilds."
|
12
|
+
}
|
13
|
+
]
|
14
|
+
}
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"version": "0.12.1",
|
18
|
+
"tag": "@rushstack/webpack5-localization-plugin_v0.12.1",
|
19
|
+
"date": "Wed, 12 Feb 2025 01:10:52 GMT",
|
20
|
+
"comments": {
|
21
|
+
"dependency": [
|
22
|
+
{
|
23
|
+
"comment": "Updating dependency \"@rushstack/localization-utilities\" to `0.12.20`"
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"comment": "Updating dependency \"@rushstack/terminal\" to `0.15.0`"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"comment": "Updating dependency \"@rushstack/heft\" to `0.68.16`"
|
30
|
+
}
|
31
|
+
]
|
32
|
+
}
|
33
|
+
},
|
4
34
|
{
|
5
35
|
"version": "0.12.0",
|
6
36
|
"tag": "@rushstack/webpack5-localization-plugin_v0.12.0",
|
package/CHANGELOG.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
# Change Log - @rushstack/webpack5-localization-plugin
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Fri, 14 Feb 2025 23:17:26 GMT and should not be manually modified.
|
4
|
+
|
5
|
+
## 0.12.2
|
6
|
+
Fri, 14 Feb 2025 23:17:26 GMT
|
7
|
+
|
8
|
+
### Patches
|
9
|
+
|
10
|
+
- Fix a bug where `chunk.localizedFiles` was not set in incremental rebuilds.
|
11
|
+
|
12
|
+
## 0.12.1
|
13
|
+
Wed, 12 Feb 2025 01:10:52 GMT
|
14
|
+
|
15
|
+
_Version update only_
|
4
16
|
|
5
17
|
## 0.12.0
|
6
18
|
Thu, 06 Feb 2025 01:11:16 GMT
|
package/dist/tsdoc-metadata.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AssetProcessor.d.ts","sourceRoot":"","sources":["../src/AssetProcessor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAG7E,OAAO,KAAK,EAAE,kBAAkB,EAAsB,MAAM,sBAAsB,CAAC;AAmBnF,KAAK,yBAAyB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;AAiB5D,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,WAAW,EAAE,WAAW,CAAC;IACzB,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;IAC3C,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,gCAAiC,SAAQ,wBAAwB;IAChF,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,OAAO,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,yBAAyB,EAAE,yBAAyB,CAAC;CACtD;AAED,MAAM,WAAW,6BAA8B,SAAQ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AA6B,GAAG,4BAA4B,CAsF1G;AAED,wBAAsB,mCAAmC,CACvD,OAAO,EAAE,gCAAgC,GACxC,OAAO,CAAC,IAAI,CAAC,CAoBf;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,gCAAgC,GAAG,eAAe,CAsDnG"}
|
package/lib/AssetProcessor.js
CHANGED
@@ -29,7 +29,7 @@ exports.processNonLocalizedAsset = exports.processNonLocalizedAssetCachedAsync =
|
|
29
29
|
const Constants = __importStar(require("./utilities/Constants"));
|
30
30
|
exports.PLACEHOLDER_REGEX = new RegExp(`${Constants.STRING_PLACEHOLDER_PREFIX}_([A-C])_(\\\\*)_([0-9a-f$]+)_`, 'g');
|
31
31
|
async function processLocalizedAssetCachedAsync(options) {
|
32
|
-
const { compilation, asset, cache } = options;
|
32
|
+
const { compilation, asset, cache, chunk } = options;
|
33
33
|
const { source: originalSource } = asset;
|
34
34
|
const eTag = cache.getLazyHashedEtag(originalSource);
|
35
35
|
const { name: originName } = asset;
|
@@ -39,7 +39,9 @@ async function processLocalizedAssetCachedAsync(options) {
|
|
39
39
|
output = processLocalizedAsset(options);
|
40
40
|
await cacheItem.storePromise(output);
|
41
41
|
}
|
42
|
-
|
42
|
+
const { localizedFiles, processedAssets } = output;
|
43
|
+
chunk.localizedFiles = localizedFiles;
|
44
|
+
for (const { filename, source, info } of processedAssets) {
|
43
45
|
if (originName === filename) {
|
44
46
|
// This helper throws if the asset doesn't already exist
|
45
47
|
// Use the function form so that the object identity of `related` is preserved.
|
@@ -51,7 +53,7 @@ async function processLocalizedAssetCachedAsync(options) {
|
|
51
53
|
compilation.emitAsset(filename, source, info);
|
52
54
|
}
|
53
55
|
}
|
54
|
-
return
|
56
|
+
return localizedFiles;
|
55
57
|
}
|
56
58
|
exports.processLocalizedAssetCachedAsync = processLocalizedAssetCachedAsync;
|
57
59
|
function processLocalizedAsset(options) {
|
@@ -65,7 +67,6 @@ function processLocalizedAsset(options) {
|
|
65
67
|
const parsedAsset = _parseStringToReconstructionSequence(options.plugin, assetSource, formatLocaleForFilenameFn);
|
66
68
|
const { issues } = parsedAsset;
|
67
69
|
const localizedFiles = {};
|
68
|
-
chunk.localizedFiles = localizedFiles;
|
69
70
|
const processedAssets = [];
|
70
71
|
const { info: originInfo, name: originName } = asset;
|
71
72
|
if (!originInfo.related) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"AssetProcessor.js","sourceRoot":"","sources":["../src/AssetProcessor.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAI3D,iEAAmD;AAkEtC,QAAA,iBAAiB,GAAW,IAAI,MAAM,CACjD,GAAG,SAAS,CAAC,yBAAyB,gCAAgC,EACtE,GAAG,CACJ,CAAC;AAeK,KAAK,UAAU,gCAAgC,CACpD,OAAsC;IAEtC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAC9C,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAGzC,MAAM,IAAI,GAAgB,KAAK,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAClE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IACnC,MAAM,SAAS,GAAoB,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACxE,IAAI,MAAM,GAA6C,MAAM,SAAS,CAAC,UAAU,EAAE,CAAC;IAEpF,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACxC,MAAM,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;QAChE,IAAI,UAAU,KAAK,QAAQ,EAAE,CAAC;YAC5B,wD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Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { Asset, AssetInfo, Chunk, Compilation, sources } from 'webpack';\n\nimport * as Constants from './utilities/Constants';\nimport type { LocalizationPlugin, IStringPlaceholder } from './LocalizationPlugin';\nimport type { ILocalizedWebpackChunk, IAssetPathOptions } from './webpackInterfaces';\n\ninterface ILocalizedReconstructionElement {\n kind: 'localized';\n start: number;\n end: number;\n escapedBackslash: string;\n data: IStringPlaceholder;\n}\n\ninterface IDynamicReconstructionElement {\n kind: 'dynamic';\n start: number;\n end: number;\n valueFn: (locale: string) => string;\n}\n\ntype IReconstructionElement = ILocalizedReconstructionElement | IDynamicReconstructionElement;\ntype FormatLocaleForFilenameFn = (locale: string) => string;\n\ninterface IParseResult {\n issues: string[];\n reconstructionSeries: IReconstructionElement[];\n}\n\ninterface ILocalizedReconstructionResult {\n result: sources.ReplaceSource;\n issues: string[];\n}\n\ninterface INonLocalizedReconstructionResult {\n result: sources.ReplaceSource;\n issues: string[];\n}\n\nexport interface IProcessAssetOptionsBase {\n plugin: LocalizationPlugin;\n compilation: Compilation;\n cache: ReturnType<Compilation['getCache']>;\n chunk: Chunk;\n asset: Asset;\n}\n\nexport interface IProcessNonLocalizedAssetOptions extends IProcessAssetOptionsBase {\n fileName: string;\n hasUrlGenerator: boolean;\n noStringsLocaleName: string;\n formatLocaleForFilenameFn: FormatLocaleForFilenameFn;\n}\n\nexport interface IProcessLocalizedAssetOptions extends IProcessAssetOptionsBase {\n locales: Set<string>;\n fillMissingTranslationStrings: boolean;\n defaultLocale: string;\n passthroughLocaleName: string | undefined;\n filenameTemplate: Parameters<typeof Compilation.prototype.getAssetPath>[0];\n formatLocaleForFilenameFn: FormatLocaleForFilenameFn;\n}\n\nexport interface IProcessAssetResult {\n filename: string;\n asset: sources.Source;\n}\n\nexport const PLACEHOLDER_REGEX: RegExp = new RegExp(\n `${Constants.STRING_PLACEHOLDER_PREFIX}_([A-C])_(\\\\\\\\*)_([0-9a-f$]+)_`,\n 'g'\n);\n\nexport interface IProcessedAsset {\n filename: string;\n source: sources.CachedSource;\n info: AssetInfo;\n}\n\nexport interface IProcessLocalizedAssetResult {\n localizedFiles: Record<string, string>;\n processedAssets: IProcessedAsset[];\n}\n\ntype ItemCacheFacade = ReturnType<ReturnType<Compilation['getCache']>['getItemCache']>;\n\nexport async function processLocalizedAssetCachedAsync(\n options: IProcessLocalizedAssetOptions\n): Promise<Record<string, string>> {\n const { compilation, asset, cache } = options;\n const { source: originalSource } = asset;\n\n type ETag = NonNullable<ReturnType<typeof cache.getLazyHashedEtag>>;\n const eTag: ETag | null = cache.getLazyHashedEtag(originalSource);\n const { name: originName } = asset;\n const cacheItem: ItemCacheFacade = cache.getItemCache(originName, eTag);\n let output: IProcessLocalizedAssetResult | undefined = await cacheItem.getPromise();\n\n if (!output) {\n output = processLocalizedAsset(options);\n await cacheItem.storePromise(output);\n }\n\n for (const { filename, source, info } of output.processedAssets) {\n if (originName === filename) {\n // This helper throws if the asset doesn't already exist\n // Use the function form so that the object identity of `related` is preserved.\n // Since we already read the original info, we don't need fancy merge logic.\n compilation.updateAsset(filename, source, () => info);\n } else {\n // This helper throws if the asset already exists\n compilation.emitAsset(filename, source, info);\n }\n }\n\n return output.localizedFiles;\n}\n\nexport function processLocalizedAsset(options: IProcessLocalizedAssetOptions): IProcessLocalizedAssetResult {\n const { compilation, asset, chunk, filenameTemplate, locales, formatLocaleForFilenameFn } = options;\n\n const { sources, WebpackError } = compilation.compiler.webpack;\n\n const { source: originalSource } = asset;\n\n const rawSource: sources.CachedSource =\n originalSource instanceof sources.CachedSource\n ? originalSource\n : new sources.CachedSource(originalSource);\n const assetSource: string = rawSource.source().toString();\n\n const parsedAsset: IParseResult = _parseStringToReconstructionSequence(\n options.plugin,\n assetSource,\n formatLocaleForFilenameFn\n );\n\n const { issues } = parsedAsset;\n\n const localizedFiles: Record<string, string> = {};\n (chunk as ILocalizedWebpackChunk).localizedFiles = localizedFiles;\n\n const processedAssets: IProcessedAsset[] = [];\n\n const { info: originInfo, name: originName } = asset;\n if (!originInfo.related) {\n originInfo.related = {};\n }\n\n for (const locale of locales) {\n const { issues: localeIssues, result: localeResult } = _reconstructLocalized(\n new sources.ReplaceSource(rawSource, locale),\n parsedAsset.reconstructionSeries,\n locale,\n options.fillMissingTranslationStrings ? options.defaultLocale : undefined,\n options.passthroughLocaleName\n );\n\n for (const issue of localeIssues) {\n issues.push(issue);\n }\n\n const data: IAssetPathOptions = {\n chunk,\n contentHashType: 'javascript',\n // The locale property will get processed by the extension to the getAssetPath hook\n locale\n };\n\n const fileName: string = compilation.getAssetPath(filenameTemplate, data);\n\n const info: AssetInfo & { locale: string } = {\n ...originInfo,\n locale\n };\n\n const wrapped: sources.CachedSource = new sources.CachedSource(localeResult);\n localizedFiles[locale] = fileName;\n\n processedAssets.push({\n filename: fileName,\n source: wrapped,\n info\n });\n\n // If file already exists\n if (originName !== fileName) {\n // If A.related points to B, B.related can't point to A or the stats emitter explodes\n // So just strip the related object for the localized assets\n info.related = undefined;\n // We omit the `related` property that does a self-reference.\n originInfo.related[locale] = fileName;\n }\n }\n\n if (issues.length > 0) {\n compilation.errors.push(\n new WebpackError(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n\n return {\n localizedFiles,\n processedAssets\n };\n}\n\nexport async function processNonLocalizedAssetCachedAsync(\n options: IProcessNonLocalizedAssetOptions\n): Promise<void> {\n const { compilation, asset, cache } = options;\n const { source: originalSource } = asset;\n\n type ETag = NonNullable<ReturnType<typeof cache.getLazyHashedEtag>>;\n const eTag: ETag | null = cache.getLazyHashedEtag(originalSource);\n const { name: originName } = asset;\n const cacheItem: ItemCacheFacade = cache.getItemCache(originName, eTag);\n let output: IProcessedAsset | undefined = await cacheItem.getPromise();\n\n if (!output) {\n output = processNonLocalizedAsset(options);\n await cacheItem.storePromise(output);\n }\n\n const { filename, source, info } = output;\n compilation.updateAsset(originName, source, info);\n if (originName !== filename) {\n compilation.renameAsset(originName, filename);\n }\n}\n\nexport function processNonLocalizedAsset(options: IProcessNonLocalizedAssetOptions): IProcessedAsset {\n const { asset, fileName, compilation, formatLocaleForFilenameFn, hasUrlGenerator } = options;\n\n const { sources, WebpackError } = compilation.compiler.webpack;\n\n const rawSource: sources.Source = asset.source;\n let cachedSource: sources.CachedSource =\n rawSource instanceof sources.CachedSource ? rawSource : new sources.CachedSource(rawSource);\n\n const { info: originInfo } = asset;\n const locale: string = options.noStringsLocaleName;\n\n if (hasUrlGenerator) {\n const assetSource: string = cachedSource.source().toString();\n const parsedAsset: IParseResult = _parseStringToReconstructionSequence(\n options.plugin,\n assetSource,\n formatLocaleForFilenameFn\n );\n\n const { issues } = parsedAsset;\n\n const { issues: localeIssues, result } = _reconstructNonLocalized(\n new sources.ReplaceSource(cachedSource, locale),\n parsedAsset.reconstructionSeries,\n locale\n );\n\n for (const issue of localeIssues) {\n issues.push(issue);\n }\n\n if (issues.length > 0) {\n options.compilation.errors.push(\n new WebpackError(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n\n cachedSource = new sources.CachedSource(result);\n } else {\n // Force the CachedSource to cache the concatenated *string*, so that the subsequent ask for the buffer is fast\n cachedSource.source();\n }\n\n const info: AssetInfo = {\n ...originInfo,\n locale\n };\n\n return {\n filename: fileName,\n source: cachedSource,\n info\n };\n}\n\nconst ESCAPE_MAP: Map<string, string> = new Map([\n ['\\r', 'r'],\n ['\\n', 'n'],\n ['\\t', 't'],\n ['\"', 'u0022'],\n [\"'\", 'u0027']\n]);\n\nconst BACKSLASH_REGEX: RegExp = /\\\\/g;\nconst ESCAPE_REGEX: RegExp = /[\\r\\n\\t\"']/g;\n\nfunction _reconstructLocalized(\n result: sources.ReplaceSource,\n reconstructionSeries: IReconstructionElement[],\n locale: string,\n fallbackLocale: string | undefined,\n passthroughLocale: string | undefined\n): ILocalizedReconstructionResult {\n const issues: string[] = [];\n\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'localized': {\n const { data } = element;\n const { stringName, translations } = data;\n let newValue: string | undefined =\n locale === passthroughLocale ? stringName : translations.get(locale)?.get(stringName);\n if (fallbackLocale && newValue === undefined) {\n newValue = translations.get(fallbackLocale)?.get(stringName);\n }\n\n if (newValue === undefined) {\n issues.push(\n `The string \"${stringName}\" in \"${data.locFilePath}\" is missing in the locale ${locale}`\n );\n\n newValue = '-- MISSING STRING --';\n }\n\n const escapedBackslash: string = element.escapedBackslash || '\\\\';\n\n if (newValue.includes('\\\\')) {\n // The vast majority of localized strings do not contain `\\\\`, so this check avoids an allocation.\n // Replace backslashes with the properly escaped backslash\n BACKSLASH_REGEX.lastIndex = -1;\n newValue = newValue.replace(BACKSLASH_REGEX, escapedBackslash);\n }\n\n // Ensure the the quotemark, apostrophe, tab, and newline characters are properly escaped\n ESCAPE_REGEX.lastIndex = -1;\n if (ESCAPE_REGEX.test(newValue)) {\n // The majority of localized strings do not contain the characters that need to be escaped,\n // so this check avoids an allocation.\n // @todo: look into using JSON.parse(...) to get the escaping characters\n const escapingCharacterSequence: string = escapedBackslash.slice(escapedBackslash.length / 2);\n newValue = newValue.replace(\n ESCAPE_REGEX,\n (match) => `${escapingCharacterSequence}${ESCAPE_MAP.get(match)}`\n );\n }\n\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n\n case 'dynamic': {\n const newValue: string = element.valueFn(locale);\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n }\n }\n\n return {\n issues,\n result\n };\n}\n\nfunction _reconstructNonLocalized(\n result: sources.ReplaceSource,\n reconstructionSeries: IReconstructionElement[],\n noStringsLocaleName: string\n): INonLocalizedReconstructionResult {\n const issues: string[] = [];\n\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'localized': {\n issues.push(\n `The string \"${element.data.stringName}\" in \"${element.data.locFilePath}\" appeared in an asset ` +\n 'that is not expected to contain localized resources.'\n );\n\n const newValue: string = '-- NOT EXPECTED TO BE LOCALIZED --';\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n\n case 'dynamic': {\n const newValue: string = element.valueFn(noStringsLocaleName);\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n }\n }\n\n return {\n issues,\n result\n };\n}\n\nfunction _parseStringToReconstructionSequence(\n plugin: LocalizationPlugin,\n source: string,\n formatLocaleForFilenameFn: FormatLocaleForFilenameFn\n): IParseResult {\n const issues: string[] = [];\n const reconstructionSeries: IReconstructionElement[] = [];\n\n let jsonStringifyFormatLocaleForFilenameFn: FormatLocaleForFilenameFn | undefined;\n\n let index: number = source.indexOf(Constants.STRING_PLACEHOLDER_PREFIX);\n const increment: number = Constants.STRING_PLACEHOLDER_PREFIX.length + 1;\n while (index >= 0) {\n const start: number = index;\n const elementStart: number = index + increment;\n const elementLabel: string = source.charAt(elementStart);\n let end: number = elementStart + 2;\n\n switch (elementLabel) {\n case Constants.STRING_PLACEHOLDER_LABEL: {\n const backslashEnd: number = source.indexOf('_', end);\n const escapedBackslash: string = source.slice(end, backslashEnd);\n end = backslashEnd + 1;\n const serialEnd: number = source.indexOf('_', end);\n const serial: string = source.slice(end, serialEnd);\n end = serialEnd + 1;\n\n const stringData: IStringPlaceholder | undefined = plugin.getDataForSerialNumber(serial);\n if (!stringData) {\n issues.push(`Missing placeholder ${serial}`);\n } else {\n const localizedElement: ILocalizedReconstructionElement = {\n kind: 'localized',\n start,\n end,\n escapedBackslash,\n data: stringData\n };\n reconstructionSeries.push(localizedElement);\n }\n break;\n }\n case Constants.LOCALE_NAME_PLACEHOLDER_LABEL: {\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n start,\n end,\n valueFn: formatLocaleForFilenameFn\n };\n reconstructionSeries.push(dynamicElement);\n break;\n }\n case Constants.JSONP_PLACEHOLDER_LABEL: {\n jsonStringifyFormatLocaleForFilenameFn ||= (locale: string) =>\n JSON.stringify(formatLocaleForFilenameFn(locale));\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n start,\n end,\n valueFn: jsonStringifyFormatLocaleForFilenameFn\n };\n reconstructionSeries.push(dynamicElement);\n break;\n }\n default: {\n throw new Error(`Unexpected label ${elementLabel} in pattern ${source.slice(start, end)}`);\n }\n }\n\n index = source.indexOf(Constants.STRING_PLACEHOLDER_PREFIX, end);\n }\n\n return {\n issues,\n reconstructionSeries\n };\n}\n"]}
|
1
|
+
{"version":3,"file":"AssetProcessor.js","sourceRoot":"","sources":["../src/AssetProcessor.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAI3D,iEAAmD;AAkEtC,QAAA,iBAAiB,GAAW,IAAI,MAAM,CACjD,GAAG,SAAS,CAAC,yBAAyB,gCAAgC,EACtE,GAAG,CACJ,CAAC;AAeK,KAAK,UAAU,gCAAgC,CACpD,OAAsC;IAEtC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IACrD,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAGzC,MAAM,IAAI,GAAgB,KAAK,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAClE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IACnC,MAAM,SAAS,GAAoB,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACxE,IAAI,MAAM,GAA6C,MAAM,SAAS,CAAC,UAAU,EAAE,CAAC;IAEpF,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;QACxC,MAAM,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC;IAElD,KAAgC,CAAC,cAAc,GAAG,cAAc,CAAC;IAElE,KAAK,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE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C;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { Asset, AssetInfo, Chunk, Compilation, sources } from 'webpack';\n\nimport * as Constants from './utilities/Constants';\nimport type { LocalizationPlugin, IStringPlaceholder } from './LocalizationPlugin';\nimport type { ILocalizedWebpackChunk, IAssetPathOptions } from './webpackInterfaces';\n\ninterface ILocalizedReconstructionElement {\n kind: 'localized';\n start: number;\n end: number;\n escapedBackslash: string;\n data: IStringPlaceholder;\n}\n\ninterface IDynamicReconstructionElement {\n kind: 'dynamic';\n start: number;\n end: number;\n valueFn: (locale: string) => string;\n}\n\ntype IReconstructionElement = ILocalizedReconstructionElement | IDynamicReconstructionElement;\ntype FormatLocaleForFilenameFn = (locale: string) => string;\n\ninterface IParseResult {\n issues: string[];\n reconstructionSeries: IReconstructionElement[];\n}\n\ninterface ILocalizedReconstructionResult {\n result: sources.ReplaceSource;\n issues: string[];\n}\n\ninterface INonLocalizedReconstructionResult {\n result: sources.ReplaceSource;\n issues: string[];\n}\n\nexport interface IProcessAssetOptionsBase {\n plugin: LocalizationPlugin;\n compilation: Compilation;\n cache: ReturnType<Compilation['getCache']>;\n chunk: Chunk;\n asset: Asset;\n}\n\nexport interface IProcessNonLocalizedAssetOptions extends IProcessAssetOptionsBase {\n fileName: string;\n hasUrlGenerator: boolean;\n noStringsLocaleName: string;\n formatLocaleForFilenameFn: FormatLocaleForFilenameFn;\n}\n\nexport interface IProcessLocalizedAssetOptions extends IProcessAssetOptionsBase {\n locales: Set<string>;\n fillMissingTranslationStrings: boolean;\n defaultLocale: string;\n passthroughLocaleName: string | undefined;\n filenameTemplate: Parameters<typeof Compilation.prototype.getAssetPath>[0];\n formatLocaleForFilenameFn: FormatLocaleForFilenameFn;\n}\n\nexport interface IProcessAssetResult {\n filename: string;\n asset: sources.Source;\n}\n\nexport const PLACEHOLDER_REGEX: RegExp = new RegExp(\n `${Constants.STRING_PLACEHOLDER_PREFIX}_([A-C])_(\\\\\\\\*)_([0-9a-f$]+)_`,\n 'g'\n);\n\nexport interface IProcessedAsset {\n filename: string;\n source: sources.CachedSource;\n info: AssetInfo;\n}\n\nexport interface IProcessLocalizedAssetResult {\n localizedFiles: Record<string, string>;\n processedAssets: IProcessedAsset[];\n}\n\ntype ItemCacheFacade = ReturnType<ReturnType<Compilation['getCache']>['getItemCache']>;\n\nexport async function processLocalizedAssetCachedAsync(\n options: IProcessLocalizedAssetOptions\n): Promise<Record<string, string>> {\n const { compilation, asset, cache, chunk } = options;\n const { source: originalSource } = asset;\n\n type ETag = NonNullable<ReturnType<typeof cache.getLazyHashedEtag>>;\n const eTag: ETag | null = cache.getLazyHashedEtag(originalSource);\n const { name: originName } = asset;\n const cacheItem: ItemCacheFacade = cache.getItemCache(originName, eTag);\n let output: IProcessLocalizedAssetResult | undefined = await cacheItem.getPromise();\n\n if (!output) {\n output = processLocalizedAsset(options);\n await cacheItem.storePromise(output);\n }\n\n const { localizedFiles, processedAssets } = output;\n\n (chunk as ILocalizedWebpackChunk).localizedFiles = localizedFiles;\n\n for (const { filename, source, info } of processedAssets) {\n if (originName === filename) {\n // This helper throws if the asset doesn't already exist\n // Use the function form so that the object identity of `related` is preserved.\n // Since we already read the original info, we don't need fancy merge logic.\n compilation.updateAsset(filename, source, () => info);\n } else {\n // This helper throws if the asset already exists\n compilation.emitAsset(filename, source, info);\n }\n }\n\n return localizedFiles;\n}\n\nexport function processLocalizedAsset(options: IProcessLocalizedAssetOptions): IProcessLocalizedAssetResult {\n const { compilation, asset, chunk, filenameTemplate, locales, formatLocaleForFilenameFn } = options;\n\n const { sources, WebpackError } = compilation.compiler.webpack;\n\n const { source: originalSource } = asset;\n\n const rawSource: sources.CachedSource =\n originalSource instanceof sources.CachedSource\n ? originalSource\n : new sources.CachedSource(originalSource);\n const assetSource: string = rawSource.source().toString();\n\n const parsedAsset: IParseResult = _parseStringToReconstructionSequence(\n options.plugin,\n assetSource,\n formatLocaleForFilenameFn\n );\n\n const { issues } = parsedAsset;\n\n const localizedFiles: Record<string, string> = {};\n\n const processedAssets: IProcessedAsset[] = [];\n\n const { info: originInfo, name: originName } = asset;\n if (!originInfo.related) {\n originInfo.related = {};\n }\n\n for (const locale of locales) {\n const { issues: localeIssues, result: localeResult } = _reconstructLocalized(\n new sources.ReplaceSource(rawSource, locale),\n parsedAsset.reconstructionSeries,\n locale,\n options.fillMissingTranslationStrings ? options.defaultLocale : undefined,\n options.passthroughLocaleName\n );\n\n for (const issue of localeIssues) {\n issues.push(issue);\n }\n\n const data: IAssetPathOptions = {\n chunk,\n contentHashType: 'javascript',\n // The locale property will get processed by the extension to the getAssetPath hook\n locale\n };\n\n const fileName: string = compilation.getAssetPath(filenameTemplate, data);\n\n const info: AssetInfo & { locale: string } = {\n ...originInfo,\n locale\n };\n\n const wrapped: sources.CachedSource = new sources.CachedSource(localeResult);\n localizedFiles[locale] = fileName;\n\n processedAssets.push({\n filename: fileName,\n source: wrapped,\n info\n });\n\n // If file already exists\n if (originName !== fileName) {\n // If A.related points to B, B.related can't point to A or the stats emitter explodes\n // So just strip the related object for the localized assets\n info.related = undefined;\n // We omit the `related` property that does a self-reference.\n originInfo.related[locale] = fileName;\n }\n }\n\n if (issues.length > 0) {\n compilation.errors.push(\n new WebpackError(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n\n return {\n localizedFiles,\n processedAssets\n };\n}\n\nexport async function processNonLocalizedAssetCachedAsync(\n options: IProcessNonLocalizedAssetOptions\n): Promise<void> {\n const { compilation, asset, cache } = options;\n const { source: originalSource } = asset;\n\n type ETag = NonNullable<ReturnType<typeof cache.getLazyHashedEtag>>;\n const eTag: ETag | null = cache.getLazyHashedEtag(originalSource);\n const { name: originName } = asset;\n const cacheItem: ItemCacheFacade = cache.getItemCache(originName, eTag);\n let output: IProcessedAsset | undefined = await cacheItem.getPromise();\n\n if (!output) {\n output = processNonLocalizedAsset(options);\n await cacheItem.storePromise(output);\n }\n\n const { filename, source, info } = output;\n compilation.updateAsset(originName, source, info);\n if (originName !== filename) {\n compilation.renameAsset(originName, filename);\n }\n}\n\nexport function processNonLocalizedAsset(options: IProcessNonLocalizedAssetOptions): IProcessedAsset {\n const { asset, fileName, compilation, formatLocaleForFilenameFn, hasUrlGenerator } = options;\n\n const { sources, WebpackError } = compilation.compiler.webpack;\n\n const rawSource: sources.Source = asset.source;\n let cachedSource: sources.CachedSource =\n rawSource instanceof sources.CachedSource ? rawSource : new sources.CachedSource(rawSource);\n\n const { info: originInfo } = asset;\n const locale: string = options.noStringsLocaleName;\n\n if (hasUrlGenerator) {\n const assetSource: string = cachedSource.source().toString();\n const parsedAsset: IParseResult = _parseStringToReconstructionSequence(\n options.plugin,\n assetSource,\n formatLocaleForFilenameFn\n );\n\n const { issues } = parsedAsset;\n\n const { issues: localeIssues, result } = _reconstructNonLocalized(\n new sources.ReplaceSource(cachedSource, locale),\n parsedAsset.reconstructionSeries,\n locale\n );\n\n for (const issue of localeIssues) {\n issues.push(issue);\n }\n\n if (issues.length > 0) {\n options.compilation.errors.push(\n new WebpackError(`localization:\\n${issues.map((issue) => ` ${issue}`).join('\\n')}`)\n );\n }\n\n cachedSource = new sources.CachedSource(result);\n } else {\n // Force the CachedSource to cache the concatenated *string*, so that the subsequent ask for the buffer is fast\n cachedSource.source();\n }\n\n const info: AssetInfo = {\n ...originInfo,\n locale\n };\n\n return {\n filename: fileName,\n source: cachedSource,\n info\n };\n}\n\nconst ESCAPE_MAP: Map<string, string> = new Map([\n ['\\r', 'r'],\n ['\\n', 'n'],\n ['\\t', 't'],\n ['\"', 'u0022'],\n [\"'\", 'u0027']\n]);\n\nconst BACKSLASH_REGEX: RegExp = /\\\\/g;\nconst ESCAPE_REGEX: RegExp = /[\\r\\n\\t\"']/g;\n\nfunction _reconstructLocalized(\n result: sources.ReplaceSource,\n reconstructionSeries: IReconstructionElement[],\n locale: string,\n fallbackLocale: string | undefined,\n passthroughLocale: string | undefined\n): ILocalizedReconstructionResult {\n const issues: string[] = [];\n\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'localized': {\n const { data } = element;\n const { stringName, translations } = data;\n let newValue: string | undefined =\n locale === passthroughLocale ? stringName : translations.get(locale)?.get(stringName);\n if (fallbackLocale && newValue === undefined) {\n newValue = translations.get(fallbackLocale)?.get(stringName);\n }\n\n if (newValue === undefined) {\n issues.push(\n `The string \"${stringName}\" in \"${data.locFilePath}\" is missing in the locale ${locale}`\n );\n\n newValue = '-- MISSING STRING --';\n }\n\n const escapedBackslash: string = element.escapedBackslash || '\\\\';\n\n if (newValue.includes('\\\\')) {\n // The vast majority of localized strings do not contain `\\\\`, so this check avoids an allocation.\n // Replace backslashes with the properly escaped backslash\n BACKSLASH_REGEX.lastIndex = -1;\n newValue = newValue.replace(BACKSLASH_REGEX, escapedBackslash);\n }\n\n // Ensure the the quotemark, apostrophe, tab, and newline characters are properly escaped\n ESCAPE_REGEX.lastIndex = -1;\n if (ESCAPE_REGEX.test(newValue)) {\n // The majority of localized strings do not contain the characters that need to be escaped,\n // so this check avoids an allocation.\n // @todo: look into using JSON.parse(...) to get the escaping characters\n const escapingCharacterSequence: string = escapedBackslash.slice(escapedBackslash.length / 2);\n newValue = newValue.replace(\n ESCAPE_REGEX,\n (match) => `${escapingCharacterSequence}${ESCAPE_MAP.get(match)}`\n );\n }\n\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n\n case 'dynamic': {\n const newValue: string = element.valueFn(locale);\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n }\n }\n\n return {\n issues,\n result\n };\n}\n\nfunction _reconstructNonLocalized(\n result: sources.ReplaceSource,\n reconstructionSeries: IReconstructionElement[],\n noStringsLocaleName: string\n): INonLocalizedReconstructionResult {\n const issues: string[] = [];\n\n for (const element of reconstructionSeries) {\n switch (element.kind) {\n case 'localized': {\n issues.push(\n `The string \"${element.data.stringName}\" in \"${element.data.locFilePath}\" appeared in an asset ` +\n 'that is not expected to contain localized resources.'\n );\n\n const newValue: string = '-- NOT EXPECTED TO BE LOCALIZED --';\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n\n case 'dynamic': {\n const newValue: string = element.valueFn(noStringsLocaleName);\n result.replace(element.start, element.end - 1, newValue);\n break;\n }\n }\n }\n\n return {\n issues,\n result\n };\n}\n\nfunction _parseStringToReconstructionSequence(\n plugin: LocalizationPlugin,\n source: string,\n formatLocaleForFilenameFn: FormatLocaleForFilenameFn\n): IParseResult {\n const issues: string[] = [];\n const reconstructionSeries: IReconstructionElement[] = [];\n\n let jsonStringifyFormatLocaleForFilenameFn: FormatLocaleForFilenameFn | undefined;\n\n let index: number = source.indexOf(Constants.STRING_PLACEHOLDER_PREFIX);\n const increment: number = Constants.STRING_PLACEHOLDER_PREFIX.length + 1;\n while (index >= 0) {\n const start: number = index;\n const elementStart: number = index + increment;\n const elementLabel: string = source.charAt(elementStart);\n let end: number = elementStart + 2;\n\n switch (elementLabel) {\n case Constants.STRING_PLACEHOLDER_LABEL: {\n const backslashEnd: number = source.indexOf('_', end);\n const escapedBackslash: string = source.slice(end, backslashEnd);\n end = backslashEnd + 1;\n const serialEnd: number = source.indexOf('_', end);\n const serial: string = source.slice(end, serialEnd);\n end = serialEnd + 1;\n\n const stringData: IStringPlaceholder | undefined = plugin.getDataForSerialNumber(serial);\n if (!stringData) {\n issues.push(`Missing placeholder ${serial}`);\n } else {\n const localizedElement: ILocalizedReconstructionElement = {\n kind: 'localized',\n start,\n end,\n escapedBackslash,\n data: stringData\n };\n reconstructionSeries.push(localizedElement);\n }\n break;\n }\n case Constants.LOCALE_NAME_PLACEHOLDER_LABEL: {\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n start,\n end,\n valueFn: formatLocaleForFilenameFn\n };\n reconstructionSeries.push(dynamicElement);\n break;\n }\n case Constants.JSONP_PLACEHOLDER_LABEL: {\n jsonStringifyFormatLocaleForFilenameFn ||= (locale: string) =>\n JSON.stringify(formatLocaleForFilenameFn(locale));\n const dynamicElement: IDynamicReconstructionElement = {\n kind: 'dynamic',\n start,\n end,\n valueFn: jsonStringifyFormatLocaleForFilenameFn\n };\n reconstructionSeries.push(dynamicElement);\n break;\n }\n default: {\n throw new Error(`Unexpected label ${elementLabel} in pattern ${source.slice(start, end)}`);\n }\n }\n\n index = source.indexOf(Constants.STRING_PLACEHOLDER_PREFIX, end);\n }\n\n return {\n issues,\n reconstructionSeries\n };\n}\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rushstack/webpack5-localization-plugin",
|
3
|
-
"version": "0.12.
|
3
|
+
"version": "0.12.2",
|
4
4
|
"description": "This plugin facilitates localization with Webpack.",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"typings": "dist/webpack5-localization-plugin.d.ts",
|
@@ -15,14 +15,14 @@
|
|
15
15
|
"@types/node": "*"
|
16
16
|
},
|
17
17
|
"dependencies": {
|
18
|
-
"@rushstack/localization-utilities": "0.12.
|
19
|
-
"@rushstack/
|
20
|
-
"@rushstack/
|
18
|
+
"@rushstack/localization-utilities": "0.12.20",
|
19
|
+
"@rushstack/terminal": "0.15.0",
|
20
|
+
"@rushstack/node-core-library": "5.11.0"
|
21
21
|
},
|
22
22
|
"devDependencies": {
|
23
23
|
"memfs": "4.12.0",
|
24
24
|
"webpack": "~5.95.0",
|
25
|
-
"@rushstack/heft": "0.68.
|
25
|
+
"@rushstack/heft": "0.68.16",
|
26
26
|
"local-node-rig": "1.0.0"
|
27
27
|
},
|
28
28
|
"peerDependenciesMeta": {
|