Repository navigation
[webpack5-localization-plugin] Fix missing asset errors when localized chunks come from the cache - #6244
Open
Guru R Bharadwaj (guru-bharadwaj20) wants to merge 1 commit into
Conversation
The realContentHash step renames entries of the chunk's localizedFiles map in place. That map was the same object stored in the webpack cache, so a rebuild that read the chunk from the cache got the renamed filenames and failed with "Could not find asset".
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the fix protecting cached localized filenames during rebuilds.
No open issues 🎉
What changed in this PR
Fixes #6127 by preventing real-content-hash processing from mutating cached localized filenames, avoiding missing-asset errors on rebuilds.
Changes:
- Copies the cached filename map before attaching it to a chunk.
- Adds a two-build memory-cache regression test.
- Records a patch release note.
| File | Description |
|---|---|
webpack/webpack5-localization-plugin/src/test/LocalizedAsyncCachedRebuild.test.ts |
Tests cached rebuilds after changing a non-localized module. |
webpack/webpack5-localization-plugin/src/AssetProcessor.ts |
Copies the filename map to protect cached entries. |
common/changes/@rushstack/webpack5-localization-plugin/webpack5-localization-cached-files_2026-12-02-12-00.json |
Documents the rebuild fix for release. |
Review effort: Balanced
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
With
realContentHash: trueand a persistent or memory cache, a rebuild that reuses a cached localized chunk fails withCould not find asset "chunks/...-LOCALE.js" for chunk N. This happens in watch mode when you edit a module outside the localized chunk.Fixes #6127
Details
processLocalizedAssetCachedAsyncassigned the cachedlocalizedFilesobject directly tochunk.localizedFilesand returned it. The true hash step intrueHashes.tslater renames entries in that map in place, so it was also changing the object held in the cache. On the next build the cache returned the already renamed filenames, which no longer matched the assets emitted in that build.The fix copies the map before using it, so the cached object stays as it was produced.
How it was tested
I added
LocalizedAsyncCachedRebuild.test.ts. It builds twice with the same compiler and a memory cache, changing a non-localized module between builds. Before the fix the second build reports the two "Could not find asset" errors. After the fix both builds have no errors or warnings and the localized chunk names match.heft test --cleanpasses for the whole package.Impacted documentation
None.