[webpack5-localization-plugin] Include a feature for generating true filename hashes.#4510
Merged
iclanton merged 24 commits intomicrosoft:mainfrom Feb 5, 2024
Merged
[webpack5-localization-plugin] Include a feature for generating true filename hashes.#4510iclanton merged 24 commits intomicrosoft:mainfrom
iclanton merged 24 commits intomicrosoft:mainfrom
Conversation
c70531c to
e03363c
Compare
e03363c to
3769d9f
Compare
dmichon-msft
reviewed
Feb 5, 2024
webpack/webpack5-localization-plugin/src/test/MixedAsync.test.ts
Outdated
Show resolved
Hide resolved
webpack/webpack5-localization-plugin/src/test/NonHashedNonLocalizedAssets.test.ts
Outdated
Show resolved
Hide resolved
webpack/webpack5-localization-plugin/src/test/NonHashedNonLocalizedAssets.test.ts
Outdated
Show resolved
Hide resolved
912fc05 to
4c7dfc8
Compare
4c7dfc8 to
15c0c58
Compare
dmichon-msft
approved these changes
Feb 5, 2024
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
The localization plugin currently has an issue where filename hashes are 1) the same on a chunk between all locales and 2) not updated if strings are changed. This PR introduces an option to the localization plugin called
useTrueHashesthat, when set totrue, updates hashes to match individual filenames' contents.Details
Updating hashes is achieved by postprocessing chunks after all localized variants are rendered. Chunks are processed in reverse-tree-order, updating the hashes of async chunks in the runtime chunk loading code in the runtime chunk's bodies after async chunks are renamed, and then hashing runtime chunks to reflect the updated async chunk filename hashes.
How it was tested
Unit tests in the localization plugin project have been updated to exercise this new functionality. This has also been tested in a large monorepo that uses the localization plugin.
Impacted documentation
This option should be documented.