Skip to content

Commit

Permalink
[webpack5-loc-plugin] Fix missing metadata during rebuild (#5110)
Browse files Browse the repository at this point in the history
Co-authored-by: David Michon <[email protected]>
  • Loading branch information
dmichon-msft and dmichon-msft authored Feb 14, 2025
1 parent 6e9add6 commit 33336f6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/webpack5-localization-plugin",
"comment": "Fix a bug where `chunk.localizedFiles` was not set in incremental rebuilds.",
"type": "patch"
}
],
"packageName": "@rushstack/webpack5-localization-plugin"
}
11 changes: 7 additions & 4 deletions webpack/webpack5-localization-plugin/src/AssetProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ type ItemCacheFacade = ReturnType<ReturnType<Compilation['getCache']>['getItemCa
export async function processLocalizedAssetCachedAsync(
options: IProcessLocalizedAssetOptions
): Promise<Record<string, string>> {
const { compilation, asset, cache } = options;
const { compilation, asset, cache, chunk } = options;
const { source: originalSource } = asset;

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

for (const { filename, source, info } of output.processedAssets) {
const { localizedFiles, processedAssets } = output;

(chunk as ILocalizedWebpackChunk).localizedFiles = localizedFiles;

for (const { filename, source, info } of processedAssets) {
if (originName === filename) {
// This helper throws if the asset doesn't already exist
// Use the function form so that the object identity of `related` is preserved.
Expand All @@ -116,7 +120,7 @@ export async function processLocalizedAssetCachedAsync(
}
}

return output.localizedFiles;
return localizedFiles;
}

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

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

const processedAssets: IProcessedAsset[] = [];

Expand Down

0 comments on commit 33336f6

Please sign in to comment.