Skip to content

Fix Webpack locale string extraction for split chunks#5740

Merged
aduth merged 1 commit intomainfrom
aduth-webpack-extract-string-split-chunk
Dec 21, 2021
Merged

Fix Webpack locale string extraction for split chunks#5740
aduth merged 1 commit intomainfrom
aduth-webpack-extract-string-split-chunk

Conversation

@aduth
Copy link
Contributor

@aduth aduth commented Dec 21, 2021

Why: So that strings for all chunks are generated, even if not directly associated with an entry module.

Specifically, if Webpack chooses to optimize by splitting a new chunk, the new chunk will have an entryModule of undefined, so the previous logic of isJavaScriptChunk would return false, and the string would not be translated.

This didn't affect us previously because chunk splitting tends to happen only for shared packages, and we don't share much code which involves translation. I noticed this while implementing a refactor in #5729 which would have introduced a new translation call to @18f/identity-component's TroubleshootingOptions component, where @18f/identity-component is a shared package between the document-capture and form-steps-wait entry points.

I'm hopeful this change should also help make the Webpack 4 to 5 transition a bit simpler, since I'd explored this previously and encountered an issue with Chunk.entryModule having been deprecated. Since we no longer rely on this, the upgrade may be easier.

References:

**Why**: So that strings for all chunks are generated, even if not directly associated with an entry module.
@aduth aduth merged commit 00becd2 into main Dec 21, 2021
@aduth aduth deleted the aduth-webpack-extract-string-split-chunk branch December 21, 2021 18:13
jmhooper pushed a commit that referenced this pull request Dec 28, 2021
**Why**: So that strings for all chunks are generated, even if not directly associated with an entry module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants