Repository navigation
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
conditionals: false?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default minifier compression (conditionals: true) merges ternary expressions calling the same function:
Because the argument becomes a dynamic expression (cond ? ...), the WordPress parser cannot statically extract either string, dropping them from translate.wordpress.org.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I test with this code snippet with and without
conditionals: falseand output is same in both cases.output:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch on that specific snippet! The reason both outputs were identical in your test is because
import { __ } from '@wordpress/i18n'compiles to an indirect external call(0, V.__)(...), which SWC's minifier does not fold.However, across Tutor's scripts (like
assets/src/js/admin-dashboard/segments/), we also use direct identifier calls via:With default
conditionals: true, SWC merges that into:When
wp i18n make-potscans this merged call, it fails to parse dynamic expressions and drops both strings from the generated.potfile on translate.wordpress.org. Settingconditionals: falseprevents SWC from folding these branches while keeping all other minifier passes active.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood.