Fix Webpack asset manifest generation for production exports#6214
Merged
Fix Webpack asset manifest generation for production exports#6214
Conversation
**Why**: So that the asset manifest plugin correctly identifies all assets.
see: https://github.com/webpack/webpack/blob/a72548f97037c941db3320397392a329f52db66a/lib/Template.js#L149 changelog: Internal, Build, Generate asset manifest during JavaScript build
zachmargolis
approved these changes
Apr 18, 2022
Contributor
zachmargolis
left a comment
There was a problem hiding this comment.
LGTM, thanks for the tests cases, they made it much easier to follow
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.
Why: So that the asset manifest plugin correctly identifies all assets.
This improves the plugin introduced in #6198, and addresses a similar peculiarity of Webpack code generation as in #6001. Similar to #6001, the regular expression should match the Webpack output pattern of
(0,getAssetPath)('path.svg')). Unlike #6001, we must account for the "comment" fragment which may be output as part of the code generation ((0,assets/* getAssetPath */.K)('id-card.svg'),). The reason this happens here and not in the translation plugin is because the translation exporttis already one character, and as such the Webpack mangling logic will not rename it, and the comment fragment is omitted if the export is not renamed. Based on the logic of the mangling plugin, we should expect that the renamed export would be one or more alphabetical characters, or_, or$.I'm hopeful this will also address the issue I observed at #6212 (comment) (will test to confirm).Edit: Confirmed.