Automattic / wc-calypso-bridge

20 stars 4 forks source link

i18n: Ensure i18n loader is included in the production build #1480

Closed yuliyan closed 5 months ago

yuliyan commented 5 months ago

Changes proposed in this Pull Request:

https://github.com/Automattic/wc-calypso-bridge/pull/1472 introduced loading translations for lazy loaded JS modules using @automattic/i18n-loader-webpack-plugin and a custom i18n loader module.

However, due to loadTranslations function from the i18n loader being used only in the runtime template, it got removed from the production build by Webpack's tree-shaking, which resulted in errors in the console when trying to fetch the translations.

This PR introduces some changes to ensure that the function is preserved in the production build and can be used in the runtime template.

How to test the changes in this Pull Request:

  1. Checkout the branch locally.
  2. Build the app locally with npm run build.
  3. Sync the changes to your test site by following the instructions from pdDOJh-3ob-p2.
  4. Change the language of your test site to any Mag-16 language.
  5. If your test site is not on Ecommerce Trial plan, override the isEcommercePlanandisEcommercePlanTrialparams totrue` in class-wc-calypso-bridge-shared.php.
  6. Navigate to /wp-admin/admin.php?page=wc-admin&path=%2Fmarketing and confirm strings are rendered translated.

Other information:

FOR PR REVIEWER ONLY:

github-actions[bot] commented 5 months ago

Size Change: +657 B (+0.33%)

Total Size: 200 kB

Filename Size Change
./build/53.js 1.08 kB +37 B (+3.53%)
./build/index.js 126 kB +521 B (+0.42%)
./build/payment-gateway-suggestions.js 6.56 kB +99 B (+1.53%)
ℹ️ View Unchanged | Filename | Size | | :--- | :---: | | `./build/index.css` | 883 B | | `./build/marketing.js` | 58 kB | | `./build/payment-gateway-suggestions.css` | 1.25 kB | | `./build/plugins.js` | 3.92 kB | | `./build/style-index.css` | 2.15 kB | | `./build/style-marketing.css` | 805 B |

compressed-size-action