Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions rspack.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,12 @@ const createConfig = (env, options) => {
new rspack.SwcJsMinimizerRspackPlugin({
extractComments: false,
minimizerOptions: {
compress: false,
compress: {
conditionals: false,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why conditionals: false?

Copy link
Copy Markdown
Collaborator Author

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:

// Original:
cond ? __("Active", "tutor") : __("Inactive", "tutor");
// Default minifier merges to:
__(cond ? "Active" : "Inactive", "tutor");

Because the argument becomes a dynamic expression (cond ? ...), the WordPress parser cannot statically extract either string, dropping them from translate.wordpress.org.

@sazedul-haque sazedul-haque Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

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: false and output is same in both cases.

const test_word = isEditMode ? __('True Word', 'tutor') : __('False Word', 'tutor');
console.log(test_word);

output:

console.log(e?(0,V.__)("True Word","tutor"):(0,V.__)("False Word","tutor"));

Copy link
Copy Markdown
Collaborator Author

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:

const { __ } = wp.i18n;
const test_word = isEditMode ? __('True Word', 'tutor') : __('False Word', 'tutor');

With default conditionals: true, SWC merges that into:

__(isEditMode ? "True Word" : "False Word", "tutor");

When wp i18n make-pot scans this merged call, it fails to parse dynamic expressions and drops both strings from the generated .pot file on translate.wordpress.org. Setting conditionals: false prevents SWC from folding these branches while keeping all other minifier passes active.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood.

},
ecma: 2015,
mangle: {
reserved: ['__'],
reserved: ['__', '_x', '_n', '_nx'],
},
format: {
comments: /translators/i,
Expand Down
Loading