Skip to content

Commit 33336f6

Browse files
authored
[webpack5-loc-plugin] Fix missing metadata during rebuild (#5110)
Co-authored-by: David Michon <[email protected]>
1 parent 6e9add6 commit 33336f6

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@rushstack/webpack5-localization-plugin",
5+
"comment": "Fix a bug where `chunk.localizedFiles` was not set in incremental rebuilds.",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@rushstack/webpack5-localization-plugin"
10+
}

webpack/webpack5-localization-plugin/src/AssetProcessor.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ type ItemCacheFacade = ReturnType<ReturnType<Compilation['getCache']>['getItemCa
9090
export async function processLocalizedAssetCachedAsync(
9191
options: IProcessLocalizedAssetOptions
9292
): Promise<Record<string, string>> {
93-
const { compilation, asset, cache } = options;
93+
const { compilation, asset, cache, chunk } = options;
9494
const { source: originalSource } = asset;
9595

9696
type ETag = NonNullable<ReturnType<typeof cache.getLazyHashedEtag>>;
@@ -104,7 +104,11 @@ export async function processLocalizedAssetCachedAsync(
104104
await cacheItem.storePromise(output);
105105
}
106106

107-
for (const { filename, source, info } of output.processedAssets) {
107+
const { localizedFiles, processedAssets } = output;
108+
109+
(chunk as ILocalizedWebpackChunk).localizedFiles = localizedFiles;
110+
111+
for (const { filename, source, info } of processedAssets) {
108112
if (originName === filename) {
109113
// This helper throws if the asset doesn't already exist
110114
// Use the function form so that the object identity of `related` is preserved.
@@ -116,7 +120,7 @@ export async function processLocalizedAssetCachedAsync(
116120
}
117121
}
118122

119-
return output.localizedFiles;
123+
return localizedFiles;
120124
}
121125

122126
export function processLocalizedAsset(options: IProcessLocalizedAssetOptions): IProcessLocalizedAssetResult {
@@ -141,7 +145,6 @@ export function processLocalizedAsset(options: IProcessLocalizedAssetOptions): I
141145
const { issues } = parsedAsset;
142146

143147
const localizedFiles: Record<string, string> = {};
144-
(chunk as ILocalizedWebpackChunk).localizedFiles = localizedFiles;
145148

146149
const processedAssets: IProcessedAsset[] = [];
147150

0 commit comments

Comments
 (0)